Learn R Programming

popkin (version 1.1.2)

inbrDiag: Replace kinship diagonal with inbreeding coefficients

Description

The usual kinship matrix contains self-kinship values \(\phi_{jj}^T = \frac{1}{2}(1+f_j^T)\) where \(f_j^T\) are inbreeding coefficients. This function returns a modified kinship matrix with each \(\phi_{jj}^T\) replaced with \(f_j\) (off-diagonal \(j \ne k\) values stay the same). This form produces more aesthetically pleasing visualizations, but is not appropriate for modeling (e.g. in GWAS or heritability estimation).

Usage

inbrDiag(Phi)

Arguments

Phi

The kinship matrix with self-kinship values along the diagonal

Value

The modified kinship matrix, with inbreeding coefficients along the diagonal

Examples

Run this code
# NOT RUN {
## Construct toy data
X <- matrix(c(0,1,2,1,0,1,1,0,2), nrow=3, byrow=TRUE) # genotype matrix
subpops <- c(1,1,2) # subpopulation assignments for individuals

## NOTE: for BED-formatted input, use BEDMatrix!
## "file" is path to BED file (excluding .bed extension)
# library(BEDMatrix)
# X <- BEDMatrix(file) # load genotype matrix object

## estimate the kinship matrix "Phi" from the genotypes "X"!
Phi <- popkin(X, subpops) # calculate kinship from X and optional subpop labels

## lastly, replace diagonal of kinship matrix with inbreeding coefficients
PhiMod <- inbrDiag(Phi)

# }

Run the code above in your browser using DataLab