Allele Frequency Calculator

Compute allele frequencies (p, q), genotype frequencies, test for Hardy‑Weinberg equilibrium (HWE) using chi‑square, and visualize observed vs. expected distributions.

Example populations:
Classic HWE (AA=45, Aa=38, aa=17)
HWE perfect (1:2:1 ratio)
Deviation (AA excess)
Recessive excess (aa high)
Fixed recessive population
Privacy first: All calculations run locally in your browser. No data leaves your device.
Verified for accuracy – This tool uses the correct chi‑square p‑value calculation (erfc approximation) and follows population genetics standards. Reviewed by the GetZenQuery Tech team, April 2026. Algorithm based on Weir, B.S. (1996) "Genetic Data Analysis II".

Understanding Allele Frequency & Hardy‑Weinberg Equilibrium

The allele frequency (or gene frequency) is the relative proportion of a particular allele among all allele copies in a population. For a biallelic locus with alleles A and a, the frequencies are denoted p (frequency of A) and q (frequency of a), with p + q = 1. The Hardy‑Weinberg principle states that under ideal conditions (random mating, no mutation, no selection, large population size, no migration), genotype frequencies remain constant and follow: p² (AA) + 2pq (Aa) + q² (aa) = 1. Deviation from HWE indicates evolutionary forces at play.

Allele frequency calculation:
p = (2 × count(AA) + count(Aa)) / (2 × total individuals)
q = (2 × count(aa) + count(Aa)) / (2 × total individuals) = 1 − p

Expected genotype counts under HWE:
E(AA) = p² × N, E(Aa) = 2pq × N, E(aa) = q² × N
Chi‑square test (df=1): χ² = Σ (O−E)²/E, p‑value = 1 - CDF(χ², df=1) where CDF is the cumulative distribution function of chi‑square distribution. This implementation uses the complementary error function approximation (Abramowitz & Stegun) for high precision.

How to interpret results?

  • p > 0.5 : Dominant allele A is more common.
  • Significant χ² (p < 0.05) : Population deviates from HWE → potential inbreeding, selection, population stratification, or genotyping error.
  • Non‑significant χ² (p ≥ 0.05) : No evidence of deviation; population may be in equilibrium (or forces are balanced).

Real‑world applications

Population geneticists use allele frequency calculators to monitor genetic diversity in endangered species, detect natural selection signatures, assess forensic DNA evidence, and understand disease allele distributions (e.g., CFTR mutations in cystic fibrosis). Conservation biologists track loss of rare alleles over time. In agriculture, HWE tests validate breeding populations and detect unintended selection.

Case study: Sickle‑cell allele in malaria‑endemic region

In a West African population, observed genotype counts: AA = 340, Aa = 180, aa = 30 (total 550). p = (2*340+180)/1100 = 0.782, q = 0.218. Expected under HWE: AA = p²*550 = 336, Aa = 2pq*550 = 187, aa = q²*550 = 26. χ² = 0.05+0.26+0.62 ≈ 0.93, p=0.33 → not significant, indicating HWE holds, consistent with random mating despite heterozygote advantage (balancing selection may be counterbalanced by other factors). This tool replicates such analyses.

Limitations & assumptions

  • The calculator assumes a biallelic locus (two alleles). For multiallelic systems, extended methods are required.
  • Small sample sizes (N < 20) or any expected genotype count < 5 may lead to inaccurate chi‑square approximation. In such cases, the tool displays a warning; Fisher's exact test is recommended for very small populations.
  • HWE test requires independence of observations and random sampling.
  • This tool is designed for diploid organisms. For polyploids, allele frequency calculations require dosage adjustments.

Frequently Asked Questions

A p‑value less than 0.05 suggests the population is not in Hardy‑Weinberg equilibrium. Possible causes: non‑random mating, selection, genetic drift, population admixture, or genotyping errors.

This tool is designed for diploid species. For polyploids, allele frequency calculations require different formulas (e.g., using dosage).

Deviations may arise from selection, inbreeding (excess homozygotes), outbreeding (excess heterozygotes), or chance in small populations. The chi‑square test quantifies this deviation.

A rule of thumb: expected counts >5 for each genotype. If any expected count <5, the chi‑square approximation may be inaccurate; consider Fisher's exact test. The tool will display a warning in such cases.
References & authoritative sources:
Hartl & Clark (2007). "Principles of Population Genetics". Sinauer Associates.
Weir, B.S. (1996). "Genetic Data Analysis II". Sinauer Associates.
NCBI Genetics & Population Genetics
This tool follows guidelines from the American Society of Human Genetics (ASHG) and the International HapMap Project. Last algorithmic validation: April 2026.