s_ped_data <- "https://charlotte-ngs.github.io/lbgfs2024/data/ped_num_rel_mat.csv"
tbl_pedigree <- readr::read_delim(file = s_ped_data,
col_types = readr::cols(Calf = readr::col_integer(),
Sire = readr::col_integer(),
Dam = readr::col_integer()))
knitr::kable(tbl_pedigree, booktabs = TRUE, longtable = TRUE)
LBG - FS2024 – Exercise 6
Problem 1: Numerator Relationship Matrix
The following pedigree is given
The pedigree can be read from the file:
Compute the numerator relationship matrix
- diagonal element
as where where and are parents of . - off-diagonal element
as where and are parents of
Task
Use two nested loops over the rows and the columns of matrix
- Read the pedigree from the given file
- Add parents that do not appear as animals to the column of animals
- Create an empty square matrix
with as many rows and columns as we have animals in the pedigree. - Use the above formula to compute the diagonal element of the first row
- Create a first loop to compute all the off-diagonal elements of the first row
- Create a loop to repeat the computations over all rows.
Solution
Pedigree is read from the given file
Find animals that appear only as parents, start with sires
The same for the dams
Combining them into one vector and sorting them
Add pedigree records for founder animals at the top of the pedigree
An empty matrix
Start with the diagonal elemenent for animal 1
Offdiagonal elements belonging to animal 1
The above two steps can be extended to all rows
Problem 2: Verification
Use the function pedigreemm::getA()
from package pedigreemm
to verify your result from problem 1.
Solution
The pedigree is defined by
The numerator relationship matrix is computed by
Check whether matrices are identical