Happy Birthday Charles Darwin.



February 12th is the day evolutionary biologists (and evolutionists) celebrate every year as Darwin Day. On this day in 1809 one of the most important influences on the world of evolutionary biology was born. After years of travelling and study, including a five year voyage on the HMS Beagle, he published the infamous book On the Origin of Species in 1859 which featured his theory of evolution supported with compelling evidence. Without his work, and interactions with the Alfred R. Wallace, it is likely that the field would be much less advanced than it is.

Happy Darwin Day, thanks Charles Robert Darwin.

Nye/Ham debate: Historical science.

In the creation story, found in the book of Genesis in the bible, God separated light from dark in one day, the next day he created the sky, and on the third day land and vegetation. On the fourth day came the sun, moon, and stars to marks seasons, night, and day, all by God’s hand. On the fifth day God created living creatures of the sea and skies and on the sixth he created the animals of the land. Those land animals included the humans to care for, rule over, and cultivate all other animals.


This is the proof that biblical creationists such as Ray Comfort and Ken Ham will cite as the way in which life came in to existence. The evidence they turn to is a written account of the events leading up to, and including, the creation of man. It’s an interesting choice. Here is a quote from Ken Ham in the recent creation debate with Bill Nye (04-02-2014, Creation Museum, Kentucky).

 “…there’s aspects about the past that you can’t scientifically prove because you weren’t there.” – Ken Ham (view the debate here, quote taken from around 1:59:00)

horse fossil evolution

Rough schematic of horse evolution constructed using fossil evidence, past (~50 MYA, left) to present (right)

It’s an argument often used by the creationists to rebut the use of evolutionists arguments that go along the lines of “you can prove evolution by looking at the fossil records because they are the fossils of organisms that once existed.” Creationists say that, because no one saw dinosaurs roaming the earth 200 million years ago, evolutionists cannot say there were dinosaurs 200 million years ago. It’s a distinction that they term “historical science” – a term which carries no meaning beyond the Creationist circles and requires direct human observation of an event for it to be admissible as evidence in the debate. Ray Comfort repeatedly uses this argument to shut down evolutionists in the 2013 video Evolution vs God (see ~3:20 for example in the EvG video).

“Historical science” is analogous to the use of evidence other than direct witness accounts in a crime. Clues are used to piece together the story so that a conviction can be brought without the need for witnesses. Imagine how few crimes would be punished if Ken Ham made the rules.

My question to creationists is if God did not create man until the 6th day, how do we know what he did in the preceding 5 days? No one was there to see it. I feel that creationists should be able to answer this seeing as it is there description of evidence that it must be directly observed, otherwise their use of the argument is hypocrisy (and hypocrisy is a sin). However, I personally think that direct observation of an event is not the only way to prove an events happening (I’ll perhaps post something on that in the future).

Nye/Ham debate: The orchard of creation.

 “…from such low and intermediate form, both animals and plants may have been developed; and, if we admit this, we must likewise admit that all organic beings which have ever lived on this earth may be descended from some one primordial form.” – Ken Ham quoting Charles Darwin.

This quote describes the evolutionary tree of life. It proposes that every organism has a common ancestor, and, logically more closely related species have more recent common ancestors. According to Ham this suggests that we do not need to find every species of dog (Canidae), every species of cat (Felidae), and every species of elephant (Proboscidea) on Noah’s Ark.

Based on the accounts of the bible, creationists have described an orchard of creation which stipulates that we only need two dogs, two apes, two birds, two dinosaurs, two lizards, two of each “kind” to lead to all of the species we have. Because there is great variation in genetics of any creature the new species, such as every Canidae species, can develop from the two individuals of the kind found on the ark. Ham also states that because lineages do not switch “kind” that evolution must not be true, species do not evolve by descent with modification.

creation orchard

An illustration of the Orchard of Creation

Now I may be wrong, but, Ham has just massively contradicted himself hasn’t he? The orchard of creation he describes is, by definition, and example of evolution. Is the descent from one species to many not the perfect manifestation of “descent with modification,” Darwin’s definition of evolution? Furthermore, I am aware of no theory that says lineages can or do switch kinds (or family) on the tree of life. No credible evolutionary biologist suggests that birds evolve in to apes, or dogs in to cats. Evolutionary theory proposes that these species share a common ancestor on the tree of life (and the orchard of creation) but evolution does not suggest that they will ever share a common descendant. The tree of life is a tree, on a tree the branches do not split in two and then rejoin later in life. One branch descends in to many.


