makeTinv | R Documentation |
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.
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, ...)
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
|
f |
A numeric vector indicating the level of inbreeding. See 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.
The inbreeding level of individuals can be provided instead of calculated.
f
must be a vector that is the same length as individuals in the
pedigree. Supplied coefficients of inbreeding are used instead of being
calculated until a NA
is encountered in the vector. From this position
on, then coefficients of inbreeding are calculated and replace entries in
f
. This can be used, for example, to calculate coefficients of
inbreeding for later generations when coefficients of inbreeding in the
previous generations have already been calculated. To specify an average
coefficient of inbreeding for the base population, modify the pedigree to
include a single phantom parent and specify this individual's non-zero
coefficient of inbreeding in f
with the rest of the terms as NA.
a list
:
the inverse of the Cholesky decomposition of the additive genetic relationship matrix (Ainv=Tinv' Dinv Tinv) in sparse matrix form
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.
the individual coefficients of inbreeding for each individual in the pedigree (matches the order of the first/ID column of the pedigree).
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.
makeAinv
, makeA
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))
# supply previous generation coefficients of inbreeding (f)
## to keep from re-calculating their f when analyzing subsequent generations
DF <- makeDiiF(Mrode2[, 1:3])
Mrode2$gen <- genAssign(Mrode2)
Mrode2$f_full <- DF$f
Mrode2$f_in <- with(Mrode2, c(f_full[gen <= 1], rep(NA, sum(gen > 1))))
DF2 <- makeDiiF(Mrode2[, 1:3], f = Mrode2$f_in)
stopifnot(identical(DF, DF2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.