A couple of people have contacted me in the last little while to ask whether mmod
,
my little R library for calculating population differentiation statistics, can be
used to deal with sequence data.
When I was designing the pacakge I was really thinking about handling microsattelite genotypes, but the statistics that mmod calculates are actually all capable of dealling with almost any genetic data. Although the actualy calculations can be handled easily enough, it’s a bit of a pain converting standard sequence datasets into population
genetic ones. So, I’ve written a little function to aid the conversion of the standard representation of DNA sequences in R (DNAbin
objects) into the genind
object that is used to store population genetic data.
I’ll use this post to show you how it works, and to compare the “identity-based” statisitics mmod caluclates with the standard AMOVA approach to population differentiation from sequence data.
AMOVA
The most widely used method of measuring population differentiation from sequence data is Excoffier’s AMOVA (Analysis of Molecular Variance). This method takes into account the relationship betwen haplotypes in terms of genetic distance between them and paritions variation in those distances into within- and among-population components. It also produces an Fst-like statistic (called Phi-statisitics) for every level of population strucure being considered.
Emmanuel Paradis’ library pegas
can calulate
AMOVA for a given dataset. Here’s an example use some faked-up data:
1 2 3 4 |
|
1 2 3 4 5 6 7 8 9 |
|
To measure population differentiation we obviously need some populations, the
amova
function takes a vector assiging each individual in the dataset to a
particular location (note, you aren’t limited to two levels of population structure,
you can use R’s formula syntax to denote, say, ~samples/sites/regions):
1 2 3 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
For what ever reason amova
doesn’t give the Phi-statisitics for each analysis,
but we can do that for ourselves:
1 2 |
|
1
|
|
Everthing else (mmod)
AMOVA is very useful, but, like G_st it can be difficult to compare between studies because the Phi-statistics are partially dependant on the total diversity in the dataset. There is not obvious way to correct for this effect, while mainting the information on how haplotypes relate to each other.
An alternative approach is to discard that ifnormation, and simply use the frequency of each haplotype present to calculate differentiation statistics in the same way you would for alleles from SNPs or microsattelites. The latest build of mmod
has a function, as.genind.DNAbin
to make this easy. It’s not on CRAN just yet, but you can
install it from github. The function takes a DNAbin
object and a vector
of populations for each sequence:
1 2 3 4 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
Once you’ve converted a sequence file into a genind
object it behaves
just as you’d expect:
1
|
|
1 2 3 4 5 6 7 8 |
|
It is interesting to note the very different measures of differentiation you get from Gst_est (Nei’s G_st) and other statisitics. It some ways this is the worst possible example for G_st, since the statistic is known to be biased upward when (a) there are a small number of sub-populations being considered and (b) the over-all deversity is high.