please provide a code using bivariate GREML to estimate genetic correlation
Here is an example code using bivariate GREML to estimate genetic correlation in R:
library(lme4) library(lmerTest)
Load the data for two traits
data <- read.csv("data.csv")
Fit bivariate GREML model
model <- glmer(cbind(trait1, trait2) ~ 1 + (1|id), data = data, family = binomial)
Estimate genetic correlation
corr <- summary(model)$varcor$id[2]/(sqrt(summary(model)$varcor$id[1])*sqrt(summary(model)$varcor$id[3]))
Print genetic correlation
print(corr)
Note: This code assumes that the data is in a CSV file named "data.csv" and has columns named "id", "trait1", and "trait2". The bivariate GREML model is fitted using the glmer function from the lme4 package, with a binomial family specified for the response variable. The genetic correlation is estimated by dividing the variance of the random effect for id in trait2 by the product of the square roots of the variances of the random effects for id in trait1 and trait2.
原文地址: https://www.cveoy.top/t/topic/bFzo 著作权归作者所有。请勿转载和采集!