Learn R Programming

hierfstat (version 0.04-22)

fstat: Wrapper for fst estimator from hierfstat package (from adegenet)

Description

pairwise.fst computes Nei's pairwise Fst between all pairs of populations using a '>genind object. Heretozygosities are weighted by group sizes (see details).

Usage

fstat(x, pop = NULL, fstonly = FALSE)

pairwise.fst(x, pop = NULL, res.type = c("dist", "matrix"))

Arguments

x

an object of class '>genind.

pop

a factor giving the 'population' of each individual. If NULL, pop is seeked from pop(x). Note that the term population refers in fact to any grouping of individuals'.

fstonly

a logical stating whether only the Fst should be returned.

res.type

the type of result to be returned: a dist object, or a symmetric matrix

Value

A vector, a matrix, or a dist object containing F statistics.

Details

The function fstat is a wrapper for varcomp.glob of the package hierfstat. For Fst, Fis and Fit, an alternative is offered by Fst from the pagas package (see example).

Let \(A\) and \(B\) be two populations of population sizes \(n_A\) and \(n_B\), with expected heterozygosity (averaged over loci) \(Hs(A)\) and \(Hs(B)\), respectively. We denote \(Ht\) the expected heterozygosity of a population pooling \(A\) and \(B\). Then, the pairwise \(Fst\) between \(A\) and \(B\) is computed as:

\( Fst(A,B) = \frac{(Ht - (n_A Hs(A) + n_B Hs(B))/(n_A + n_B) )}{Ht}\)

References

Nei, M. (1973) Analysis of gene diversity in subdivided populations. Proc Natl Acad Sci USA, 70: 3321-3323

See Also

Hs

Examples

Run this code
# NOT RUN {
if(require(adegenet)){
data(nancycats)

## pairwise Fst
mat.fst <- pairwise.fst(nancycats, res.type="matrix")
mat.fst
}

## Fst, Fis, Fit
## using hierfstat
if(require(hierfstat)){
fstat(nancycats)
}

## using pegas
if(require(pegas)){
data(nancycats)

## conversion to pegas's format
as.loci(nancycats)

## use Fst from pegas
fsttab <- Fst(as.loci(nancycats))

## average over loci
apply(fsttab, 2, mean)
}
# }

Run the code above in your browser using DataLab