Problem 1: Marker Effects Model

Predict genomic breeding values using a marker effects model. The dataset is available from

https://charlotte-ngs.github.io/asmss2022/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/asmss2022/data/asm_geno_sim_data.csv 

Hints

  • The genomic variance \(\sigma_g^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: 2022-05-23 08:40:47 (pvr)

LS0tCnRpdGxlOiBBcHBsaWVkIFN0YXRpc3RpY2FsIE1ldGhvZHMgLSBOb3RlYm9vayAxMQphdXRob3I6IF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