This is not what happens in Evolutionary theory. There is no change of “kind.”

Thanks Ken Ham. All you’ve done is prove you do not understand the theory of evolution. It would be great if people challenging the theory of evolution could get the definition right. Creationists are ignoring the real argument because of the confused understanding of evolution. The views of creationism (those accepting the orchard of life) and evolutionary biologists differ, not forward of the division of new lineages, but prior to the division of phylogenetic families.

where evolution differs

Hint… this is where the true debate lies

Creationists must refocus themselves or face losing significant ground in the debate over the origins of life on earth. Move on from attacks on the character of atheists and attempts to promote a false interpretation of the views of evolutionary biologists (creationists can be scientists as long as they are objective about their research). I think it is a debate which should continue and one which evolutionary biologists should not ignore because many people still do not accept evolution to be true. Eventually one side will produce such compelling evidence that it can no longer be debated, until then the discussion is bound to continue.

I will deal with the issue of “observable” evidence in new blog post soon because apparently we can’t observe fossils, my eyes must be deceiving me…

Evolution can only be true.

This entry is based on a short public talk I saw by a former lecturer of mine last year (Professor Tom Tregenza). He put across a simple way to argue that evolution is a process that cannot be denied. I chose to write about it because of it’s simplicity and elegance. I start by defining evolution and then expanding on the points made by Tom.

The theory of evolution was defined by Darwin as “Descent with modification.” That is, characteristics descend along a lineage (from parent to offspring) and, between generations, can become different from the ancestral characteristic. It is, in my opinion, only a theory by scientific definition, just like the theory of gravity. I know that if I stand on the surface of the earth and drop an apple, without applying any other forces, it will fall to the ground because of gravity. The existence of evolution is equally as certain, yet many do not accept it.

The aim of Tom’s talk was to provide a logical basis, supported by fact, upon which the only outcome that makes sense is to accept evolution. All of the following questions can only be answered with “yes” and thus irrefutably support evolution. I do not provide hard evidence for many of these points because the answers are so obviously true.


1. Do living organisms reproduce?

The very definition of life states that all living organisms reproduce. Every single species on the tree of life reproduces in some capacity. Right from simple clonal reproduction of single celled organisms through to the sexual reproduction found in many eukaryotes, and all sorts of weird and wonderful variations in-between and beyond. The answer to this question is undoubtedly yes.

2. Do some individual organisms have more offspring than others?

There is high variation in reproductive success even within species. Looking to humans we know that some people die before reaching a reproductive age, some are infertile, some chose not to have children, and some chose to have many. Looking across species we see even greater variance from very few offspring per parent to many thousands. Again, the answer to this question is yes.

3. Do individuals vary in their characteristics?

Look around you, there is variance in height, hair color, eye color, between species there is variance in the number of legs used to walk, the number and type of limbs species have, body size, shape, senses, color, behavior, and much more. So, is there variation between individuals? Yes.

4. Are characteristics heritable?

Again look at humans. We more often see that the characters of offspring resemble their parent’s characters more than the homologous character of a random organism. Tall people tend to have tall children. Short people tend to have short children. Humans tend to produce offspring that look more like humans than an elephant, and elephants tend to produce offspring that look more like elephants than humans. Obviously there is heritability in traits (and much of this is due to the passing of genes along a lineage) so the answer is thus yes.

5. Are traits causing variance in reproductive success heritable?

An example of this would be the genetic inheritance of disease. Some diseases kill people before they have reached the end of their natural reproductive window, the point where they can no longer viably reproduce. Cancer has been linked to genetic mutations which can be passed from parent to offspring (for example the BRCA1 gene is linked to high incidences of breast cancer). If a cancer, passed along the lineage, stops an individual from producing as many offspring as possible then a heritable characteristic has affected the variation in reproductive success. Traits affecting reproductive success need not be detrimental, a mutation might arise that increases may fertility for example. In such a case the male would be expected to sire more offspring in the next generation, thus there will be an increased proportion of the population with that mutation. Therefore the answer to this fifth and final question is also yes.

These five points are nothing pioneering or controversial, they just simply support the definition of evolution by showing that heritable changes can occur in a population and as a result the population may become different over time. *Technically, excluding point five, we can still say that evolution can only be true. Combing the evidence from points one to four, shows that traits are transmitted from one generation to the next in such a way that could cause a change over time – this is via genetic drift. Point five simply invokes selection for adaptation as a mechanism of evolution.*

