50% off | Unlimited Data & AI Learning

Last chance! 50% off unlimited learning

Sale ends in


popkin (version 1.1.2)

fst: Extract FST from a population-level kinship matrix or vector of inbreeding coefficients

Description

This function simply returns the weighted mean inbreeding coefficient fjT. If weights are NULL (default), the regular mean fjT is returned. If a kinship matrix ΦT is provided, then fjT are extracted from its diagonal using inbr (assumes the diagonal of ΦT is ϕjjT=12(1+fjT) as popkin returns, and not fjT as inbrDiag returns).

Usage

fst(x, w = NULL)

Arguments

x

The vector of inbreeding coefficients (fjT), or the kinship matrix ΦT if x is a matrix.

w

Weights for individuals (optional, defaults to uniform weights)

Value

FST

Details

The returned weighted mean inbreeding coefficient equals the generalized FST if all individuals are "locally outbred" (i.e. if the self relatedness of every individual stems entirely from the population structure rather than due partly to having unusually closely related parents, such as first or second cousins). Note most individuals in population-scale human data are locally outbred. If there are locally inbred individuals, the returned value will overestimate FST.

Examples

Run this code
# NOT RUN {
## Get FST from a genotype matrix

## 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
w <- weightsSubpops(subpops) # can weigh individuals so subpopulations are balanced
Fst <- fst(Phi, w) # use kinship matrix and weights to calculate fst

Fst <- fst(Phi) # no (or NULL) weights implies uniform weights

inbr <- inbr(Phi) # if you extracted inbr for some other analysis...
Fst <- fst(inbr, w) # ...use this inbreeding vector as input too!

# }

Run the code above in your browser using DataLab