R: Calculates unbiased pairwise Fst between all sampled...
calculate.all.pairwise.Fst
R Documentation
Calculates unbiased pairwise Fst between all sampled populations
Description
This function calculates unbiased F_{ST} (based on Weir and Hill's θ,
2002), between all populations/individuals included in the counts matrix, and
returns the results in a k by k matrix, where k = nrow(counts).
Loci for which either of the populations/individuals has missing data (i.e. - the sample
size is zero) are excluded.
A matrix of allelic count data, for which nrow = the number of populations
and ncol = the number of bi-allelic loci sampled. Each cell gives the number
of times allele ‘1’ is observed in each population. The choice of which allele is
allele ‘1’ is arbitrary, but must be consistent across all populations at a locus.
sample.sizes
A matrix of sample sizes, for which nrow = the number of populations
and ncol = the number of bi-allelic loci sampled (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.
Value
A matrix of pairwise, unbiased F_{ST}.
Author(s)
Gideon Bradburd
References
Weir,B.S. and W.G. Hill. 2002. Estimating F-statistics. Ann.Rev.Gen. 36:949-952.
Examples
#With the HGDP dataset
data(HGDP.bedassle.data)
#Calculate pairwise Fst between all population pairs
hgdp.pairwise.Fst <- calculate.all.pairwise.Fst(
HGDP.bedassle.data$allele.counts,
HGDP.bedassle.data$sample.sizes
)
#Plot pairwise Fst against geographic distance
plot(HGDP.bedassle.data$GeoDistance,
hgdp.pairwise.Fst,
pch=19,
col=HGDP.bedassle.data$EcoDistance+1,
ylab="pairwise Fst",
xlab="geographic distance",
main="isolation by distance")
legend(x="bottomright",pch=19,col=c(1,2),
legend=c("same side of Himalayas",
"opposite sides of Himalayas"))
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(BEDASSLE)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/BEDASSLE/calculate.all.pairwise.Fst.Rd_%03d_medium.png", width=480, height=480)
> ### Name: calculate.all.pairwise.Fst
> ### Title: Calculates unbiased pairwise Fst between all sampled populations
> ### Aliases: calculate.all.pairwise.Fst
>
> ### ** Examples
>
> #With the HGDP dataset
> data(HGDP.bedassle.data)
>
> #Calculate pairwise Fst between all population pairs
> hgdp.pairwise.Fst <- calculate.all.pairwise.Fst(
+ HGDP.bedassle.data$allele.counts,
+ HGDP.bedassle.data$sample.sizes
+ )
>
> #Plot pairwise Fst against geographic distance
> plot(HGDP.bedassle.data$GeoDistance,
+ hgdp.pairwise.Fst,
+ pch=19,
+ col=HGDP.bedassle.data$EcoDistance+1,
+ ylab="pairwise Fst",
+ xlab="geographic distance",
+ main="isolation by distance")
> legend(x="bottomright",pch=19,col=c(1,2),
+ legend=c("same side of Himalayas",
+ "opposite sides of Himalayas"))
>
>
>
>
>
> dev.off()
null device
1
>