Drift vs DraftThe script drift_vs_draft.py (download here) illustrates how the dynamics of neutral alleles and neutral genealogies are affected by linked selection. To this end, the population is set up in linkage equilibrium with mostly neutral and a few strongly deleterious sites. These deleterious sites become beneficial one after the other and sweep through the population. This perturbes allele frequencies and causes rapid coalescence. As output, the script plots allele frequency trajectories and genealogies.
To implement this time dependent selection, the fitness effect of one random previously deleterious locus is set to a positive value at intervals of 200 generations.
Allele frequencies are recorded every 10 generations and a sample of the allele frequency trajectories looks like this:
# every 200 gen., make one of the deleterious mutations (at position m*[0..25]) beneficial if (sweeps and pop.generation % 200 == 0): selection_coefficients[m*np.random.randint(0,25)] = s # update fitness function pop.set_trait_additive(selection_coefficients)
The color indicates the position on the genome, selected trajectories are in shown as dashed lines, neutral ones by solid lines. Neutral allele frequencies are most strongly perturbed by sweeps nearby on the chromosome, i.e., of similar color.
We can also look at the genealogies at different neutral loci on these genomes.
These trees bear strong signatures of coalescence induced by linked selection: We see large bursts of coalescence next to long lineages that go all the way back for 2000 generations, which is the total time the population was simulated for. The effect of sweeps is best appreciated by comparing them to a simulation when the selective sweeps are switched off:
Without sweeps, many lineages continue 2000 generations into the past. This is expected, since the population size in these examples is 10000 and the common ancestor of the population would live roughly 20000 generation ago, i.e., long before the start of the simulation.