The discussion over the truth of evolution is largely fuelled by religious groups who see it as opposing their beliefs, but eventually I am sure that religions will come to accept the theory of evolution. In the face of growing evidence, just as when we realized that the earth was round and not at the centre of the universe, those religions will be forced to adapt, to evolve.

* This section has been added after initial publication

The inevitability of sexual antagonism.

A few days ago the first citation alert popped up on my paper I published this summer. It was my first citation on my first first-author paper… that’s a big first for me so I got a little excited. I was even more excited when I saw the paper that had referenced my paper. First of all it was by two excellent scientists, Tim Connallon and Andrew Clark both of Cornell, and the latter also being co-author of one of the most important textbooks in evolutionary genetics. I have also had the pleasure of meeting Andy Clark on a few occasions and can safely say he is not only one of the most respected in the field, but also one of the most modest and humble I’ve met.


This is the abstract from the paper:

“Sexual antagonism, whereby mutations are favourable in one sex and disfavourable in the other, is common in natural populations, yet the root causes of sexual antagonism are rarely considered in evolutionary theories of adaptation. Here, we explore the evolutionary consequences of sex-differential selection and genotype-by-sex interactions for adaptation in species with separate sexes. We show that sexual antagonism emerges naturally from sex differences in the direction of selection on phenotypes expressed by both sexes or from sex-by-genotype interactions affecting the expression of such phenotypes. Moreover, modest sex differences in selection or genotype-by-sex effects profoundly influence the long-term evolutionary trajectories of populations with separate sexes, as these conditions trigger the evolution of strong sexual antagonism as a by-product of adaptively driven evolutionary change. The theory demonstrates that sexual antagonism is an inescapable by-product of adaptation in species with separate sexes, whether or not selection favours evolutionary divergence between males and females.”

We often talk of selection acting on the phenotype and how sexually antagonistic selection arises when phenotypic optima differ. Sexual antagonism is a pleiotropic constraint which acts on genes because the genes are present and selected upon in two different environments – the male and female genomes. If selection favours two different phenotypes in either sex then selection on the phenoptype is sexually antagonistic because genetic changes that increase male fitness will decrease female fitness and vice versa. This is the classic way to think of and explain sexual antagonism, Connallon and Clark call this fitness landscape dimorphism. For example, males and females may differ in there optimum wing length in fruit flies.


We can show fitness landscape dimorphism, and therefore that sexually antagonistic selection is occurring, by measuring selection in both sexes, if the phenotypic optima differ, then there is sexually antagonistic selection. Or is there? That’s what the Connallon and Clark paper got me thinking about.

The authors describe a scenario where sexual antagonism occurs even with the same phenotypic optima. This involves the presence of genotype x environment interactions (GxE) – when one genotype produces different phenotypes in different environments. One example of this is the ability of rats to run mazes when raised in more or less stimulating environments. To explain this let’s imagine that we are looking at fruit flies, and males and females are both under stabilizing selection for wing length with and optimum of 2 mm. This is, in this imaginary scenario, affected by a single locus with two alleles W and w. The gene has an interaction with the gender which causes the males to have larger wings than females of the same genotype. Let’s say WW males = 3 mm, Ww = 2.5 mm, and ww = 2 mm, and WW females = 2 mm, Ww, = 1.5 mm, and ww = 1 mm. In this way there is equal phenotypic optima but the selection on genotype is antagonistic illustrated below. From this illustration it is clear that both the W and w alleles would be maintained at equilibrium in the population and the average of both sexes would be suboptimal.


This is a way I had not thought about sexual antagonism arising before. Further it also highlights an issue with the previous description of sexually antagonistic selection on the phenotype, SA selection between the sexes does not automatically indicate conflict, it may be that GxE interactions have actually negated the conflict caused by SA selection. If males and females have different optima and the same gene produces the optimal phenotype for both by GxE interaction then there is no sexual antagonism. Following from the above example, the male optimum might be 3 mm and female optimum 2 mm, in this case there would be different phenotypic optima but equal genotypic optima and the W allele would be expected to go to fixation. Overcoming conflicts is essential for the adaptive evolution of sexual dimorphism, sex-specific regulation of the genome allows GxE interactions to occur and the sexes to fine tune the shared genome.

