# Essence of Nature in code

Every cell of a body contains two copies of DNA.If a cell contains the only single copy of DNA, then it is called the haploid cell. DNA encodes the complete architecture of human body. Gene is a particular piece of DNA that can have a specific functionality or feature associated with it.

Each gene will have a slightly modified version of itself called alleles. Genotypes are the list of all dual combinations that can be formed by particular gene alleles.

Now think of a particular gene A in the population with alleles A1 and A2 distributed in the population with a probability of 0.6 and 0.4. Now probability of finding a genotype with

A1A1 duo is P(A1,A1) = 0.6*0.6=0.36

P(A2,A2)=0.4*0.4=0.16

P(A1,A2)=1-0.16-0.36=0.48
In the next generation,

P(A1)=0.6 and

P(A2)=0.4

.. These probability distributions of alleles and genotypes persist for generation after generation under the assumption of the infinite population size. This is the model of zero evolution or called as a state of Hardy-Weinberg principle.

Assumptions of Hardy-Weinberg principle:

1. Population size is infinite and generations don’t overlap.
2. Mating is completely random.
3. Reproduction is sexual but there are no males and females.

Once we have established the Hardy-Weinberg principle as a platform to model evolution, we need to discuss four major forces that drive the evolution.

1. Genetic Drift – Finite Population Size.
2. Mutation.
3. Migration.
4. Natural Selection.

Finite Population Size:

Why is it that under the assumption of infinite population size that probabilities persist?

Think of a square of area 1. Divide the area of the square into two parts which are proportional to the allele frequencies. Now consider dropping points into that area randomly. If a number of points dropped approaches infinity, then a probability of finding a point in the area of the first allele will approach the original probability of finding the first allele. As the number of points decreases, the probabilities deviate from its original values(Read about Monte Carlo simulation). Thus withdrawing the assumption of infinite population results in a drift of allele frequencies in the population. This phenomenon eventually results in genetic drift. Because of randomness associated with occupancies of next generation alleles, this simulation is stochastic in nature.

Before going any further, let’s get into the informal definition of two terms.

Genetic Drift(G): Probability of picking two alleles of the same type from any particular generation.

Genetic Variation(H): Probability of picking two alleles of the different type from any particular generation.

Consider a population of N persisting for every generation for simplicity. This implies we have 2*N alleles in the population.

G=Probability of picking the same allele two times + Probability of picking two different alleles of the same type.

G1(next generation)=(1/(2*N))+(1-(1/(2*N)))*G

H1=1-G1

From the above formula, you can identify that as N increases and approaches infinity, G remains same for next generation. Smaller the value of N, more drifts you can expect of value G.

This means for lesser population, it takes fewer generations to extricate a particular allele from the gene pool and the converse is true.

In reality, Alleles can have more than two variations though we have assumed them to be of only two here for simplicity and pedagogical benefit.

Mutation:

Consider the scenario where a new allele has been formed in the gene pool because of a mistake. In this scenario, the relative population of this allele with respect to rest of the alleles determines the probability of this allele going to fixation. Fixation is the term used to convey the idea that eventually an allele outcompetes all the remaining alleles in the population.

Migration:

In the Hardy-Weinberg principle, we pick the next generation alleles randomly from the gene pool of the previous generation. When we consider and limit the selection of next generation allele based on the surrounding parent alleles, the effect of inbreeding i.e reduction in heterozygosity increases. Why is that?

Natural Selection:

Up to now, we have been simulating the stochastics of evolution without considering the advantage or disadvantage an allele would have in the gene pool for its character traits. The probabilities of picking an allele for next generation depended on only the relative frequency or population of that allele in the previous generation. The element of fitness of a particular allele in its environment is completely ignored. When this fitness element is considered, it will have a dramatic impact on particular allele going to fixation or extinction based on its fitness value. The effect is so dramatic that many people think Natural selection synonymous to Evolution.

Co-evolution:

Here we need to relax one more assumption of single species in the population. In reality, it is often the case that population of one species is negatively or positively dependent on the population of predators or prey species related to that. Suppose there are two alleles of same species, one resulting in the characteristic of high visibility by the predator and other having the low visibility. Then the fitness of two alleles is modified based on the population of predator alleles that identify. Conversely, the population of predator alleles depend on the population of visible prey alleles. This negatively interdependent nature of species result in a stable system of evolution called Co-evolution as long as one of the species doesn’t go extinct.

Epidemics:

SIR Model:

Small world Network: