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 \(A\) for the given pedigree. Recall from the course notes that elements of matrix \(A\) are computed differently for elements on the diagonal and for off-diagonal elements. In summary, we compute
- diagonal element \((A)_{ii}\) as \((A)_{ii} = 1+F_i\) where \(F_i = 0.5 * (A)_{sd}\) where \(s\) and \(d\) are parents of \(i\).
- off-diagonal element \((A)_{ki}\) as \((A)_{ki} = 0.5 * \left[(A)_{ks} + (A)_{kd}\right]\) where \(s\) and \(d\) are parents of \(i\)
Task
Use two nested loops over the rows and the columns of matrix \(A\) to compute all the elements of matrix \(A\) using the formulas given above. You can use the following steps to get to the solution
- 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 \(A\) 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 \(A\) is initialized
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