For me the message I am really taking from the Connallon and Clark paper is this: thanks to GxE interactions sexually antagonistic selection on the phenotype does not necessarily equate to SA selection on the genotype, but it also means SA selection can occur when there are identical adaptive landscapes between the sexes. Sexual antagonism can occur if the phenotypic optima differ or there are genotype x environment interactions, sexual antagonism will not occur only if mutation increases the fitness of both sexes.

The G-matrix.

It will surely not blow your mind if I start this post by telling you that our DNA affects what we look like. Our DNA contains genes which can influence all manner of our characteristics, or phenotypic traits – physiological, morphological, life history, and behavioural traits all included. Traits are often influenced by more than one gene and one gene often affects more than one trait. For example, genes that determine the length of your arms probably have some effect on the length of your legs and size of your feet, otherwise you would see a huge amount of people walking around on tiny legs dragging their long arms along the ground. This phenomenon, of genes affecting many traits, is called pleiotropy and causes correlations between traits (people with long arms tend to have long legs) and I will return to this shortly.

One of the major mechanisms of evolution is selection which acts upon phenotypic traits and causes changes in the genome if genotype is correlated to phenotype (i.e. the trait selected is somewhat genetically determined). The trait value which selection favours most will depend on its environment, it’s why lions who hunt in the savannah are yellow-brown and  tigers who hunt in the forests are striped – they are the better camouflage systems in their respective environments. It is not by too great an extension then that we can think of the sexes as two different environments a gene can find itself in. For genes, at least the vast majority of genes, there is an equal chance they will be passed to offspring of the same sex as the parent as there is of going to the same sex. If a gene affects a trait, for illustration the blueness of feathers, in both sexes but the phenotypic fitness optima differ between the sexes (females are fittest when brown, males fittest when bright blue) then sexually antagonistic selection is causing an intralocus conflict over the optimisation of that gene will occur.


In this case, alleles producing brown feathers will maximise female fitness, and alleles producing blue feathers will maximise male fitness. It then is clear that a conflict is going to occur and can only be overcome if the sexes are able to develop sex-specific mechanisms affecting the blueness of feathers. When this does occur we will see sexual dimorphism, a feature of all sexually reproducing species, evolve. One mechanism allowing the resolution of conflict is sex specific gene-expression. Sticking with the blue feathers example we can assume that the gene under conflict produces blue colour and increasing its expression increases the amount of blueness. If a sex-specific promoter becomes associated with that gene the correlation between the sexes is reduced and sex-specific phenotypes can be produced. Negative correlations have been found between sexual dimorphism and intersexual genetic correlation, a measure of how independent the sexes are (see Bonduriansky & Rowe 2005, Poissant et al 2010, and Griffin et al 2013 [shameless self citation]).

I have now introduced the principles of sexual dimorphism, sexually antagonistic selection, intralocus conflict, genetic constraint, and pleiotropy. The next step is to combine them. Russell Lande introduced the G-matrix to the world of evolutionary biology in 1980. It forms one element of the multivariate breeders equation which I will come to in a future post. Put simply the G-matrix is composed of the genetic variance and covariance of traits. When two traits are not affected by the same (or highly linked) genes the covariance should be low or none. When both trait A and trait B are both heavily determined by a single gene the covariance between them will be high. Similarly, if the male trait A is separately determined from the female trait A value then the covariance will be low or none, and, when male and female trait values are determined by the same genetic architecture then the covariance will be high.


Further, the G-matrix can be broken in to four submatrices. The upper left in this matrix is called the Gm-submatrix, the genetic variance-covariance matrix for males in the measured traits, and the lower right submatrix is the female equivalent, the Gf-submatrix. These indicate how correlated the response to selection will be between the traits within the sexes. The two remaining submatrices are the B- (and B transposed) matrices. These show the genetic covariance between the sexes. Combined with estimates of sex-specific selection gradients, these B-matrices will give indications of the constraint imposed by a shared genetic architecture when selection differs between the sexes.


For now this gives you an idea of what the G-matrix is and my work which will begin to use the G-matrix soon. It also begins to touch upon the multivariate breeders equation, I’ll do another post about that in the future. Good reading on this subject would include Lande 1980, Arnold et al 2008, Steppan et al 2002, and the G-matrix homepage.

Learning by teaching.

