Skip to content

Population Genetics - Simulations with PopG


PopG is a one-locus, two-allele (A and a) genetic simulation program written in Java. PopG allows you to simulate evolving populations. You specify the parameters in the settings window. The output shows the allele frequencies over time (generations) for the different populations. The aim of the simulations is not to get it right, but to get a feel for the evolutionary forces. For this reason, think about the possible outcome before you run it.

The PopG website helps with the installation. There is also a short tutorial and a list of suggestions. Please also read the credits and respect the copyright.

Caution

Be careful not to open more than one parameter setting window at a time!

A - Random Genetic Drift

A1 - Get started

Try to understand the graphical output by running a first simulation using the default parameters.

To gain a better understanding and answer the following questions, run a few more simulations.

Repeat Simluation

You can use [Run]▸[Restart] to repeat the simulations. This is recommended as it will show you different outcomes of the same simulation. You will see how much variation you can expect.

Can you predict the result of the simulation? No, I can't, because genetic drift is a random process.
Over time, what happens to allele A? It either gets fixed or it gets lost.
What can this observation tell us about the genetic diversity of a population over time? The population loses alleles over time due to genetic drift.

A2 - Random Seed

Set the <Random number seed:> parameter to a number you like and run a few more simulations with the same seed number.

What has changed? The result of the simulation will not change as long as I use the same random number seed.

A3 - Random but not arbitrary

Exchange the <Random number seed> with your neighbour and run the simulation using their seed number.

What does the Seed parameter do and what might be the reason for using it? The results are the same for every simulation and for everyone using the same seed. Although the result of a simulation is random, we have made the simulation reproducible by setting a seed, not just for us, but for everyone with the same seed number.
If we use a seed, can we still consider the simulation to be random? Setting a seed in R does not affect randomness; in fact, it allows you to control and reproduce random processes, which can be very useful in various statistical and scientific applications.

A4 - Patterns

Increase the number of evolving populations from the default of 10 to 100. Run 5 simulations and record the number (or %) of populations in which allele A has become fixed (P(A)=1) or lost (P(A)=0).

  • fixed (f(A) = p = 1; f(a) = q = 0)
  • lost (f(A)= p = 0; f(a) = q = 1)
Sim Pop-Size fixed lost
#1 100 ? ?
#2 100 ? ?
#3 100 ? ?
#4 100 ? ?
#5 100 ? ?

Is it possible to make a general prediction as to the fate of the A allele? Difficult to say, it is. Allele frequencies fluctuate and A is fixed or lost in some populations.

A5 - Over time

Continue the last simulation for another 500 generations in steps of 100 generations (Run > Continue with 100). The x-axis shows the time (generation time) elapsed since the start of the simulation.

Gen Pop-Size fixed lost
100 100 ? ?
200 100 ? ?
300 100 ? ?
400 100 ? ?
500 100 ? ?

Do you see a general trend now? I think so. Over time, more and more of the A alleles are either lost or become fixed.

What can this observation tell us about the genetic diversity of a population over time? Random drift reduces allele diversity in populations over time.

A6 - Population size

Repeat the previous simulation but increase the initial population size to 500.

Gen Pop-Size fixed lost
100 500 ? ?
200 500 ? ?
300 500 ? ?
400 500 ? ?
500 500 ? ?

Can you see a difference between the previous simulations with a population size of 100? There is the same tendency for the population to lose alleles and become homozygous over time, but it takes longer (more generations). The size of the population affects the rate of allelic loss due to genetic drift. The larger the population, the slower the allelic loss.

A7 - Destiny

Run new simulations with the same parameters but increase the number of generations.

Gen Pop-Size fixed lost
1000 100 ? ?
1000 500 ? ?
5000 100 ? ?
5000 500 ? ?
10000 100 ? ?
10000 500 ? ?

How does population size affect allele frequencies over time? Over time, all populations lose genetic diversity through genetic drift alone. The speed of this genetic erosion depends on the size of the population.
⇒ The larger the population, the slower the effect of drift (allelic loss).

A8 - Probability of fixation

Run a few more simulations but use different initial allele frequencies (Feq(A)). Population size (Size), number of generations (N(Gen)) and number of individuals (N(Pop)) are kept constant.

Size Feq(A) N(Gen) N(Pop) fixed lost
100 0.10 1000 1000 ? ?
100 0.20 1000 1000 ? ?
100 0.30 1000 1000 ? ?
100 0.40 1000 1000 ? ?
100 0.50 1000 1000 ? ?
100 0.60 1000 1000 ? ?
100 0.70 1000 1000 ? ?
100 0.80 1000 1000 ? ?
100 0.90 1000 1000 ? ?
100 0.95 1000 1000 ? ?
100 0.99 1000 1000 ? ?

Can you predict the fate of genetic diversity? Yes, heterozygosity will decrease, alleles will be lost and diversity will decrease.

☞ Interesting observation: Frequency(A) -> % fixation rate -> 1-% loss rate

In Summary - What did you learn from the simulations above in terms of allele frequency changes and the predictability of genetic diversity within and between populations over time?

B - Mutation

Mutations are the source of all genetic variation. A single mutation can have a large effect, but in many cases evolutionary change is based on the accumulation of many mutations. In this simulation we assume that allele A mutates to a and back to a at different mutation rates.

