Allele Frequency Calculator
Find allele frequencies p and q from genotype counts, then compare observed genotype frequencies against Hardy-Weinberg equilibrium expectations.
🧬 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
📖 How to Use This Calculator
Steps
💡 Example Calculations
Example 1 — A Population in Hardy-Weinberg Equilibrium
320 AA, 160 Aa, 20 aa (n = 500)
Example 2 — The Classic MN Blood Group Example
49 MM, 42 MN, 9 NN (n = 100)
Example 3 — A Population Deviating from Equilibrium (Excess Homozygotes)
900 AA, 90 Aa, 10 aa (n = 1000)
❓ Frequently Asked Questions
🔗 Related Calculators
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.