ThisCalculator

Biology

Hardy-Weinberg Calculator: Calculate Allele Frequencies

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Hardy-Weinberg Calculator: Calculate Allele Frequencies

This calculator estimates Hardy-Weinberg genotype frequencies from the frequency of one allele in a two-allele population. Enter the frequency of allele A as a decimal from 0 to 1; the calculator returns the expected frequencies of AA, Aa, and aa, along with the other allele’s frequency.

Formula

For a gene with two alleles, A and a, Hardy-Weinberg proportions are described by p + q = 1 and p² + 2pq + q² = 1. Here, p is the frequency of allele A, q is the frequency of allele a, p² is the expected frequency of AA individuals, 2pq is the expected frequency of Aa individuals, and q² is the expected frequency of aa individuals. Frequencies are proportions, so they have no physical units; multiply by 100 to express them as percentages.

The calculator uses q = 1 − p, then calculates the three genotype frequencies. The model assumes a population with two alleles at one locus and random mating, with no meaningful effects from selection, mutation, migration, or genetic drift. These are expected proportions under the model, not a guarantee that a real sample will match them exactly.

Worked Example

Using the default input, p = 0.6:

  1. Find the other allele frequency: q = 1 − 0.6 = 0.4.
  2. Calculate expected AA: p² = 0.6² = 0.36, or 36%.
  3. Calculate expected Aa: 2pq = 2 × 0.6 × 0.4 = 0.48, or 48%.
  4. Calculate expected aa: q² = 0.4² = 0.16, or 16%.

The expected proportions add to 1: 0.36 + 0.48 + 0.16 = 1.00. The calculator displays four decimal places, so its results are 0.4000, 0.3600, 0.4800, and 0.1600.

What You’ll Need

  • The frequency of one allele, entered as a decimal from 0 through 1. For example, 35% is 0.35.
  • If you are working from observed genotype counts, the numbers of AA, Aa, and aa individuals and the total sample size. These let you calculate allele frequency before using the calculator.
  • A clear definition of which allele is A and which is a. The labels are arbitrary, but use them consistently.

Step-by-Step

  1. Identify the locus and alleles. Apply the two-allele version of the model to one gene location at a time. Confirm that your data distinguish the two alleles and the three possible genotypes.
  2. Obtain an allele frequency. Use a reliable estimate for allele A, or calculate it from genotype counts. If there are N diploid individuals, the total number of allele copies is 2N. Count two A copies for each AA individual and one for each Aa individual: p = (2 × AA + Aa) / (2N).
  3. Enter p as a proportion. Convert a percentage to a decimal by dividing by 100. Enter 0.6 for 60%, not 60. Values must be between 0 and 1 inclusive.
  4. Read q. The frequency of the other allele is q = 1 − p. Check that p and q add to 1. If you started with the frequency of a instead, designate it as q and calculate p as 1 − q.
  5. Calculate expected genotype proportions. Square p for AA, calculate 2pq for Aa, and square q for aa. These are proportions among individuals expected under Hardy-Weinberg conditions.
  6. Convert proportions to percentages or counts if useful. Multiply a frequency by 100 for a percentage. To obtain expected counts for a sample of N individuals, multiply each genotype frequency by N. Expected counts may be fractional; observed counts must be whole individuals.
  7. Check the results. The three genotype proportions should sum to 1, apart from minor display rounding. Confirm the allele frequencies also add to 1. If comparing with observed data, use an appropriate statistical test rather than treating small differences as proof that the model fails.

Common Mistakes

  • Entering a percentage as a whole number: use 0.25 for 25%. An input above 1 is not a valid allele frequency.
  • Confusing allele and genotype frequencies: p and q refer to alleles; p², 2pq, and q² refer to genotypes. Do not treat an observed heterozygote percentage as an allele frequency.
  • Forgetting that heterozygotes have two allele arrangements: the expected heterozygote frequency is 2pq, not pq.
  • Using a genotype-count formula with the wrong denominator: diploid individuals carry two copies of the locus, so divide the total A copies by 2N, not N.
  • Rounding too early: retain the original precision during calculations and round only the displayed result. Rounded genotype percentages may total 99.9% or 100.1%.
  • Assuming expected counts must be whole numbers: expected values are averages from a probability model; observed sample counts are integers.

Tips

  • Keep a note of whether the input is p or q; the calculator specifically takes p, the frequency of allele A.
  • For an allele frequency near 0 or 1, expect most individuals to have the corresponding homozygous genotype under the model.
  • When you have genotype counts, calculate p directly from allele copies, then calculate the expected genotype proportions. Do not use observed genotype proportions as though they were the expected values.
  • State the population, locus, sample, and assumptions alongside results. This makes the calculation easier to interpret and reproduce.
  • For more than two alleles, the simple two-allele formulas are not sufficient as written. Use the multi-allele form, in which genotype frequencies depend on each allele frequency and their pairwise combinations.

Troubleshooting

The input is rejected or looks unreasonable: check that p is a decimal from 0 to 1. Convert percentages, and check for a misplaced decimal point.

The genotype frequencies do not add to 1: recalculate q as 1 − p and verify that the terms are p², 2pq, and q². If they differ only in the last displayed digit, that is usually rounding; check using unrounded values.

Expected and observed counts differ: multiply each expected proportion by the same sample size used for the observations. Differences can occur by chance, especially in small samples, or because assumptions are not met. Check sampling, genotype calls, population structure, mating patterns, and possible selection before drawing a conclusion.

You have genotype counts but no allele frequency: let AA, Aa, and aa be the observed counts and N their sum. Calculate p = (2AA + Aa)/(2N) and q = (2aa + Aa)/(2N); verify p + q = 1. Then use p in the calculator.

Frequently Asked Questions

What does the Hardy-Weinberg calculation tell me?
It gives expected genotype proportions from allele frequencies under the model’s assumptions. It is a baseline for comparing a population with observed data.

How do I calculate allele frequency from genotype counts?
For N diploid individuals, count two copies per matching homozygote and one per heterozygote. For allele A, p = (2AA + Aa)/(2N).

Can I use this for a recessive phenotype?
Only if the phenotype reliably identifies the homozygous recessive genotype and the two-allele model is appropriate. In that case, the recessive genotype frequency estimates q²; take its square root to estimate q, then calculate p = 1 − q.

Does a difference from expected prove evolution is happening?
No. A difference may reflect sampling variation, genotyping errors, population structure, or other departures from assumptions. Statistical testing and context are needed.

What if p equals 0 or 1?
The formulas still work. At p = 0, all expected genotypes are aa; at p = 1, all are AA. There are no expected heterozygotes in either case.

Can I use the formula for a haploid organism?
Not directly for genotype proportions as written. The equations describe diploid genotypes formed from two allele copies; adapt the analysis to the organism’s ploidy and life cycle.

Related

Formula used
in p | Frequency of allele A | - | 0.6 | 0
out q | Frequency of allele a | - | 1 - p | 4
out AA | Expected AA frequency | - | p ^ 2 | 4
out Aa | Expected Aa frequency | - | 2 * p * q | 4
out aa | Expected aa frequency | - | q ^ 2 | 4

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.