8. Computing Genetic Covariances | R Documentation |
Pairwise genetic covariances for variables with the same experimental design
getGenCov(y, X = NULL, Z = NULL, K = NULL,
U = NULL, d = NULL, scale = TRUE,
pairwise=FALSE, verbose = TRUE, ...)
y |
(numeric matrix) Response variable matrix. It should contain more than one column |
X |
(numeric matrix) Design matrix for fixed effects. When |
Z |
(numeric matrix) Design matrix for random effects. When |
K |
(numeric matrix) Kinship relationship matrix |
U |
(numeric matrix) Eigenvectors from spectral value decomposition of G = U D U' |
d |
(numeric vector) Eigenvalues from spectral value decomposition of G = U D U' |
scale |
|
pairwise |
|
verbose |
|
... |
Other arguments passed to the function 'fitBLUP' |
Assumes that both y1 and y2 follow the basic linear mixed model that relates phenotypes with genetic values of the form
where b1 and b2 are the specific fixed effects, u1 and u2 are the specific genetic values of the genotypes, e1 and e2 are the vectors of specific environmental residuals, and X and Z are common design matrices conecting the fixed and genetic effects with replicates. Genetic values are assumed to follow a Normal distribution as u1 ~ N(0,σ2u1K) and u2 ~ N(0,σ2u2K), and environmental terms are assumed e1 ~ N(0,σ2e1I) and e2 ~ N(0,σ2e2I).
The genetic covariance σ2u1,u2 is estimated from the formula for the variance for the sum of two variables as
where σ2u3 is the genetic variance of the variable y3 = y1 + y2 that also follows the same model as for y1 and y2.
Likewise, the environmental covariance σ2e1,e2 is estimated as
where σ2e3 is the error variance of the variable y3.
Solutions are found using the function 'fitBLUP' (see help(fitBLUP)
) to sequentialy fit mixed models for all the variables y1, y2 and
y3.
Returns a list object that contains the elements:
varU
: (vector) genetic variances.
varE
: (vector) error variances.
covU
: (vector) genetic covariances between response variable 1 and the rest.
covE
: (vector) environmental covariances between response variable 1 and the rest.
When pairwise=TRUE
, varU
and varE
are matrices containing all variances (diagonal) and pairwise covariances (off diagonal)
require(SFSI)
data(wheatHTP)
index = which(Y$trial %in% 1:8) # Use only a subset of data
Y = Y[index,]
M = scale(M[index,])/sqrt(ncol(M)) # Subset and scale markers
G = tcrossprod(M) # Genomic relationship matrix
y = scale(Y[,4:7]) # Response variable
# Covariances between the first and the rest: y[,1] and y[,2:4]
fm = getGenCov(y=y, K=G)
fm$varU # Genetic variances
fm$varE # Residual variances
fm$covU # Genetic covariance between y[,1] and y[,2:4]
fm$covU+fm$covE # Phenotypic covariance
cov(y)[1,-1] # Sample phenotypic covariance
# Pairwise covariance for all columns in y
fm = getGenCov(y=y, K=G, pairwise=TRUE)
fm$varU
fm$varE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.