makeTinv: Creates components of the additive genetic relationship...

View source: R/makeTinvDF.R

makeTinvR Documentation

Creates components of the additive genetic relationship matrix and its inverse

Description

This returns the Cholesky decomposition of the numerator relationship matrix and its inverse. It can also be used to obtain coefficients of inbreeding for the pedigreed population.

Usage

makeTinv(pedigree, ...)

## Default S3 method:
makeTinv(pedigree, ...)

## S3 method for class 'numPed'
makeTinv(pedigree, ...)

## Default S3 method:
makeT(pedigree, genCol = NULL, ...)

## Default S3 method:
makeDiiF(pedigree, f = NULL, ...)

## S3 method for class 'numPed'
makeDiiF(pedigree, f = NULL, ...)

Arguments

pedigree

A pedigree where the columns are ordered ID, Dam, Sire

...

Arguments to be passed to methods

genCol

An integer value indicating the generation up to which the T matrix is to be created (corresponding to columns of the lower triangle T matrix). The first generation is numbered 0, default is all generations.

f

A numeric indicating the level of inbreeding. See Details

Details

Missing parents (e.g., base population) should be denoted by either 'NA', '0', or '*'.

The function implements an adaptation of the Meuwissen and Luo (1992) algorithm (particularly, following the description of the algorithm in Mrode 2005) with some code borrowed from the inverseA function by Jarrod Hadfield in the MCMCglmm package.

At the moment, providing the inbreeding level of individuals or the base population has not been implemented. However, this argument is a placeholder for now.

Value

a list:

Tinv

the inverse of the Cholesky decomposition of the additive genetic relationship matrix (Ainv=Tinv' Dinv Tinv) in sparse matrix form

D

the diagonal D matrix of the A=TDT' Cholesky decomposition. Contains the variance of Mendelian sampling. Matches the order of the first/ID column of the pedigree.

f

the individual coefficients of inbreeding for each individual in the pedigree (matches the order of the first/ID column of the pedigree).

Author(s)

matthewwolak@gmail.com

References

Meuwissen, T.H.E & Luo, Z. 1992. Computing inbreeding coefficients in large populations. Genetics, Selection, Evolution. 24:305-313.

Mrode, R.A. 2005. Linear Models for the Prediction of Animal Breeding Values, 2nd ed. Cambridge, MA: CABI Publishing.

See Also

makeAinv, makeA

Examples


 Tinv <- makeTinv(Mrode2)
 # Method for a numeric pedigree (of `nadiv` class "numPed")
 nPed <- numPed(Mrode2)
 Tinv2 <- makeTinv(nPed)

 ########
 DF <- makeDiiF(Mrode2)
 # manually construct the inverse of the relatedness matrix `Ainv`
 Dinv <- DF$D  #<-- not the inverse yet, just copying the object
 Dinv@x <- 1 / DF$D@x  #<-- inverse of a diagonal matrix
 handAinv <- crossprod(Tinv, Dinv) %*% Tinv
   # make the A-inverse directly
   Ainv <- makeAinv(Mrode2)$Ainv
   # Compare
   handAinv
   Ainv
   stopifnot(all(abs((Ainv - handAinv)@x) < 1e-6))



matthewwolak/nadiv documentation built on July 7, 2023, 1:24 p.m.