Constructs the SNP additive genomic relationship matrix (G) following VanRaden (2008) Method 1. The resulting matrix captures additive genetic relationships among individuals based on SNP marker data, and can be used directly in masreml() or gwablup() via the G argument.
Usage
build_G_snp(W, ref_W = NULL)
Arguments
W
numeric matrix (n x m) of raw genotype codes, where n is the number of individuals and m is the number of SNP markers. Values must be 0, 1, or 2 representing the number of copies of the reference allele. Row names are used as individual IDs. Example format:
SNP1 SNP2 SNP3
ind1 0 1 2
ind2 1 0 1
ind3 2 1 0
Details
SNP additive GRM (VanRaden 2008). The centred genotype matrix \(W\) is first constructed by:
\(W_{ij} = X_{ij} - 2p_j\)
where \(X_{ij} \in \{0,1,2\}\) is the allele dosage of individual \(i\) at SNP \(j\) and \(p_j\) is the allele frequency. The additive GRM is then:
\(G = \frac{WW^\top}{2\sum_j p_j(1-p_j)}\)
The denominator \(2\sum_j p_j(1-p_j)\) scales \(G\) so that diagonal elements average approximately 1 (i.e., similar to the pedigree-based numerator relationship matrix).
Value
numeric matrix (n x n) of genomic relationships. Diagonal elements approximate 1 + inbreeding coefficient. Off-diagonal elements represent genomic relationships between pairs of individuals.
References
VanRaden, P. M. (2008) Efficient methods to compute genomic predictions. J. Dairy Sci. 91:4414-4423. doi:10.3168/jds.2007-0980
See Also
build_G_mh, build_D_snp, masreml
Examples
Code
library("masreml")d<-load_data("small")G<-build_G_snp(d$snp)# Diagonal should be ~1 + inbreeding coefficientround(summary(diag(G)), 3)# Train-only G with leakage-safe full-set G for predictionG_train<-build_G_snp(d$snp[d$train_idx, ])G_full<-build_G_snp(d$snp, ref_W =d$snp[d$train_idx, ])