Understanding the allele frequency calculator — concept and principle
Allele frequency is the share of all gene copies in a population that carry a particular variant. This calculator counts alleles directly from the numbers of each genotype for a gene with up to three alleles, and compares observed and expected heterozygosity.
How it is calculated
- N individuals carry 2N allele copies (diploid organisms).
- Gene counting: p = (2·N11 + N12 + N13) ÷ 2N; likewise q for A2 and r for A3; p + q + r = 1.
- Observed heterozygosity Ho = heterozygous individuals ÷ N.
- Expected heterozygosity under random mating He = 1 − (p² + q² + r²).
The principle
Each homozygote carries two copies of the same allele and each heterozygote carries one copy of each of its two alleles. Adding up copies and dividing by the total gives each allele's frequency exactly, as long as every genotype can be told apart (codominant markers or DNA genotyping). Under Hardy–Weinberg proportions, the chance that an individual inherits two different alleles is 1 minus the chance of two identical ones, which gives He. A large shortfall of observed heterozygotes can indicate inbreeding or population structure.
Worked example
Default inputs: A1A1 45, A2A2 10, A3A3 5, A1A2 30, A1A3 20, A2A3 10.
- N = 120 individuals; 2N = 240 allele copies.
- p = (2 × 45 + 30 + 20) ÷ 240 = 140 ÷ 240 ≈ 0.5833.
- q = (2 × 10 + 30 + 10) ÷ 240 = 60 ÷ 240 = 0.25; r = (2 × 5 + 20 + 10) ÷ 240 = 40 ÷ 240 ≈ 0.1667.
- Observed heterozygosity = (30 + 20 + 10) ÷ 120 = 0.5.
- Expected heterozygosity = 1 − (0.3403 + 0.0625 + 0.0278) ≈ 0.5694.
| A₁A₃ individuals | Frequency of A₁ (p) |
|---|---|
| 5 | 0.5952 |
| 10 | 0.5909 |
| 15 | 0.587 |
| 20 | 0.5833 |
| 25 | 0.58 |
| 30 | 0.5769 |
| 40 | 0.5714 |
How to read the result
Here Ho (0.50) is somewhat below He (0.57). Whether that difference is meaningful needs a statistical test, because sampling alone produces deviations. Allele frequencies track how populations change through selection, drift, migration and mutation.
Common mistakes
- Counting individuals instead of allele copies.
- Using the square-root shortcut (q = √frequency of recessive phenotype) when genotypes can be counted directly.
- Forgetting that the frequencies must sum to 1.
- Interpreting a small heterozygote shortfall without a significance test.
Frequently asked questions
How do you calculate allele frequency?
Count the copies of the allele (two per homozygote, one per heterozygote) and divide by twice the number of individuals.
What is expected heterozygosity?
The share of heterozygotes predicted under random mating: 1 − Σ pi².
What does low observed heterozygosity mean?
It can point to inbreeding, population subdivision or genotyping errors; a formal test is needed.
Sources: Hartl, D. L. & Clark, A. G., Principles of Population Genetics, 4th ed. Sinauer · Nei, M. (1973). Analysis of Gene Diversity in Subdivided Populations. PNAS, 70(12).