Problem 1: Marker Effects Model
Predict genomic breeding values using a marker effects model. The
dataset is available from
https://charlotte-ngs.github.io/asmss2023/data/asm_geno_sim_data.csv
Hints
- The variance \(\sigma_q^2\) of the
marker effect is \(3\).
- The residual variance \(\sigma_e^2\) is \(36\)
- The sex of each animal can be modelled as a fixed effect
Your Solution
- Read the data
- Setup mixed model equations to predict marker effects for all the
SNP-loci
- Compute predicted genomic breeding values based on the estimated
marker effects
Problem 2: Breeding Value Based Model
Use the same dataset as in Problem 1 to predict genomic breeding
values based on a breeding-value model. The dataset is available
from
https://charlotte-ngs.github.io/asmss2023/data/asm_geno_sim_data.csv
Hints
- The genomic variance \(\sigma_u^2\)
of the marker effect is \(9\).
- The residual variance \(\sigma_e^2\) is \(36\)
- The sex of each animal can be modelled as a fixed effect
- Use the following function to compute the genomic relationship
matrix \(G\) based on the matrix of
genotypes
computeMatGrm <- function(pmatData) {
matData <- pmatData
# check the coding, if matData is -1, 0, 1 coded, then add 1 to get to 0, 1, 2 coding
if (min(matData) < 0) matData <- matData + 1
# Allele frequencies, column vector of P and sum of frequency products
freq <- apply(matData, 2, mean) / 2
P <- 2 * (freq - 0.5)
sumpq <- sum(freq*(1-freq))
# Changing the coding from (0,1,2) to (-1,0,1) and subtract matrix P
Z <- matData - 1 - matrix(P, nrow = nrow(matData),
ncol = ncol(matData),
byrow = TRUE)
# Z%*%Zt is replaced by tcrossprod(Z)
return(tcrossprod(Z)/(2*sumpq))
}
- If the genomic relationship matrix \(G\) which is computed by the function above
cannot be inverted, add \(0.05 * I\) to
\(G\) which results in \(G^*\) and use \(G^*\) as genomic relationship matrix.
Your Solution
- Read the data
- Compute the inverse genomic relationship matrix using the given
function for the genomic relationship matrix
- Setup mixed model equations to predict genomic breeding values
Latest Changes: 2023-05-14 09:14:12 (pvr)
LS0tCnRpdGxlOiBBcHBsaWVkIFN0YXRpc3RpY2FsIE1ldGhvZHMgLSBOb3RlYm9vayA3CmF1dGhvcjogUGV0ZXIgdm9uIFJvaHIKZ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