PCR, polymerase chain reaction, is a process which is used to amplify DNA and is a staple of any biologists basic training at undergraduate (and masters level). Some people even get to do them in high school. I have devoted the last six years of my education solely to biology, collected a bachelors degree in Conservation Ecology, a masters in Evolutionary Biology, and I’m half way through a PhD in Evolutionary Genetics. You might then be surprised to read that, until just recently, I had no idea of how to do a PCR. Even going back a just one week putting me in the lab and asking for a PCR would have probably lead to my cataclysmic nervous breakdown with extensive therapy being required for any witnesses.

This week I am a changed man. Now I can do a PCR (and the accompanying gel electrophoresis) quite fluently and entirely from memory. What’s changed? What happened to me in those five days? Believe it or not, I taught a class of ~25 undergraduate and masters students how to use PCR to identify the sex of birds from extracted DNA. Three full days of teaching, the blind leading the blind. Fortunately I was not on my own, I had the guidance of another PhD student who did know well enough what to do. Unfortunately the course materials were not as helpful. If you gave that lab manual to a random person, even an intelligent person, they would not have been able to make any sense of it and would not even come close to beginning a PCR, let alone getting a result.

After a chaotic first couple of hours in the lab, things eventually settled down as the students got a clearer understanding of what to do. As the day progressed I grew more comfortable and confident in my ability to help. One of the 12 groups even finished, successfully sexing all 6 samples of DNA on their first attempt. By the time I went to bed that Friday evening I had spent nearly 9 hours teaching, an hour in the fly lab, had my dinner, and then written a full set of step-by-step PCR and gel electrophoresis instructions. After a weekend of rest to recover I was back in the teaching lab on Monday morning. The pandemonium of Friday had given way to a Monday characterized by harmony and peace, the students had obviously also spent some time digesting just what had happened on the previous Friday. The day passed much more smoothly and by the close of play a further three groups had successfully identified the gender of their samples.

By the third and final day the class had been whittled down to just 16 struggling students already sick of the sight of a thermocycler and growing rapidly disillusioned with science. Cue my step-by-step instructions, by now almost polished in to the finished article. I started distributing these among some of the groups and, a few hours later, the class had all finished (completed the exercise or established that their primers didn’t work). I even used the instructions myself to do my first ever solo effort at a PCR; there has been just three attempts before all of which were heavily supervised, a long time ago, and wholly unsuccessful. I followed the instructions I had made just a few nights before to the letter and produced a PCR which successfully identified the sex of all six samples (the picture is not great, but on the camera screen the results were all clear). To get to my step-by-step guide go to this Biology Stack Exchange post.


So that’s how I learned to do a PCR. Learning by teaching. I was forced to learn by being thrown in at the deep end. My supervisor was the course leader, and, when he signed me up as an instructor he knew that he was picking someone who was utterly clueless. I can see that there are pro’s and con’s of doing this but ultimately I think everyone involved has genuinely benefited. Personally speaking it was uncomfortable and embarrassing not to be able to help students when, in the early stages of the lab, I could not answer their questions. This initially left me feeling demoralized, and my students feeling lost, let down by the university, and resigning themselves to failure. But then it can also be a positive. I used it to motivate myself in to making amends for my being useless. Using my inexperienced perspective of PCR I have made instructions and have prepared a massive overhaul of the course for next year that beginners can understand, made sure I helped this years class learn PCR properly, and in the end I think every member of that class can now successfully do a PCR (though not all did so in the practical – sometimes primers just don’t work). I’ve spent time discussing the weaknesses of the course with the current crop of students and some have agreed to help me design the new version, even offering up time to do a dummy run of the course. So has everyone involved benefited? Well I’ve learned how to do a PCR. This years students have (eventually) all learned how to do one. And next years students will hopefully be on the receiving end of a much more engaging, intuitive, and effective course. Learning by teaching can work for everyone involved, it just requires perseverance and motivation.

Self-teaching the matrix (Part I).

As I try to get myself more comfortable with quantitative genetic theory it is about right that I (re-)learn about matrices and blow the dust of the mathematical part of my brain. I have definitely neglected my mathematical abilities since finishing the compulsory maths high school education aged 16. I was good at math in school until some fairly uninspiring years towards the end, it’s probably the reason I have ignored it, but now I’m going to fix that.

