Allele Frequency Calculator
Calculate allele frequencies (p and q) from genotype counts, test for Hardy-Weinberg equilibrium, and compare observed vs expected genotype frequencies
Allele Frequency Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser โ no data is sent to any server.
Formula: p = (2 x AA + Aa) / (2 x N) ; q = (2 x aa + Aa) / (2 x N) ; p + q = 1
Worked example โ p(M) = 0.60, q(N) = 0.40
Formula
p = (2 x AA + Aa) / (2 x N) ; q = (2 x aa + Aa) / (2 x N) ; p + q = 1
Where p is the frequency of the dominant allele, q is the frequency of the recessive allele, AA is the count of dominant homozygous individuals, Aa is heterozygous count, aa is recessive homozygous count, and N is total individuals. For Hardy-Weinberg equilibrium, expected genotype frequencies are p squared, 2pq, and q squared.
Worked Examples
Example 1: MN Blood Group Allele Frequencies
Problem:In a population of 1,000 people, 360 have genotype MM, 480 have MN, and 160 have NN. Calculate the allele frequencies of M and N.
Solution:Total alleles = 1,000 x 2 = 2,000 Frequency of M (p) = (2 x 360 + 480) / 2,000 = 1,200 / 2,000 = 0.60 Frequency of N (q) = (2 x 160 + 480) / 2,000 = 800 / 2,000 = 0.40 Check: p + q = 0.60 + 0.40 = 1.00
Result:p(M) = 0.60, q(N) = 0.40
Example 2: Testing for Hardy-Weinberg Equilibrium
Problem:Observed: 50 AA, 40 Aa, 10 aa (total 100). Is this population in HWE?
Solution:p = (2x50 + 40) / 200 = 0.70, q = 0.30 Expected: AA = 0.49 x 100 = 49, Aa = 0.42 x 100 = 42, aa = 0.09 x 100 = 9 Chi-square = (50-49)^2/49 + (40-42)^2/42 + (10-9)^2/9 = 0.0204 + 0.0952 + 0.1111 = 0.2268 0.2268 < 3.841 critical value
Result:Chi-square = 0.2268, population IS in Hardy-Weinberg equilibrium (p > 0.05)
Frequently Asked Questions
What is allele frequency and why does it matter?
Allele frequency is the proportion of a specific allele (variant of a gene) within a population's gene pool. It is calculated by counting the number of copies of that allele and dividing by the total number of alleles at that locus in the population. Allele frequencies are fundamental to population genetics because changes in these frequencies over generations indicate evolution. If allele frequencies remain constant, the population is said to be in Hardy-Weinberg equilibrium, meaning no evolutionary forces are acting on that gene.
How do you calculate allele frequency from genotype counts?
To calculate allele frequency, count the total number of each allele in the population. For a two-allele system (A and a): the frequency of A (p) = (2 x number of AA individuals + number of Aa individuals) / (2 x total individuals). Similarly, q = (2 x number of aa individuals + number of Aa individuals) / (2 x total individuals). The factor of 2 accounts for diploid organisms carrying two alleles per locus. The frequencies p and q must always sum to 1.0, which serves as a useful check on your calculations.
What is the Hardy-Weinberg equilibrium principle?
The Hardy-Weinberg principle states that allele and genotype frequencies in a population will remain constant from generation to generation in the absence of evolutionary influences. For this to hold, five conditions must be met: no mutation, random mating, no natural selection, extremely large population size, and no gene flow (migration). The expected genotype frequencies under HWE are: AA = p squared, Aa = 2pq, and aa = q squared. Deviations from these expected frequencies suggest that one or more evolutionary forces are acting on the population.
What does the chi-square test tell us about allele frequencies?
The chi-square goodness-of-fit test compares observed genotype counts with those expected under Hardy-Weinberg equilibrium. A chi-square value less than 3.841 (the critical value at 1 degree of freedom and alpha = 0.05) means the population does not significantly deviate from HWE. A value above this threshold suggests evolutionary forces such as natural selection, genetic drift, non-random mating, or migration may be influencing the allele frequencies. This test is one of the most commonly used statistical tools in population genetics research.
Can allele frequency change over time?
Yes, allele frequencies change over time through several mechanisms collectively known as evolutionary forces. Natural selection favors alleles that increase fitness, causing their frequency to rise. Genetic drift causes random changes in small populations. Mutation introduces new alleles at very low rates. Gene flow (migration) between populations can introduce or remove alleles. Non-random mating (such as inbreeding or assortative mating) changes genotype frequencies without directly altering allele frequencies. Tracking these changes across generations is central to the study of evolution and conservation biology.
What is the difference between allele frequency and genotype frequency?
Genotype frequencies are proportions of individuals, so AA, Aa and aa are each divided by N and the three sum to 1. Allele frequencies are proportions of gene copies, divided by 2N because every diploid individual carries two alleles at the locus, and p and q sum to 1. The Hardy-Weinberg expressions p squared, 2pq and q squared are the bridge between them, predicting genotype frequencies from allele frequencies under random mating.
Why can't direct gene counting be used for a fully dominant trait?
Counting requires that heterozygotes be visible, which is true for codominant markers such as blood groups, allozymes and SNP genotypes. With complete dominance, AA and Aa share one phenotype and cannot be separated by inspection. The only route left is to take q as the square root of the recessive phenotype frequency: a 16 percent recessive phenotype implies q = 0.4, p = 0.6 and a carrier frequency 2pq of 0.48. That shortcut assumes Hardy-Weinberg equilibrium, so it cannot afterwards be used to test for it.
What does a shortage or surplus of heterozygotes indicate when a population fails the test?
A deficit most often points to inbreeding or to population structure. Pooling two genetically distinct subpopulations produces an apparent heterozygote shortfall even when each is internally at equilibrium, an artefact called the Wahlund effect. In molecular datasets a null allele that fails to amplify creates the same signature by miscalling heterozygotes as homozygotes. A surplus is rarer and suggests balancing selection favouring heterozygotes, negative assortative mating, or a very small breeding group.
How is the inbreeding coefficient F calculated from these genotype counts?
F compares observed heterozygosity with the Hardy-Weinberg expectation: F = 1 - (observed heterozygote frequency / 2pq). Using the default counts of 320 AA, 480 Aa and 200 aa, p is 0.56 and q is 0.44, so expected heterozygosity is 2 x 0.56 x 0.44 = 0.4928 against an observed 0.480, giving F = 1 - 0.480/0.4928 = 0.026. Positive values indicate a heterozygote deficit, negative values an excess, and zero matches equilibrium exactly.
How large a sample is needed before an allele frequency estimate settles down?
The sampling standard error of an allele frequency is roughly the square root of pq divided by 2N. At p = 0.5 with 100 individuals that is about 0.035, so a 95 percent interval spans roughly plus or minus 0.07 and the estimate could sit anywhere from 0.43 to 0.57. Raising the sample to 1,000 individuals cuts the standard error to about 0.011. Because precision improves with the square root of N, quadrupling the sample only halves the uncertainty.
References
Background & Theory
History
Reviewed for accuracy by Daniel Agrici, Founder & Lead Developer ยท Editorial policy
Related Calculators
๐งฎAmino Acid Frequency Calculator
Calculate amino acid frequency with inputs, formulas, and instant results.
๐งฎLinkage Recombination Frequency Calculator
Calculate linkage recombination frequency with inputs, formulas, and instant results.
๐งฎCodon Usage Calculator โ Frequency by Amino Acid
Calculate codon usage with inputs, formulas, and instant results.
๐งฎAlpaca Gestation Calculator
Calculate alpaca gestation with inputs, formulas, and instant results.
๐งฎCat Pregnancy Calculator โ Due Date & Gestation
Calculate cat pregnancy with inputs, formulas, and instant results.
๐งฎCow Gestation Calculator
Calculate cow gestation with inputs, formulas, and instant results.
๐งฎDog Pregnancy Calculator: Due Date by Breed
Calculate dog pregnancy with inputs, formulas, and instant results.
๐งฎGoat Gestation Calculator
Calculate goat gestation with inputs, formulas, and instant results.