Tajima's D Calculator
Calculate Tajima's D to test for departures from neutral evolution in population genetics.
Two Estimates of the Same Quantity
Tajima's D compares two ways of estimating genetic diversity that should agree under neutrality but diverge under selection or demographic change.
| Estimator | Based on | Sensitive to |
|---|---|---|
| π (pairwise) | Average differences between sequence pairs | Intermediate-frequency variants |
| θW (Watterson) | Number of segregating sites | All variants equally, including rare ones |
The difference in sensitivity is the whole mechanism. Because θW counts every polymorphic site regardless of frequency, an excess of rare variants inflates it relative to π, driving D negative. An excess of intermediate-frequency variants does the opposite.
| D value | Pattern | Selection cause | Demographic cause |
|---|---|---|---|
| D < 0 | Excess rare variants | Purifying selection, selective sweep | Population expansion |
| D ≈ 0 | Neutral expectation | — | Constant size |
| D > 0 | Excess intermediate variants | Balancing selection | Bottleneck, structure |
The Confounding Problem
Notice that each D value has both a selective and a demographic explanation, and the statistic cannot distinguish them from a single locus. A sweep and a population expansion both produce negative D.
The standard resolution is to compare many loci. Demographic history affects the entire genome equally, so a genome-wide negative D suggests expansion. Selection acts locally, so a single locus with strongly negative D against a neutral genomic background suggests a sweep. This is why modern scans report D relative to an empirical genome-wide distribution rather than against zero.
Values beyond roughly ±2 are conventionally treated as significant, though the actual null distribution depends on sample size and recombination rate.
Worked Examples
Common Mistakes
Selection and demography produce identical signatures. Distinguishing them requires comparing many loci across the genome.
Population expansion produces genome-wide negative D. Only a locus that stands out against the genomic background suggests a sweep.
The null distribution depends on sample size and recombination. Empirical genome-wide distributions are more reliable than the nominal ±2 threshold.
Low-recombination regions show wider variance in D, so apparent outliers there may be statistical artefacts rather than selection.