Skip to content

Instantly share code, notes, and snippets.

@explodecomputer
Created February 4, 2015 15:20
Show Gist options
  • Save explodecomputer/651a3fee316dc3fb28c3 to your computer and use it in GitHub Desktop.
Save explodecomputer/651a3fee316dc3fb28c3 to your computer and use it in GitHub Desktop.
interpretation of rG and rP
# Assume that we have 2 traits and large sample size
# Each trait is a function of g and e
# g1 and g2 are correlated
# e1 and e2 are correlated
# g and e are independent
# y1 and y2 are correlated due to correlations in g and e combined
n <- 100000
g1 <- rnorm(n)
e1 <- rnorm(n)
b1 <- 0.1
b2 <- 0.2
b3 <- 0.3
b4 <- 0.4
g2 <- g1 * 0.5 + rnorm(n)
e2 <- e1 * 0.1 + rnorm(n)
y1 <- b1*g1 + b2*e1
y2 <- b3*g2 + b4*e2
# The expected covariance between the two traits is a function
# of the genetic and non genetic covariances
#
# cov(y1, y2)
# = cov(b1*g1 + b2*e1, b3*g2 + b4*e2)
# = b1*b3*cov(g1,g2) + b2*b4*cov(e1,e2)
# As can be seen here:
cov(y1, y2)
b1*b3*cov(g1,g2) + b2*b4*cov(e1,e2)
# We can estimate genetic correlation quite simply:
rg <- cor(g1,g2)
# And this is much higher than the phenotypic correlation
rp <- cor(y1,y2)
# And the ratio of the rg and rp doesn't make much sense
# i.e. the genetic correlation is the proportion of h2 in trait 1
# that can be captured by knowing all the causal variants in trait 2
# Whereas we know that the phenotypic correlation is the same except
# you also need to know the environmental factors
# Ultimately, the interpretation of rg is it tells you how much
# of the heritable component of trait 2 is predictable by the
# heritable component of trait 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment