Calculates the realized additive relationship matrix.
Usage
A.mat(G,min.MAF=0.01,n.core=1,PD=TRUE)
Arguments
G
Matrix ($n \times m$) of unphased genotypes for $n$ lines and $m$ biallelic markers,
coded as {-1,0,1} = {aa,Aa,AA}. Fractional (imputed) and missing values (NA) are allowed.
min.MAF
Minimum minor allele frequency; default is 0.01.
n.core
For Mac, Linux, and UNIX users, setting n.core > 1 will enable parallel execution on a machine with multiple cores. R package multicore must be installed for this to work. Do not run multicore from within the R GUI; you must use the command line.
PD
When there is missing data, the A matrix is not positive semidefinite by construction. If PD=TRUE, the function nearPD is used to return the closest positive definite matrix, which can then be used in
Value
$n \times n$ additive relationship matrix
Details
The A matrix is calculated as $W W'/c$, where $W_{ik} = G_{ik} + 1 - 2 p_k$ and $p_k$ is the frequency of the 1 allele at marker k. The normalization constant is $c = 2 \sum_k {p_k (1-p_k)}$. When alleles are missing, each pairwise calculation is based only on the markers that are present for both lines.
#random population of 200 lines with 1000 markersG <- matrix(rep(0,200*1000),200,1000)
for (i in1:200) {
G[i,] <- ifelse(runif(1000)<0.5,-1,1)
}
#Additive relationship matrixA <- A.mat(G)