Saturday, April 7, 2012

New package for population genetic simulation & numerical analysis

I have just posted a new package, 'popgen', that does some relatively simple numerical analyses of basic population genetic models, as well as genetic drift and founder effect simulations. These are mostly a small number of functions that I have developed for teaching the population genetics section of the undergraduate evolutionary biology class I'm giving this semester (as well as one function that I developed for a paper I have submitted in collaboration with Manuel Leal at Duke). Consequently, the functions generally generate animations (e.g., here). I have usually incorporated a few different options for plotting in each case. For instance, the two figures below illustrate the end result of the same simulation of genetic drift in 10 populations for the allele frequency, p, and the mean heterozygosity (in the latter case, the red curved line shows the expected decline in heterozygosity through time). It is not currently possible to generate both animations at once; rather to replicate the same simulation and plot different aspects (gene frequency, genotype frequencies, heterozygosity, etc.) is necessary to control the seed and re-run. For instance, in the cases below I just did the following:

> require(popgen)
> set.seed(1); genetic.drift() # using all defaults
> set.seed(1); genetic.drift(show="heterozygosity")



I mostly built this package to make it easier to save, document & load the code I have developed for future instances in which I might teach this course - but now that I have done so, I thought that I might as well share it with the world!

A direct link to the package is here after which you can install as follows:

> install.packages("popgen_0.1.tar.gz",type="source",repos=NULL)

The package is also linked of my programs page where there is also a link to a PDF manual for the package.

2 comments:

  1. Thank you so much for sharing this great blog.Very inspiring and helpful too.Hope you continue to share more of your ideas.I will definitely love to read.
    London Population

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete

Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.