A \xrightarrow[]{\mu_1} a
A \xleftarrow[]{\mu_2} a

B1 - Different mutation rates

Size N(Gen) N(Pop) \mu_1 \mu_2 f(AA) f(Aa) f(aa)
100 500 100 0.0001 0 ? ? ?
100 500 100 0.001 0 ? ? ?
100 500 100 0.01 0 ? ? ?
100 500 100 0.1 0 ? ? ?
100 500 100 0.01 0.01 ? ? ?

B2 - Mutation over time

Size N(Gen) N(Pop) \mu_1 \mu_2 f(AA) f(Aa) f(aa)
100 100 100 0 0 ? ? ?
100 100 100 0.001 0 ? ? ?
100 500 100 0.001 0 ? ? ?

B3 - Population size and mutation rate

Size N(Gen) N(Pop) \mu_1 \mu_2 f(AA) f(Aa) f(aa)
10 500 100 0.001 0 ? ? ?
100 500 100 0.001 0 ? ? ?
1000 500 100 0.001 0 ? ? ?

What is considered a high mutation rate? Observe the blue line (with no drift). As soon as it deviates from the horizontal line mutation has a measurable effect.
N=100 / time=1000 => m=1.0E-4

How does the mutation rate affect genetic diversity over time? Observe the blue line (with no drift). As soon as it deviates from the horizontal line mutation has a measurable effect.
If µ(A→a) = µ(A←a) nothing happen.
If µ(A→a) ≄ µ(A←a) directional influence.

What are the limitations of this simulation?
  • allele loss/fixation is directed if µ1 ≄ µ2
  • if µ1 = µ2 allele frequency stabilises at 0.5 independent of starting frequency
  • mutation does not create new alleles (not realistic)
  • C - Gene Flow / Migration

    Gene flow, also known as migration, is the movement of genetic material (genes) between different populations of the same species. It plays a crucial role in maintaining genetic diversity and can lead to evolutionary changes within a population over time.

    C1 - Different migration rates

    Size N(Gen) N(Pop) m f(AA) f(Aa) f(aa)
    100 500 100 0.0 ? ? ?
    100 500 100 0.01 ? ? ?
    100 500 100 0.001 ? ? ?

    C2 - Migration rate and population size

    Size N(Gen) N(Pop) m f(AA) f(Aa) f(aa)
    10 500 100 0.01 ? ? ?
    100 500 100 0.01 ? ? ?
    1000 500 100 0.01 ? ? ?

    C3 - Migration and mutation rate

    Size N(Gen) N(Pop) m \mu_1 f(AA) f(Aa) f(aa)
    100 500 100 0.01 0.001 ? ? ?
    100 500 100 0.05 0.001 ? ? ?
    100 500 100 0.10 0.001 ? ? ?
    Describe the effect of migration on the genotype frequency.
    m=0.01 reduces alleles loss/fixation m=0.1 prevents allele loss/fixation at initial frequency

    Describe the interaction between migration rate, genetic drift and mutation rate.
    µ(A-a):0.001; µ(a-A):0.0; m:0.1 → 0.1% mutation in enough to make it directional
    µ(A-a):0.01; µ(a-A):0.01; m:0.1 → With equal forward and reverse mutation rates the allele frequency will stabilise at 50% regardless of the initial frequency

    What factors can influence the migration rate? Migration model - PopG allows individuals to migrate between replicate populations at a constant rate. It is difficult for an allele to become dominant. More common alleles have a high rate of migration.

    D - Selection / Fitness

    Natural selection is the differential success of genotypes in contributing to the next generation. The effect of natural selection on genotypes is measured by fitness.

    • w: relative fitness (w=1-s)
    • s: selection coefficient (s=1-w)
    • f(xx): genotype frequency

    Before you start a simulation, think about the possible outcomes!

    w(AA) w(Aa) w(aa) s f(AA) f(Aa) f(aa) Fitness
    1 1 1 - ? ? ? neutral
    1 1 0 - ? ? ? complete dominance
    1 0 1 - ? ? ? complete underdominance
    0 1 0 - ? ? ? complete overdominance
    1 1 1-s 0.01 ? ? ? recessive
    1 1 1-s 0.1 ? ? ? recessive
    1 1-s/2 1-s 0.1 ? ? ? additive
    1-s 1 1-s 0.05 ? ? ? overdominance
    1-s 1 1-s 0.1 ? ? ? overdominance
    1+s 1 1+s 0.05 ? ? ? underdominance
    1+s 1 1+s 0.1 ? ? ? underdominance

    How does fitness affect diversity within and between populations? The fitness is directional if homozygotes have a higher fitness rate:
    If both homozygotes have higher (and equal) fitness (homozygote advantage / heterozygote disadvantage) the fixation and loss rate is ~ 50:50.
    In order to reduce/prevent allelic losses, the fitness advantage of the heterozygote must be >5%.

    How much fitness does a population need to overcome genetic drift? An increase of 0.1% in fitness for AA will result in a visible change, but it may not lead to a higher rate of fixation.

    E - Simulations Explained

    Find the setting used for the following simulations. Set the population size, number of generations, and number of population to 100.

    E1 - Keep them both

    E2 - Swift shift

    E3 - We all go down

    E4 - Back to the centre

    E5 - You will not get rid of me

    Possible Solutions for E
    TEST