Allele Frequency Calculator

Find allele frequencies p and q from genotype counts, then compare observed genotype frequencies against Hardy-Weinberg equilibrium expectations.

🧬 Allele Frequency Calculator
AA genotype count (homozygous dominant)
individuals
Aa genotype count (heterozygous)
individuals
aa genotype count (homozygous recessive)
individuals
Allele frequency p (A)
—
Allele frequency q (a)
—
Chi-square (χ²)
—
HWE verdict
—
Step-by-step working

🧬 What is the Allele Frequency Calculator?

The allele frequency calculator finds the frequency of each allele at a genetic locus, p and q, from observed genotype counts (AA, Aa, aa), then compares your population's actual genotype frequencies against what the Hardy-Weinberg principle predicts if the population were in equilibrium. The Hardy-Weinberg principle is the foundational null model of population genetics, describing how allele and genotype frequencies stay constant across generations under a specific set of idealized assumptions.

This calculator is used across many contexts. Genetics students use it to practice the core p and q allele-frequency formula and to build intuition for how p², 2pq, and q² relate to p and q. Population geneticists and evolutionary biologists use Hardy-Weinberg comparisons as a first diagnostic check for selection, non-random mating, or population substructure at a locus. Clinical and forensic genetics applications use allele frequency estimates from Hardy-Weinberg-consistent populations to calculate genotype probabilities.

A common misconception is that any deviation from Hardy-Weinberg expected frequencies proves natural selection is acting on a locus. It does not, deviations can also arise from small sample sizes, non-random mating such as inbreeding, genotyping error, or pooling together subpopulations with different allele frequencies (the Wahlund effect). A formal chi-square goodness-of-fit test, not just eyeballing the numbers, is needed to say whether an observed deviation is statistically meaningful.

This calculator is useful because it computes allele frequencies, Hardy-Weinberg expected genotype frequencies, and a proper chi-square test all in one step, then shows the observed and expected frequencies side by side as bar comparisons so deviations are easy to see at a glance.

📐 Formula

p  =  (2 × nAA + nAa) ÷ (2 × n),    q  =  1 − p
nAA, nAa, naa = observed genotype counts, n = total individuals
Hardy-Weinberg expected genotype frequencies: p² + 2pq + q² = 1
Chi-square goodness of fit: χ² = Σ(O − E)² ÷ E, compared against 3.841 (df=1, α=0.05)
Example: 320 AA, 160 Aa, 20 aa (n=500) gives p = (640+160)/1000 = 0.8, q = 0.2, expected AA = 0.64, Aa = 0.32, aa = 0.04, an exact match to the observed frequencies.

📖 How to Use This Calculator

Steps

1
Enter genotype counts. Type the number of individuals with each genotype: AA (homozygous dominant), Aa (heterozygous), and aa (homozygous recessive).
2
Read allele frequencies. See the calculated frequency of each allele, p for A and q for a, which always sum to 1.
3
Compare observed vs expected genotype frequencies. See whether your population's genotype frequencies match Hardy-Weinberg expectations, backed by a chi-square goodness-of-fit test.

💡 Example Calculations

Example 1 — A Population in Hardy-Weinberg Equilibrium

320 AA, 160 Aa, 20 aa (n = 500)

1
p = (2 × 320 + 160) ÷ (2 × 500) = 800 ÷ 1000 = 0.8000, q = 1 − 0.8 = 0.2000
2
Expected: p² = 0.6400, 2pq = 0.3200, q² = 0.0400, exactly matching the observed frequencies (0.64, 0.32, 0.04)
3
χ² ≈ 0.0000, far below the 3.841 critical value, so this population is consistent with Hardy-Weinberg equilibrium
p = 0.8000, q = 0.2000, χ² ≈ 0.0000 (Consistent with HWE)
Try this example →

Example 2 — The Classic MN Blood Group Example

49 MM, 42 MN, 9 NN (n = 100)

