Learn R Programming

popkin (version 1.0.5)

inbr: Extract inbreeding coefficients from a kinship matrix

Description

The kinship matrix \(\Phi^T\) contains inbreeding coefficients \(f_j^T\) along the diagonal, present as \(\phi_{jj}^T = \frac{1}{2}(1+f_j^T)\). This function extracts the vector of \(f_j^T\) values from the input \(\Phi^T\).

Usage

inbr(Phi)

Arguments

Phi

The \(n \times n\) kinship matrix \(\Phi^T\).

Value

The length-\(n\) vector of inbreeding coefficients \(f_j^T\) for each individual \(j\).

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

## extract inbreeding coefficients from Phi
inbr <- inbr(Phi)

# }

Run the code above in your browser using DataLab