
Genomic relationship matrix from genotype data
Source:R/genomic_relationship.R
genomic_relationship.RdComputes the VanRaden (2008) genomic relationship matrix (GRM) from biallelic
marker genotypes, for use as the A argument of lmm_animal.
Arguments
- M
Numeric genotype matrix with individuals in rows and markers in columns, coded as the number of copies (0, 1, 2) of the counted allele. Missing genotypes are allowed (
NA); non-integer values such as imputed dosages are also accepted.- p
Optional vector of allele frequencies of the counted allele, one per column of
M. IfNULL(default), they are estimated fromMascolMeans(M, na.rm = TRUE) / 2. Supplying base-population frequencies is recommended when they are known.- maf
Markers with minor allele frequency below this value are dropped. Monomorphic markers (and, when
pis estimated, markers with a single observed genotype class) are always dropped.- max_missing
Markers with a proportion of missing genotypes above this value are dropped. Fully missing markers are always dropped, even when
max_missing = 1andpis supplied.- blend
Weight
win(1 - w) * G + w * I. Default 0 returns the raw GRM; a small value (e.g. 0.01) makes a singular GRM, such as one with fewer markers than individuals or duplicated genotypes, positive definite.
Value
A symmetric positive-semidefinite matrix with the individuals' row
names of M on both dimensions. The number of markers used and their
scaling constant are stored in the attributes n_markers and
scale.
Details
The GRM is G = Z %*% t(Z) / (2 * sum(p * (1 - p))), where
Z = M - 2p. Missing genotypes are replaced by their expected value
2p, so they contribute zero to the numerator. Fully missing markers
are excluded from both numerator and denominator; if other markers remain,
a warning is issued when they would otherwise pass the filters. With frequencies
estimated from the data, the diagonal averages about one plus the
inbreeding coefficient, and the off-diagonals are relative to the
sample average.