Learn R Programming

kinship2 (version 1.9.6.1)

ibdMatrix: Create an IBD matrix

Description

Transform identity by descent (IBD) matrix data from the form produced by external programs such as SOLAR into the compact form used by the coxme and lmekin routines.

Usage

ibdMatrix(id1, id2, x, idmap, diagonal)

Value

a sparse matrix of class dsCMatrix. This is the same form used for kinship matrices.

Arguments

id1, id2

pairs of subject identifiers

x

the IBD value for that pair

idmap

an optional 2 column matrix or data frame whose first element is the internal value (as found in id1 and id2), and whose second element will be used for the dimnames of the result

diagonal

optional value for the diagonal element. If present, any missing diagonal elements in the input data will be set to this value.

Details

The IBD matrix for a set of n subjects will be an n by n symmetric matrix whose i,j element is the contains, for some given genetic location, a 0/1 indicator of whether 0, 1/2 or 2/2 of the alleles for i and j are identical by descent. Fractional values occur if the IBD fraction must be imputed. The diagonal will be 1. Since a large fraction of the values will be zero, programs such as Solar return a data set containing only the non-zero elements. As well, Solar will have renumbered the subjects as 1:n in such a way that families are grouped together in the matrix; a separate index file contains the mapping between this new id and the original one. The final matrix should be labeled with the original identifiers.

See Also

kinship, Matrix