Hardy-Weinberg Calculator
Convert between allele and genotype frequencies, estimate carrier frequency from the frequency of a recessive trait, and test observed genotype counts for equilibrium.
The equation
For a gene with two alleles at frequencies p and q, where p + q = 1, random mating produces genotypes in the proportions p² : 2pq : q². The principle, worked out independently by G. H. Hardy and Wilhelm Weinberg in 1908, says these proportions stay constant from generation to generation as long as there is no selection, mutation, migration or genetic drift, and mating is random. It is the null model of population genetics: deviations from it point to one of those forces at work.
Carrier frequency from a recessive trait
The most common use is estimating how many people carry a recessive allele from how many show the trait. If 4% of a population shows a recessive phenotype, q² = 0.04, so q = 0.2 and p = 0.8. The heterozygote frequency is 2pq = 2 × 0.8 × 0.2 = 0.32, so 32% are carriers, eight carriers for every affected individual. For a rare condition affecting 1 in 2,500 births, q = 0.02 and 2pq = 3.92%, about 1 in 26 people are carriers, 98 carriers for every affected person. This is why rare recessive conditions persist: almost all copies of the allele sit in healthy heterozygotes, where selection cannot see them. A common misconception is that a recessive allele will disappear from a population over time simply because it is recessive; without selection, its frequency stays the same.
Testing observed counts
Given genotype counts, you can test whether a sample fits the equilibrium. In a sample of 1,000 with 298 AA, 489 Aa and 213 aa, the allele frequencies are p = (2 × 298 + 489) ÷ 2,000 = 0.5425 and q = 0.4575. The expected counts are 294.3, 496.4 and 209.3. The chi-square statistic, Σ (observed − expected)² ÷ expected, is 0.221 with 1 degree of freedom: three genotype classes, minus one for the total and one for the estimated allele frequency. The p-value is 0.638, well above 0.05, so the sample is consistent with equilibrium. An excess of homozygotes is the classic sign of inbreeding or of a sample that mixes two populations, and in genotyping studies a strong deviation often signals a laboratory error rather than biology.
Limits
The model assumes an infinitely large population, which small, isolated populations are not; drift can change allele frequencies quickly there. It applies to one locus at a time, and for genes on the X chromosome, males and females must be treated separately: the frequency of a recessive X-linked trait in males is q, not q².
How to use it
- Choose whether you are starting from a recessive phenotype frequency, an allele frequency or genotype counts.
- Enter the percentage of individuals with the trait, the frequency q, or the counts of each genotype.
- Read p, q and the genotype frequencies, including carriers.
- For counts, read the chi-square statistic and p-value for the equilibrium test.
Questions from the teaching lab
How do you calculate carrier frequency with Hardy-Weinberg?
Take the square root of the frequency of the recessive phenotype to get q, subtract from 1 to get p, and calculate 2pq. If 1 in 2,500 people are affected, q = 0.02, p = 0.98 and the carrier frequency is 2 × 0.98 × 0.02 = 3.92%, about 1 in 26.
What are the five assumptions of Hardy-Weinberg equilibrium?
No natural selection, no mutation, no migration or gene flow, a very large population so that genetic drift is negligible, and random mating. When any of these fails, genotype frequencies can change between generations or depart from p², 2pq and q².
How many degrees of freedom does a Hardy-Weinberg chi-square test have?
One, for a gene with two alleles. There are three genotype classes; one degree of freedom is lost because the counts must add up to the total and another because the allele frequency is estimated from the same data.
Why are most copies of a rare recessive allele in carriers?
Because when q is small, 2pq is much larger than q². For q = 0.02, carriers make up 3.92% of the population and affected individuals 0.04%, so carriers hold 98% of the copies of the allele.
Disclaimer: Genetics results apply textbook models, Mendelian ratios, Hardy-Weinberg equilibrium and simple Tm formulas, to the values you enter. They are for education and are not medical advice, genetic counselling or parentage testing. Real inheritance involves linkage, variants and family history these models leave out: anyone concerned about a condition, a pregnancy or a test result should speak to a doctor or genetic counsellor.