Learn R Programming

BEDASSLE (version 1.6.1)

calculate.pairwise.Fst: Calculates unbiased pairwise Fst between a pair of populations

Description

This function calculates unbiased \(F_{ST}\) (based on Weir and Hill's \(\theta\), 2002), between a pair of populations/individuals. Loci for which either of the populations/individuals has missing data (i.e. - the sample size is zero) are excluded.

Usage

calculate.pairwise.Fst(allele.counts, sample.sizes)

Value

Pairwise unbiased \(F_{ST}\) between a pair of populations/individuals

Arguments

allele.counts

A matrix of allele counts of dimensions nrow = 2, one for each of the two populations/individuals between which pairwise \(F_{ST}\) is being calculated, and ncol = the number of loci genotyped.

sample.sizes

A matrix of sample sizes of dimensions nrow = 2, one for each of the two populations/individuals between which pairwise \(F_{ST}\) is being calculated, and ncol = the number of loci genotyped (i.e. - the dimensions of sample.sizes must match those of counts). Each cell gives the number of chromosomes successfully genotyped at each locus in each population.

Author

Gideon Bradburd

References

Weir,B.S. and W.G. Hill. 2002. Estimating F-statistics. Ann.Rev.Gen. 36:949-952.

Examples

Run this code
#With the HGDP dataset
	data(HGDP.bedassle.data)

#Draw 2 populations at random from the Eurasian HGDP dataset
	pop1 <- sample(nrow(HGDP.bedassle.data$allele.counts),1)
	pop2 <- sample(nrow(HGDP.bedassle.data$allele.counts),1)

#Calculate unbiased Fst between them
	pairwise.Fst <- calculate.pairwise.Fst(
		HGDP.bedassle.data$allele.counts[c(pop1,pop2),],
		HGDP.bedassle.data$sample.sizes[c(pop1,pop2),]	
	)

#Print that Fst to the console
	print(sprintf("Fst between the %s population and the %s population is %s",
		HGDP.bedassle.data$hgdp.metadata[pop1,1],
		HGDP.bedassle.data$hgdp.metadata[pop2,1],
		round(pairwise.Fst,3))
	 )

Run the code above in your browser using DataLab