Monday, March 5, 2012

Function to model selection at a biallelic locus

This is not for phytools, but I am teaching evolutionary biology to undergrads this semester. We are presently studying population genetics and for class tomorrow I decided to write an R function to illustrate selection at one locus. The function takes a starting allele frequency and fitnesses for each of the three genotypes as input, and then it can plot various things: the frequency of A or a over time; the mean fitness through time; and the population mean fitness as a function of p. The function is as follows:

  p<-wbar<-vector(); p[1]<-p0
  for(i in 2:time){
      xlab="time",main="frequency of A")
    else if(show=="q")
      ylab="q",main="frequency of a")
    else if(show=="fitness")
      xlab="time",main="mean fitness")
    else if(show=="surface")
    else {
      message("not a recognized option")
    plot(p,wbar,type="l",ylim=c(0,1),main="mean fitness")

Here is an example of a run to illustrate selection on A in which the fitness advantage of the A allele is recessive.

1 comment:

  1. I have been using this replica watch, it is a very beautiful and affordable automatic watch, replica rolex watch uk good size, great quality, elegant and temperament, is my favorite style. replica rolex datejust watchI shared this website with my friends and they were very happy.