Allele Frequency Calculator

This calculator works out allele frequencies from genotype counts using the Hardy-Weinberg principle, a foundational tool in population genetics for students and researchers studying a single two-allele locus. Enter the number of individuals observed with each genotype, AA (homozygous dominant), Aa (heterozygous), and aa (homozygous recessive), choose a significance level of 0.05, 0.01, or 0.10 for the Hardy-Weinberg test, and pick whether frequencies display as decimals or percentages. The calculator returns the frequency of the dominant allele (p) and recessive allele (q), the total individuals sampled, and the total alleles in the gene pool. It then compares your observed genotype counts against the counts expected under Hardy-Weinberg equilibrium (p squared, 2pq, q squared), runs a chi-square goodness-of-fit test showing the statistic, critical value, and degrees of freedom, and states whether the population is in equilibrium or deviates significantly from it. A plain-English interpretation explains what a deviation could mean, such as non-random mating, selection, migration, or genotyping error. Use it to check whether a locus you have genotyped fits the equilibrium model, or to see how changing genotype counts shifts allele frequencies and test outcomes. Note that the chi-square test is only reliable when expected genotype counts are at least 5; for smaller samples, use Fisher's exact test instead.

Calculate.co.nz is proud to be partnered with Health Based Building, a leader in sustainable and health-conscious building innovation. With over a century of experience, they develop high-performance systems like Foreverbreathe Specification, Magnum Board, and Foreverbreathe Paints to support energy-efficient, non-toxic living environments. Their commitment to healthier homes aligns with our belief that informed choices lead to better outcomes for Kiwi households.
Calculate.co.nz partner: Health Based Building
Standard method  Hardy-Weinberg principle (Hardy 1908; Weinberg 1908). Chi-square goodness-of-fit with 1 degree of freedom.

1. Observed Genotype Counts

2. Options

Allele Frequencies

Frequency p (A)
0.8000
Dominant allele
Frequency q (a)
0.2000
Recessive allele
Total individuals
500
Sampled
Total alleles (2N)
1,000
In gene pool sample

Observed vs Expected Genotypes

GenotypeObservedExpected (HWE)Freq (obs)

Hardy-Weinberg Test

p (freq. of A allele)0.8000
q (freq. of a allele)0.2000
p + q1.0000
Expected AA (p²)320.0 (p2 = 0.6400)
Expected Aa (2pq)160.0 (2pq = 0.3200)
Expected aa (q²)20.0 (q2 = 0.0400)
Chi-square statistic0.0000 (p ≈ 1.0000)
Degrees of freedom1
Critical value (α = 0.05)3.841
HWE conclusionIn HWE
Interpretation: Enter genotype counts above to see results.

How Allele Frequency is Calculated

At a locus with two alleles, A (dominant) and a (recessive), each individual carries exactly two copies. The frequency of allele A (denoted p) is the proportion of all allele copies in the sample that are A:

p = (2 x N_AA + N_Aa) / (2 x N_total)
q = 1 - p

where N_AA = count of AA individuals, N_Aa = count of Aa individuals, N_total = N_AA + N_Aa + N_aa

The denominator is 2 x N_total because each individual carries two alleles. For example, if you have 320 AA, 160 Aa, and 20 aa individuals (total = 500), the total number of alleles is 1,000. The A alleles are: (2 x 320) + 160 = 800, so p = 800 / 1,000 = 0.8. Then q = 1 - 0.8 = 0.2.

Hardy-Weinberg Expected Genotype Frequencies

Under Hardy-Weinberg equilibrium, the expected frequencies of the three genotypes are determined entirely by the allele frequencies:

Expected frequency of AA = p²
Expected frequency of Aa = 2pq
Expected frequency of aa = q²

Expected count of AA = p² x N
Expected count of Aa = 2pq x N
Expected count of aa = q² x N

In the worked example (320 AA, 160 Aa, 20 aa; N = 500; p = 0.8; q = 0.2): expected AA = 0.64 x 500 = 320; expected Aa = 2 x 0.8 x 0.2 x 500 = 160; expected aa = 0.04 x 500 = 20. The observed counts match the HWE expected counts exactly in this example, giving a chi-square of 0 and a non-significant HWE test.

Chi-Square Test for Hardy-Weinberg Equilibrium

The chi-square goodness-of-fit test compares observed genotype counts to HWE expected counts. The statistic is:

X² = sum of [(Observed - Expected)² / Expected]

X² = (O_AA - E_AA)² / E_AA + (O_Aa - E_Aa)² / E_Aa + (O_aa - E_aa)² / E_aa

The degrees of freedom for the HWE test is 1 (three genotype classes minus one allele frequency estimated from the data minus one constraint that frequencies sum to 1, giving 3 - 1 - 1 = 1). At a significance level of 0.05, the critical value is 3.841. If the chi-square exceeds this threshold, the population departs significantly from HWE at the chosen significance level.

The chi-square test is only reliable when expected counts are at least 5 for each genotype class. With small samples, Fisher's exact test or a permutation test is preferable.

What Causes Departure from Hardy-Weinberg Equilibrium?

CauseEffect on genotype frequencies
Inbreeding / non-random matingExcess homozygotes (AA and aa), deficit of heterozygotes (Aa)
Positive assortative matingExcess homozygotes
Outbreeding / hybrid vigourExcess heterozygotes
Natural selection against a genotypeDeficit of the selected-against genotype
Recent migration or admixtureExcess heterozygotes (Wahlund effect reversed)
Wahlund effect (hidden subpopulations)Excess homozygotes
Genotyping errorOften excess homozygotes due to allele dropout

Worked Example

A researcher genotypes 500 individuals at a single nucleotide polymorphism (SNP) and finds: AA = 320, Aa = 160, aa = 20. To test whether this SNP locus is in Hardy-Weinberg equilibrium:

  1. Total alleles = 2 x 500 = 1,000
  2. A alleles = (2 x 320) + 160 = 800; so p = 800/1,000 = 0.8000
  3. q = 1 - 0.8 = 0.2000
  4. Expected AA = 0.8² x 500 = 320.0
  5. Expected Aa = 2 x 0.8 x 0.2 x 500 = 160.0
  6. Expected aa = 0.2² x 500 = 20.0
  7. Chi-square = (320-320)²/320 + (160-160)²/160 + (20-20)²/20 = 0.000
  8. Conclusion: chi-square (0.000) is below the critical value of 3.841, so the locus is in HWE (p-value = 1.000).

The default inputs in this calculator are set to match this worked example exactly.

Related Calculators

Sources and method: Hardy GH (1908) "Mendelian proportions in a mixed population." Science 28:49-50. Weinberg W (1908) "Uber den Nachweis der Vererbung beim Menschen." Jahreshefte des Vereins fur vaterlandische Naturkunde in Wurttemberg 64:368-382. Chi-square critical value from standard chi-square distribution table (df = 1). Guo SW, Thompson EA (1992) "Performing the exact test of Hardy-Weinberg proportion for multiple alleles." Biometrics 48:361-372.

This calculator is for educational and research planning purposes. The chi-square test for HWE requires expected counts of at least 5 per genotype class. For small samples, use Fisher's exact test. Always consult a statistician or geneticist for formal population genetics analyses.