Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

getGenCov

Genetic covariances


Description

Pairwise genetic covariances for variables with the same experimental design and equal variance

Usage

getGenCov(y1, y2, X = NULL, Z = NULL, K = NULL, 
      U = NULL, d = NULL, scale = TRUE, mc.cores = 1, ...)

Arguments

y1

(numeric vector) Response variable 1

y2

(numeric matrix) Response variable 2. The number of rows must be equal to length of vector y1

X

(numeric matrix) Design matrix for fixed effects. When X=NULL a vector of ones is constructed only for the intercept (default)

Z

(numeric matrix) Design matrix for random effects. When Z=NULL an identity matrix is considered (default) thus G = K; otherwise G = Z K Z' is used

K

(numeric matrix) Kinship relationships

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

TRUE or FALSE to scale y1 and y2 by their corresponding standard deviations so the resulting variables will have unit variance

mc.cores

(integer) Number of cores used. The analysis is run in parallel when mc.cores is greater than 1. Default is mc.cores=1

...

Other arguments passed to the function 'fitBLUP'

Details

Assumes that both y1 and y2 follow the basic linear mixed model that relates phenotypes with genetic values of the form

y1 = X b1 + Z u1 + e1
y2 = X b2 + Z u2 + e2

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(02u1K) and u2 ~ N(02u2K), and environmental terms are assumed e1 ~ N(02e1I) and e2 ~ N(02e2I).

The genetic covariance σ2u1,u2 is estimated from the formula for the variance for the sum of two variables as

σ2u1,u2 = 1/2(σ2u3 - σ2u1 - σ2u2)

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

σ2e1,e2 = 1/2(σ2e3 - σ2e1 - σ2e2)

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.

Value

Returns a list object that contains the elements:

  • varU1: genetic variance for response variable 1.

  • varU2: (vector) genetic variances for response variable 2.

  • varE1: error variance for response variable 1.

  • varE2: (vector) error variances for response variable 2.

  • covU: (vector) genetic covariances between response variables 1 and 2.

  • covE: (vector) environmental covariances between response variables 1 and 2.

Author(s)

Marco Lopez-Cruz (maraloc@gmail.com) and Gustavo de los Campos

Examples

require(SFSI)
  data(wheatHTP)
  
  X = scale(X[1:200,])/sqrt(ncol(X))    # Subset and scale markers
  G = tcrossprod(X)                     # Genomic relationship matrix
  y = as.vector(scale(Y[1:200,"YLD"]))  # Subset response variable
  WL = scale(WL[1:200,20:40])           # Subset reflectance data
  
  fm = getGenCov(y,WL,K=G)
  
  covU = fm$covU                     # Genetic covariance
  covP_corrected = fm$covU+fm$covE   # Phenotypic covariance
  covP_uncorrected = cov(y,WL)       # Genetic covariance
  
  plot(covP_corrected,covP_uncorrected)
  plot(covU,covP_uncorrected)
  plot(covU,covP_corrected)

SFSI

Sparse Family and Selection Index

v0.3.0
GPL-3
Authors
Marco Lopez-Cruz [aut, cre], Gustavo de los Campos [aut], Paulino Perez-Rodriguez [ctb]
Initial release
2021-04-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.