1
p = (2 × 49 + 42) ÷ (2 × 100) = 140 ÷ 200 = 0.7000, q = 1 − 0.7 = 0.3000
2
Expected: p² = 0.4900, 2pq = 0.4200, q² = 0.0900, exactly matching the observed frequencies
3
χ² ≈ 0.0000, far below the 3.841 critical value, this classic textbook population is consistent with Hardy-Weinberg equilibrium
p = 0.7000, q = 0.3000, χ² ≈ 0.0000 (Consistent with HWE)
Try this example →

Example 3 — A Population Deviating from Equilibrium (Excess Homozygotes)

900 AA, 90 Aa, 10 aa (n = 1000)

1
p = (2 × 900 + 90) ÷ (2 × 1000) = 1890 ÷ 2000 = 0.9450, q = 1 − 0.945 = 0.0550
2
Expected: p² = 0.8930, 2pq = 0.1040, q² = 0.0030, versus observed 0.900, 0.090, 0.010, more homozygotes and fewer heterozygotes than expected
3
χ² ≈ 18.0094, well above the 3.841 critical value, so this population deviates significantly from Hardy-Weinberg equilibrium (consistent with inbreeding or assortative mating)
p = 0.9450, q = 0.0550, χ² ≈ 18.0094 (Deviates from HWE)
Try this example →

❓ Frequently Asked Questions

What is the allele frequency formula?+
p = (2 x AA count + Aa count) / (2 x total individuals), where p is the frequency of the A allele. The frequency of the other allele is q = 1 - p, since the two frequencies must sum to 1 in a two-allele system.
What is the Hardy-Weinberg equation?+
p^2 + 2pq + q^2 = 1, where p^2 is the expected frequency of the AA homozygote, 2pq is the expected frequency of the Aa heterozygote, and q^2 is the expected frequency of the aa homozygote, assuming a population is in Hardy-Weinberg equilibrium.
How do I know if a population is in Hardy-Weinberg equilibrium?+
Compare the observed genotype frequencies to the Hardy-Weinberg expected frequencies (p^2, 2pq, q^2) computed from the same allele frequencies, then run a chi-square goodness-of-fit test. If the chi-square statistic exceeds the critical value (3.841 at 1 degree of freedom, alpha=0.05), the population's genotype frequencies deviate significantly from Hardy-Weinberg equilibrium.
Why does the chi-square test use 1 degree of freedom here?+
There are 3 genotype categories (AA, Aa, aa), which normally gives 2 degrees of freedom, but 1 more degree of freedom is lost because allele frequency p is estimated from the same observed data used in the test, leaving 3 - 1 - 1 = 1 degree of freedom.
What causes a population to deviate from Hardy-Weinberg equilibrium?+
Common causes include natural selection favoring certain genotypes, non-random mating (such as inbreeding or assortative mating), small population size leading to genetic drift, migration introducing new alleles, new mutations, and population substructure where subpopulations with different allele frequencies are pooled together (the Wahlund effect).
Can this calculator handle more than two alleles?+
No, this calculator implements the standard two-allele (A and a), three-genotype (AA, Aa, aa) Hardy-Weinberg model. Multi-allele systems require an extended version of the Hardy-Weinberg equation with more genotype categories and are not covered here.
What is a real example of Hardy-Weinberg equilibrium?+
The classic MN blood group system in humans is a commonly cited textbook example: with genotype counts of 49 MM, 42 MN, and 9 NN in a sample of 100 people, the observed genotype frequencies match the Hardy-Weinberg expected frequencies almost exactly, illustrating a population near equilibrium for this locus.
Does inbreeding cause a Hardy-Weinberg deviation?+
Yes, inbreeding (mating between relatives) typically increases the frequency of homozygotes (both AA and aa) above the Hardy-Weinberg expectation and decreases heterozygote (Aa) frequency below expectation, even though allele frequencies p and q themselves are unaffected by inbreeding alone.
How large does my sample need to be for a reliable chi-square test?+
As a general rule of thumb, chi-square goodness-of-fit tests are considered reliable when every expected genotype count (not frequency) is at least 5. With small samples or a rare allele, an expected count can fall below this threshold, and the chi-square result should be interpreted cautiously or replaced with an exact test.
What is the difference between allele frequency and genotype frequency?+
Allele frequency is the proportion of a specific allele (such as A or a) among all allele copies in the population, while genotype frequency is the proportion of individuals carrying a specific genotype (such as AA, Aa, or aa). Allele frequencies are derived from genotype counts using p = (2 x AA + Aa) / (2 x total).
Can I enter observed frequencies instead of raw counts?+
This calculator is built around genotype counts because the chi-square test requires actual counts, not just frequencies. If you only have observed frequencies, multiply each one by any convenient total sample size (such as 1,000) to generate equivalent counts, then enter those.

