R/fst.R
fst.each.snp.hudson.Rd
Fixation index (Fst) calculation was implemented using Hudson method as in Bhatia (2013) and Hudson (1992).
fst.each.snp.hudson(X, idx.p1, idx.p2)
A matrix contains the number 0, 1, and 2 representing SNP in additive coding. Rows represent individuals and columns represent SNP.
An integer vector contains the row indices of first population in the matrix X.
An integer vector contains the row indices of second population in the matrix X.
The function returns a matrix of pairwise Fst values for all SNPs between 2 specified groups.
Bhatia, G., Patterson, N., Sankararaman, S., and Price, A.L. (2013). Estimating and interpreting FST: The impact of rare variants. Genome Res. 23, 1514-1521.
Hudson, R.R., Slatkin, M., and Maddison, W.P. (1992). Estimation of levels of gene flow from DNA sequence data. Genetics 132, 583-589.
#Load simulated dataset
data(example_SNP)
idx1 <- which(sample_labels == 'pop1')
idx2 <- which(sample_labels == 'pop2')
fst.pairwise <- fst.each.snp.hudson(simsnp$snp, idx1, idx2)
#Print out the Fst values of the first three SNPs between 'pop1' and 'pop2'
print(fst.pairwise[1:3])
#> [1] 0.007396462 0.099574837 -0.006330218