How to use the hardy-weinberg calculator
- Count the individuals in your sample with each genotype and enter them as AA, Aa and aa. A is one allele of a gene and a is the other.
- Read the allele frequencies p (for A) and q (for a), then the expected counts for each genotype if the population is in equilibrium.
- Check the chi-square value and its p-value with 1 degree of freedom. A small p-value is evidence that the population is not in Hardy-Weinberg proportions.
- The inbreeding coefficient F compares the heterozygotes you saw with the number expected: positive means fewer than expected.
Formula
p = (2 AA + Aa) / (2 N) q = 1 - p
expected counts: AA = p^2 N, Aa = 2 p q N, aa = q^2 N
chi-square = sum of (observed - expected)^2 / expected, with 1 degree of freedom
F = 1 - (observed Aa) / (expected Aa)
The Hardy-Weinberg principle says that, with random mating and no selection, migration or mutation, allele frequencies stay the same and genotype frequencies settle at p squared, 2pq and q squared. The p-value is the upper tail of the chi-square distribution with one degree of freedom.
A blood group sample of 1,000 people
A classic data set has 298 people with genotype MM (AA here), 489 with MN (Aa) and 213 with NN (aa). The allele frequency p is (2 x 298 + 489) / 2000 = 0.5425, so q is 0.4575. The expected counts are 294.31, 496.39 and 209.31. The chi-square is 0.2215 with a p-value of 0.6379, so there is no sign of departure from equilibrium. F is 0.0149.
Contrast a sample of 10 AA, 2 Aa and 38 aa. Here p is 0.22, only 2 heterozygotes are seen against 17.16 expected, the chi-square is 39.02 and the p-value is about 0.0000000004, with F = 0.8834. That pattern, a shortage of heterozygotes, can come from inbreeding, a mixed population or a genotyping problem.
What the test can and cannot say
A large p-value means the data are consistent with equilibrium; it does not prove it, especially in a small sample. A small p-value shows the genotypes depart from the expected proportions but not why. The usual suspects are non-random mating, population mixing, selection, genotyping errors and a sample drawn from related individuals.
The chi-square approximation is poor when an expected count is below 5, and the page warns you. For rare alleles in small samples an exact test is the better choice.
Using it with other tools
To predict the offspring of a particular cross, use the Punnett Square Generator. For other tests of counts against expectations, the Chi-Square Calculator handles tables and goodness of fit, and the Odds Ratio and Relative Risk Calculator compares two groups.
More genetics tools
For crosses and sequences, try the Punnett Square Generator and DNA Sequence Toolkit.
Assumptions and limits
- The gene has two alleles, and each person in the sample has exactly one genotype.
- Mating is random and there is no selection, migration or mutation in the population being modeled.
- The sample is random and the people in it are not close relatives.
- Counts are whole numbers of individuals, and the chi-square needs expected counts of about 5 or more.
- The example counts are an illustration. Replace them with your own.
Frequently asked questions
Why is there only one degree of freedom?
There are three genotype counts, which are fixed by the total, so two are free. Estimating the allele frequency from the data uses up one more, leaving one degree of freedom.
What if the p-value is exactly 0.05?
That depends on the rule you chose before looking at the data. This page only reports the figure and does not label the result.
What does it mean if only one allele is present?
Then every individual is the same genotype and nothing varies, so there is nothing to test. The page says the test does not apply.
Can I use this for a sex-linked gene?
No. The formulas are for a gene on an autosome. Genes on sex chromosomes have different expected proportions in males and females.