Learn R Programming

popkin (version 1.2.2)

pwfst: Estimate the individual-level pairwise FST matrix

Description

This function construct the individual-level pairwise \(F_{ST}\) matrix implied by the input kinship matrix. If the input is the true kinship matrix, the return value corresponds to the true pairwise \(F_{ST}\) matrix. On the other hand, if the input is the estimated kinship returned by popkin, then the return value is the pairwise \(F_{ST}\) estimates described in our paper. In all cases the diagonal of the pairwise \(F_{ST}\) matrix is zero by definition.

Usage

pwfst(kinship)

Arguments

kinship

The \(n \times n\) kinship matrix

Value

The \(n \times n\) pairwise \(F_{ST}\) matrix

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 from the genotypes "X"!
kinship <- popkin(X, subpops) # calculate kinship from X and optional subpop labels

# lastly, compute pairwise FST matrix from the kinship matrix
pwF <- pwfst(kinship)
 
# }

Run the code above in your browser using DataLab