in which the function name, msd, stands for migration,
selection, & drift. It is a relatively simple modification of
another function, drift.selection, but in which individuals
are swapped from one population to another at some rate. It's pretty flexible
in that, for instance, we simulate things like asymmetric migration rates
between populations (the function argument m should contain
emigration rates), differing effective population sizes, and
different genotypic selection between populations.

Here are a few of examples of how it might be used.

First, load package:

library(PopGen)
packageVersion("PopGen")

## [1] '0.9.1'

Now, genetic drift absent migration between populations:

msd(m=c(0,0),Ne=c(200,200),ngen=500) ## with NO migration

msd(m=c(0,0),Ne=c(200,200),ngen=500)

Next, migration but no selection:

Ne<-c(200,200)
msd(m=1/Ne,Ne=Ne,ngen=500) ## relatively low migration

msd(m=10/Ne,Ne=Ne,ngen=500) ## relatively high migration

Now we're ready to introduce divergent natural selection between
populations.

About this blog

This web-log chronicles the development of new tools for phylogenetic analyses in the phytools R package. Unless you a reading a very recent page of the blog, I recommend that you install the latest CRAN version of phytools (or latest beta release) before attempting to replicate any of the analyses of this site. That is because the linked functions may be archived, and very likely have been replaced by newer versions.