Allele Frequency Calculator - Hardy-Weinberg Tool

Calculate allele frequencies, genotype frequencies, and Hardy-Weinberg equilibrium for any population from genotype counts or direct allele inputs.

Enter genotype counts (AA, Aa, aa) or direct allele counts to compute p, q, expected genotype frequencies, and a chi-square HWE test.

Allele Frequency Calculator - Hardy-Weinberg Tool
Calculate allele frequencies, genotype frequencies, and Hardy-Weinberg equilibrium for any population from genotype counts or direct allele inputs.

About the Allele Frequency Calculator

The allele frequency calculator is a population genetics tool that computes the fundamental quantities used to characterize genetic variation within a population: the frequency of each allele, the frequency of each genotype, and whether the population is in Hardy-Weinberg equilibrium (HWE). These calculations are essential for courses in genetics and evolutionary biology, clinical genetics, conservation biology, and any research involving population-level DNA data. Allele frequency is the simplest and most important summary statistic in population genetics. For a two-allele system — the dominant allele A and the recessive allele a — the allele frequencies are denoted p (frequency of A) and q (frequency of a), with the requirement that p + q = 1. When working from genotype counts, p = (2 × AA + Aa) / (2 × N) where N is the total number of diploid individuals. The denominator 2N is the total number of alleles in the population because each diploid individual carries two copies. From direct allele counts, p = A / (A + a) and q = a / (A + a). Genotype frequencies describe what fraction of the population carries each of the three diploid genotype classes: AA (homozygous dominant), Aa (heterozygous), and aa (homozygous recessive). The observed genotype frequencies are simply the counts divided by N. The expected genotype frequencies under Hardy-Weinberg equilibrium are p², 2pq, and q² respectively, predicted by the Hardy-Weinberg principle. The Hardy-Weinberg principle states that in a large, randomly mating population with no mutation, migration, natural selection, or genetic drift, allele and genotype frequencies will remain constant from generation to generation. The expected genotype counts under HWE are p² × N for AA, 2pq × N for Aa, and q² × N for aa. When observed genotype counts differ significantly from these expectations, the population is said to be out of HWE, which may signal inbreeding, population stratification, natural selection acting on the locus, or a genotyping error in laboratory data. The chi-square test provides a formal statistical framework for deciding whether deviations from HWE are larger than would be expected by random chance. The test statistic is the sum of (observed − expected)² / expected across the three genotype classes. With one degree of freedom (2 alleles, 3 genotypes, 1 constraint), the critical value at p = 0.05 is 3.841. A chi-square value below 3.841 is consistent with HWE; a value above indicates a statistically significant departure. Practical applications are wide-ranging. In clinical genetics, testing a SNP for HWE is a standard quality-control step — systematic HWE departure in control genotyping data flags batch effects or genotyping errors. In conservation biology, departure from HWE in small or fragmented populations can indicate inbreeding depression or genetic bottlenecks. In forensic genetics, HWE assumptions underlie the product rule used to calculate the random match probability of a DNA profile. Understanding p and q for disease-associated alleles also lets epidemiologists estimate carrier frequencies using the 2pq formula.

Allele Frequency Examples

Real population scenarios showing genotype counts, allele frequencies, and Hardy-Weinberg expectations.

Populationp / qHWE assessment
50 AA, 30 Aa, 20 aa (N=100)p = 0.6500, q = 0.3500Expected: AA 42.25, Aa 45.50, aa 12.25. Chi-square ≈ 7.14 — deviates from HWE.
10 AA, 80 Aa, 10 aa (N=100)p = 0.5000, q = 0.5000Mostly heterozygotes. Expected: AA 25, Aa 50, aa 25. Chi-square ≈ 36 — strongly out of HWE (excess heterozygotes).
120 A alleles, 80 a allelesp = 0.6000, q = 0.4000Direct allele input mode. N estimated as 100. Expected: AA 36, Aa 48, aa 16.
3 AA, 2 Aa, 5 aa (N=10)p = 0.4000, q = 0.6000Small population. Expected: AA 1.6, Aa 4.8, aa 3.6. Small sample sizes make HWE testing unreliable.

How to use the Allele Frequency Calculator

  1. Choose your input method: 'Genotype Counts' if you have AA, Aa, and aa counts, or 'Allele Counts' if you have direct counts of each allele.
  2. For genotype counts: enter the number of homozygous dominant (AA), heterozygous (Aa), and homozygous recessive (aa) individuals.
  3. For allele counts: enter the number of A alleles and a alleles. Optionally enter the total number of individuals to get scaled HWE expected counts.
  4. Click Calculate. The tool displays p and q, total N, expected genotype counts under HWE, and (for genotype input) a chi-square test for HWE departure.
  5. Click Reset to clear all fields and start a new calculation.

Allele Frequency Calculator FAQ

What do p and q represent in genetics?
In a two-allele system, p is the frequency of the dominant allele (A) and q is the frequency of the recessive allele (a). They always sum to 1 (p + q = 1) because every allele at the locus must be either A or a. Allele frequencies range from 0 (allele absent) to 1 (allele fixed in the population).
What is Hardy-Weinberg equilibrium?
Hardy-Weinberg equilibrium (HWE) describes the theoretical state of a population where allele and genotype frequencies remain constant across generations. It requires five conditions: large population size, random mating, no mutation, no migration, and no natural selection. Under HWE, the expected genotype frequencies are p² (AA), 2pq (Aa), and q² (aa).
Why might my population deviate from HWE?
Common causes of HWE departure include inbreeding (reduces heterozygosity), population stratification (mixing of genetically distinct subpopulations), strong natural selection on the locus, recent migration, or genotyping errors in lab data. Excess homozygosity suggests inbreeding; excess heterozygosity may indicate population stratification or a heterozygote advantage.
How is the chi-square test for HWE interpreted?
The chi-square statistic measures the difference between observed and expected genotype counts. With 1 degree of freedom, a value below 3.841 is not statistically significant at the 5% level (consistent with HWE). A value above 3.841 indicates a significant departure from HWE. Note that with very small sample sizes (N < 20), the chi-square approximation is unreliable and an exact test is preferred.
Can I use this calculator for X-linked loci?
The standard Hardy-Weinberg formulas shown here apply to autosomal loci. For X-linked loci, males are hemizygous (carrying only one allele), so the frequency of the recessive phenotype in males equals q rather than q². A separate X-linked HWE analysis is needed, though the allele frequency calculation (p and q) from female genotype counts uses the same formula.
What is a typical allele frequency for a common disease variant?
Common disease-associated SNPs identified in genome-wide association studies (GWAS) often have minor allele frequencies (MAF) between 0.05 and 0.50. Rare Mendelian disease variants can have frequencies well below 0.01 (1%). Carrier frequency for a recessive disease equals 2pq, so for a recessive allele with q = 0.01, the carrier frequency is approximately 2 × 0.99 × 0.01 ≈ 2%.