getTInv: Inverse gene flow from a pedigree

View source: R/pedigree.R

getTInvR Documentation

Inverse gene flow from a pedigree

Description

Get inverse gene flow matrix from a pedigree.

Usage

getTInv(ped)

Arguments

ped

pedigree

Value

matrix (dtCMatrix - lower unitriangular sparse)

Examples

ped <- pedigree(sire = c(NA, NA, 1,  1, 4, 5),
                dam =  c(NA, NA, 2, NA, 3, 2),
                label = 1:6)
(TInv <- getTInv(ped))

# Test for correctness
TInvExp <- matrix(data = c( 1.0,  0.0,  0.0,  0.0,  0.0,  0.0,
                            0.0,  1.0,  0.0,  0.0,  0.0,  0.0,
                           -0.5, -0.5,  1.0,  0.0,  0.0,  0.0,
                           -0.5,  0.0,  0.0,  1.0,  0.0,  0.0,
                            0.0,  0.0, -0.5, -0.5,  1.0,  0.0,
                            0.0, -0.5,  0.0,  0.0, -0.5,  1.0),
                  byrow = TRUE, nrow = 6)
stopifnot(!any(abs(TInv  - TInvExp) > .Machine$double.eps))
stopifnot(is(TInv, "sparseMatrix"))

pedigreeTools documentation built on Oct. 12, 2024, 9:07 a.m.