fst {popkin} | R Documentation |
This function simply returns the weighted mean inbreeding coefficient.
If weights are NULL
(default), the regular mean is calculated.
If a kinship matrix is provided, then the inbreeding coefficients are extracted from its diagonal using inbr
(requires the diagonal to contains self-kinship values (φ_jj^T = (1+f_j^T)/2) as popkin
returns, and not inbreeding coefficients (f_j^T) as inbr_diag
returns).
fst(x, weights = NULL)
x |
The vector of inbreeding coefficients, or the kinship matrix if |
weights |
Weights for individuals (optional, defaults to uniform weights) |
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.
FST
# 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 "kinship" from the genotypes "X"! kinship <- popkin(X, subpops) # calculate kinship from X and optional subpop labels weights <- weights_subpops(subpops) # can weigh individuals so subpopulations are balanced Fst <- fst(kinship, weights) # use kinship matrix and weights to calculate fst Fst <- fst(kinship) # no (or NULL) weights implies uniform weights inbr <- inbr(kinship) # if you extracted inbr for some other analysis... Fst <- fst(inbr, weights) # ...use this inbreeding vector as input too!