What got me thinking about matrices? G and B matrices have been around in evolutionary biology for a while now, but they are coming up in the literature far more often now as computational packages and statistical education improve. Reading Russell Lande’s 1980 paper (Sexual dimorphism, sexual selection and adaptation in polygenic characters), in preparation for a journal club meeting, has made me determined to get a complete understanding of them so I’ve turned to the internet to get my math abilities up to scratch.

What is a matrix? A matrix is quite simply a 2 dimensional array of numbers, the dimensions are given as number of rows by the number of columns. For example…

matrix1are matrices of 3×3 and 3×2 (rows x columns) respectively. Using the matrices we can then introduce scalar multiplication, where the matrix is multiplied by a number. All that happens here is we multiply each matrix value by the scalar value, in this example that scalar is the number of 3…

matrix2The next process to cover is matrix addition. Just like scalar multiplication, this is a very simple and intuitive process. To add two matrices together you simply add the numbers in the matched position (I suggest thinking about the dimensions of the matrices as coordinates on a map). So with two equal dimension matrices, matrix A and matrix B, we add the number found in matrix A at position row 1 column 1 (A1,1) to the number at position B1,1 in matrix B, then number A1,2 to number B1,2, and so on. We do the same for every position in the matrix…

matrix3Matrix subtraction is exactly the same as addition but instead of adding we subtract (stating the obvious!). Using the example I gave for addition, but instead subtracting, the resulting matrix would be filled with the numbers -1, -1, -7, 3 (reading left to right, top row first). Simple.

But what happens in addition and subtraction when the matrices are not the same dimensions? The first two matrices I showed are not equal (3×3 and 3×2), how would we add those to each other? In this scenario we can’t add or subtract them, they are not definable, or undefined. We just can’t do it so we don’t do it.

Now that technicality is dealt with we can move on to transposed matrices. Transposed matrices are simply matrices which are switched around such that the rows become the columns and the columns become the rows. A transposed matrix is signified by a superscript T, for example matrix A when transposed is matrix AT (called “A transpose”)…


So that is part 1 of my re-entry in to matrices, I’ll post the next part soon. In making this post I used online material from khanacademy and purplemath which I really recommend you visit to try out their exercises and view the videos.

Wright-Fisher genetic drift simulation.

The Wright-Fisher model of genetic drift assumes a population of haploid individuals that reproduce asexually with discrete generations. Each generation contains the same number of individuals as the previous and the genotypes are also samled randomly from the previous generation.

Starting with two alleles in a population of 10 individuals we sample from the first generation (t) to make the next generation (t+1). To do this we pick one t individual at random to be our parent of one t+1 individual. We repeat this, returning the parent to the base population each time, until we have 10 offspring. On average, using many replicate populations, the next generation will be 50% allele 1 and 50% allele 2. However, some of the t generation may have been sampled more than once, and others not sampled at all. If, by chance, the allele 1 parents were sampled twice each then our next generation would all be allele 1 offspring. Allele 1 would have gone to fixation. This figure illustrates drift from the base population across 4 generations with 10 individuals and equal share of two alleles where one goes to fixation.

Drift illustrationFor more on the Wright-Fisher  model I recommend reading An Introduction to Population Genetics: Theory and Applications by Nielsen and Slatkin. The following R-script has been adapted and annotated from this site.

#### Wright-Fisher simulation of genetic drift ####
# n = number of individuals
# p = frequency of focal alleles at base population
# g = number of generations to sim
# r = number of replicate populations

# Libraries

# Variables
n = 1000
p = 0.2
g = 120
r = 1000

# replication array
# set dimensions of array to be g*r
gd = array(0, dim=c(g,r))

# set first line of array at n*f
gd[1,] = rep(n*p,r)

# loop for r replicates
for(j in 1:r){

# from line 2 of the array until final generation
for(i in 2:g){

# sample from the population with probability defined by the value in the previous generation
gd[i,j] = rbinom(1,n,prob=gd[i-1,j]/n)

# put it into a dataframe
gd = data.frame(gd/n)
gd2 <- melt(gd)
ggplot(gd2, aes(x = rep(c(1:g), r), y = value, colour = variable)) + geom_line() + opts(title = "") + xlab("Generations") + ylab("Focal Allele Frequency") + ylim(0,1) + labs(colour = "") + theme(legend.position="none")

# fixation proportion
gd$fixed = (apply(gd,1,sum)/r)

# proportion of focal allele in final generation