matthewwolak / nadiv

R package that constructs (non)additive genetic relationship matrices, and their inverses, from a pedigree to be used in linear mixed effect models (A.K.A. the 'animal model').
17 stars 7 forks source link

Speedup make ainv #6

Closed matthewwolak closed 9 years ago

matthewwolak commented 9 years ago

makeAinv.R now implements the full Meuwissen & Luo (1992) algorithm for directly constructing the inverse of the additive (or numerator) relationship matrix. The main switch is to add elements to A-1 directly one by one instead of constructing T-1 and D-1 separately, then using matrix multiplication to obtain something akin to T-1 D-1 = L-1 and L-1 t(L-1) = A-1.

Both methods were comparable in speed. However, this now enables me to skip individuals who have the same parents as the previous individual the algorithm has run through (by assigning the value from the last individual without re-calculating). So now, the pedigree is sorted by generation, then dam, and sire - A-1 is computed - and A-1 is permuted to regain the order from the input pedigree.

The algorithm will also make the incorporation of genetic groups much easier.