What is the allele frequency formula?

p = (2 x AA count + Aa count) / (2 x total individuals), where p is the frequency of the A allele. The frequency of the other allele is q = 1 - p, since the two frequencies must sum to 1 in a two-allele system.

What is the Hardy-Weinberg equation?

p^2 + 2pq + q^2 = 1, where p^2 is the expected frequency of the AA homozygote, 2pq is the expected frequency of the Aa heterozygote, and q^2 is the expected frequency of the aa homozygote, assuming a population is in Hardy-Weinberg equilibrium.

How do I know if a population is in Hardy-Weinberg equilibrium?

Compare the observed genotype frequencies to the Hardy-Weinberg expected frequencies (p^2, 2pq, q^2) computed from the same allele frequencies, then run a chi-square goodness-of-fit test. If the chi-square statistic exceeds the critical value (3.841 at 1 degree of freedom, alpha=0.05), the population's genotype frequencies deviate significantly from Hardy-Weinberg equilibrium.

Why does the chi-square test use 1 degree of freedom here?

There are 3 genotype categories (AA, Aa, aa), which normally gives 2 degrees of freedom, but 1 more degree of freedom is lost because allele frequency p is estimated from the same observed data used in the test, leaving 3 - 1 - 1 = 1 degree of freedom.

What causes a population to deviate from Hardy-Weinberg equilibrium?

Common causes include natural selection favoring certain genotypes, non-random mating (such as inbreeding or assortative mating), small population size leading to genetic drift, migration introducing new alleles, new mutations, and population substructure where subpopulations with different allele frequencies are pooled together (the Wahlund effect).

Can this calculator handle more than two alleles?

No, this calculator implements the standard two-allele (A and a), three-genotype (AA, Aa, aa) Hardy-Weinberg model. Multi-allele systems require an extended version of the Hardy-Weinberg equation with more genotype categories and are not covered here.

What is a real example of Hardy-Weinberg equilibrium?

The classic MN blood group system in humans is a commonly cited textbook example: with genotype counts of 49 MM, 42 MN, and 9 NN in a sample of 100 people, the observed genotype frequencies match the Hardy-Weinberg expected frequencies almost exactly, illustrating a population near equilibrium for this locus.

Does inbreeding cause a Hardy-Weinberg deviation?

Yes, inbreeding (mating between relatives) typically increases the frequency of homozygotes (both AA and aa) above the Hardy-Weinberg expectation and decreases heterozygote (Aa) frequency below expectation, even though allele frequencies p and q themselves are unaffected by inbreeding alone.

How large does my sample need to be for a reliable chi-square test?

As a general rule of thumb, chi-square goodness-of-fit tests are considered reliable when every expected genotype count (not frequency) is at least 5. With small samples or a rare allele, an expected count can fall below this threshold, and the chi-square result should be interpreted cautiously or replaced with an exact test.

What is the difference between allele frequency and genotype frequency?

Allele frequency is the proportion of a specific allele (such as A or a) among all allele copies in the population, while genotype frequency is the proportion of individuals carrying a specific genotype (such as AA, Aa, or aa). Allele frequencies are derived from genotype counts using p = (2 x AA + Aa) / (2 x total).

Can I enter observed frequencies instead of raw counts?

This calculator is built around genotype counts because the chi-square test requires actual counts, not just frequencies. If you only have observed frequencies, multiply each one by any convenient total sample size (such as 1,000) to generate equivalent counts, then enter those.