Skip to content

Instantly share code, notes, and snippets.

@Ram-N
Last active December 14, 2015 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ram-N/5136763 to your computer and use it in GitHub Desktop.
Save Ram-N/5136763 to your computer and use it in GitHub Desktop.
#Bookkeeping
calcAllelesInGeneration <- function(x) {
AA = sum(x==1)
AB = sum(x==2)
BB = sum(x==3)
#print(unlist(x))
#print(c(AA, AB, BB))
num.A <- (2 * AA) + AB
num.B <- (2 * BB) + AB
return(c(num.A, num.B))
}
###plotting function
plotAllelesWithTime <- function(df, num.trials) {
colorRange<-colorRampPalette(c(rgb(0,0,1), rgb(1,0.7,0) ))
p <- ggplot(df, aes(x= Generation, y= value, group=Trial, color=factor(Trial))) + geom_line()
p <- p + scale_colour_manual(values = colorRange(num.trials),
name="Trial")
p <- p + labs(title = "Allele A Frequencies Across Generations (2011) ")
p <- p + ylab("Number of \"A\" Allele in the Population")
return(p)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment