Simulation lab
Antibiotic Resistance Evolution Lab
Antibiotics do not create resistant bacteria; they select them. Imagine a bacterial population where a rare allele R confers resistance to a widely used antibiotic. While the drug is present, R carriers survive treatment and sensitive cells die, so R is strongly favored. When the drug is removed, maintaining the resistance machinery often costs energy, so R carriers are slightly less fit than sensitive cells. Use the fitness sliders to model both eras and watch the resistance allele sweep, then slowly fade.
Natural Selection Simulator
Watch allele frequencies change under selection, generation by generation.
Fitness = relative reproductive success (1.0 = baseline). Try w_aa = 0 to model a lethal recessive allele.
Generation-by-generation table
| Gen | p | q | w̄ (mean fitness) |
|---|---|---|---|
| 0 | 0.1000 | 0.9000 | — |
| 6 | 0.4381 | 0.5619 | 0.7954 |
| 12 | 0.7380 | 0.2620 | 0.9226 |
| 18 | 0.8759 | 0.1241 | 0.9681 |
| 24 | 0.9383 | 0.0617 | 0.9852 |
| 30 | 0.9683 | 0.0317 | 0.9927 |
| 36 | 0.9835 | 0.0165 | 0.9963 |
| 42 | 0.9913 | 0.0087 | 0.9980 |
| 48 | 0.9954 | 0.0046 | 0.9990 |
| 54 | 0.9976 | 0.0024 | 0.9995 |
| 60 | 0.9987 | 0.0013 | 0.9997 |
Each generation: p′ = (p²·wAA + pq·wAa) / w̄, where w̄ = p²·wAA + 2pq·wAa + q²·waais mean fitness. This is a deterministic model — it ignores genetic drift, mutation and migration, so real small populations will bounce around these curves.
How to use it
Set p0 to 0.02 so the resistance allele starts rare, and model treatment with wRR = 1.0, wRr = 1.0, wrr = 0.3 over 100 generations.
Watch the R allele sweep toward fixation and record the generation the readout reports it fixed.
Now withdraw the antibiotic: set wRR = 0.95, wRr = 0.95, wrr = 1.0 (the cost of resistance) and observe the slow decline.
Compare sweep speed under strong selection (wrr = 0.3) versus weak selection (wrr = 0.9) to see how selection strength sets the pace.
Check the mean-fitness column: it climbs during treatment, showing the population adapting to the drug.
Bacteria are haploid and frequently share genes by horizontal transfer, so this diploid two-allele model is a teaching approximation, not a microbiological one. The panel has no mutation creating new resistance alleles, no plasmid transfer between cells, and no migration between treated and untreated populations. The fitness-cost values are illustrative, and real selection in hospitals is complicated by dosing schedules and mixed infections.
What you will learn
- Explain why antibiotics select for pre-existing resistance alleles rather than creating them.
- Contrast selection on the resistance allele with and without drug pressure.
- Explain the fitness cost of resistance and why resistant strains can decline when treatment stops.
- Relate the strength of selection to the speed of an allele sweep.