Calculating allele frequencies in R……

Here is a simple annotated script to quickly calculate, output, and graph allele frequencies in R.  Here I have  downloaded data (via dryad) from Lander et al. 2011 of a European Beech data set genotyped at 13 microsatellite markers.  I have used a single population as the example data set.
Here is the output from the script at one locus:

Locus allele count frequency
mfc7 107 2 0.001751
mfc7 111 699 0.612084
mfc7 115 2 0.001751
mfc7 117 150 0.131349
mfc7 119 2 0.001751
mfc7 123 55 0.048161
mfc7 125 68 0.059545
mfc7 127 85 0.074431
mfc7 129 76 0.06655
mfc7 131 3 0.002627

and here is a plot of allele frequencies at a different locus:  Allele frequency plot
Please keep in mind that this is only one example of how to calculate allele frequencies.  Feel free to add your own suggestions or improvements in the comments.  If anybody has a script that calculates unbiased allele frequencies (with respect to sample size), I would be happy to post that as well.

This entry was posted in bioinformatics, howto, software. Bookmark the permalink.