Allele Frequency Calculator
Last updated: 20 August 2026
Reviewed by Gavin · Research and drafting assisted by AI
Enter the observed counts of three genotypes at a single biallelic locus: homozygous reference AA, heterozygous Aa, and homozygous alternate aa. The calculator derives allele frequencies, expected Hardy-Weinberg proportions, goodness-of-fit χ², and the inbreeding coefficient F.
Allele Frequency Calculator
The Allele Frequency Calculator is a population-genetics tool that turns three integer counts, the number of homozygous reference individuals (AA), heterozygous individuals (Aa), and homozygous alternate individuals (aa), into the complete Hardy-Weinberg statistics used in every introductory genetics textbook, molecular ecology paper, and forensic DNA lab report. From a single set of three counts you get the allele frequencies p and q, the Hardy-Weinberg expected genotype counts (p²N, 2pqN, q²N), Pearson's chi-square goodness-of-fit with its p-value, the expected and observed heterozygosity, Wright's inbreeding coefficient F, and the polymorphism information content (PIC) of Botstein et al. (1980). The math is implemented from first principles in pure JavaScript, no statistical library, no look-up tables, so the result is reproducible to the last decimal place.
The calculator is designed for a single biallelic locus: a single position in the genome where exactly two alleles are segregating (call them A and a). This covers the vast majority of population-genetics studies, most SNPs, microsatellites scored as presence/absence, RFLP markers, classical blood-group antigens, HLA-A and HLA-B supertypes, and many sex-linked markers when the analysis is restricted to one sex. For multiallelic loci (HLA-DRB1 with 100+ alleles, microsatellites with 10+ length variants) the simple biallelic framework doesn't apply and you need a multiallele extension.
How to Use the Allele Frequency Calculator
- Count your genotypes. Type the number of AA individuals, Aa individuals, and aa individuals into the three input boxes. The total sample size N = AA + Aa + aa is computed automatically. Counts must be non-negative integers.
- Verify N. The N readout below the inputs shows the sum, make sure it matches your sample size. If you have 200 individuals, all 200 must be assigned to one of the three genotype classes.
- Click "Calculate". The results panel populates with allele frequencies, expected counts, χ², p-value, heterozygosity, F, and PIC.
- Read the interpretation. The calculator tells you whether to reject Hardy-Weinberg equilibrium at α = 0.05, whether there is a heterozygote excess or deficit, and how informative the locus is (low / moderate / high PIC).
- Use the test cases. A collapsible section at the bottom of the page contains six hand-verified test cases you can load into the form to sanity-check the calculator against known results.
- Copy the results. A single "Copy results" button writes a plain-text summary to your clipboard, useful for pasting into a lab notebook, a manuscript supplement, or a CSV.
The calculator tolerates any non-negative integer counts including 0 (a monomorphic or hemizygous class) and reports edge cases (PIC = 0 for a monomorphic locus, F undefined when H_exp = 0, χ² undefined when an expected count is exactly 0).
The Formulas
Given three counts AA, Aa, aa with total sample size N = AA + Aa + aa:
Allele frequencies (gene-counting, maximum-likelihood under random mating):
- p = (2·AA + Aa) / (2·N), frequency of allele A
- q = 1 − p, frequency of allele a
Observed genotype frequencies (proportions of the sample):
- f(AA) = AA / N
- f(Aa) = Aa / N
- f(aa) = aa / N
Hardy-Weinberg expected frequencies (binomial expansion of (p + q)² = 1):
- E[AA] = p²
- E[Aa] = 2pq
- E[aa] = q²
Hardy-Weinberg expected counts (out of N individuals):
- E(AA) = p²·N
- E(Aa) = 2pq·N
- E(aa) = q²·N
Goodness-of-fit chi-square (Pearson, df = 1, since the parameter p is estimated from the data):
- χ² = Σᵢ (Oᵢ − Eᵢ)² / Eᵢ
p-value: the right-tail probability of the chi-square distribution with 1 degree of freedom, computed via the upper regularized incomplete gamma function Q(½, χ²/2). For the critical values df = 1, χ² = 3.841 → p = 0.05; χ² = 6.635 → p = 0.01; χ² = 10.828 → p = 0.001.
Heterozygosity:
- H_exp = 2pq (expected, under HWE)
- H_obs = Aa / N (observed, direct from the sample)
Inbreeding coefficient (Wright 1922):
- F = 1 − H_obs / H_exp
- F > 0 → heterozygote deficit (possible inbreeding, population substructure, null alleles)
- F < 0 → heterozygote excess (outbreeding, selection against homozygotes, genotyping error)
- F = 0 → HWE-equilibrium
Polymorphism information content (Botstein, White, Skolnick, Davis 1980, biallelic form):
- PIC = 1 − p² − q² − 2p²q²
The PIC ranges from 0 (monomorphic locus, p = 0 or p = 1) to a maximum of 0.375 (when p = q = 0.5). For multiallelic markers, the full Botstein et al. formula uses a sum over all alleles; for a biallelic locus it reduces to the expression above.
Worked Examples
Example 1: A textbook MN blood-group sample (p = q = 0.5)
You genotype 100 unrelated individuals for the MN blood-group locus and find 25 MM, 50 MN, 25 NN. The classical Hardy-Weinberg case with p = q = 0.5.
Input: AA = 25, Aa = 50, aa = 25 (N = 100) Allele frequencies: p = (50 + 50) / 200 = 0.5, q = 0.5 HWE expected counts: p²N = 25, 2pqN = 50, q²N = 25, identical to observed χ² = 0.00, p-value = 1.0000, HWE is not rejected (the data fit perfectly) F = 0, the inbreeding coefficient is exactly zero PIC = 0.375, the maximum value, achieved at p = q = 0.5
This is the classic "perfect HWE" case taught in every genetics textbook.
Example 2: A heterozygote-deficient sample
A molecular-ecology study of a small, isolated population finds 48 AA, 32 Aa, 20 aa (N = 100). The p and q are p = 0.64, q = 0.36, but the Aa count is lower than expected.
Input: AA = 48, Aa = 32, aa = 20 (N = 100) Allele frequencies: p = (96 + 32) / 200 = 0.64, q = 0.36 HWE expected counts: p²N = 40.96, 2pqN = 46.08, q²N = 12.96 χ² ≈ 9.34, p-value ≈ 0.0022, HWE is rejected at α = 0.05 F ≈ 0.31, substantial heterozygote deficit PIC ≈ 0.355, moderately to highly informative
The heterozygote deficit (F > 0) is consistent with population substructure, recent inbreeding, or null alleles at the locus. The χ² test rejects HWE because the deficit is too large to be random sampling noise.
Example 3: An extreme deviation (no heterozygotes observed)
A dramatic case: 50 AA, 0 Aa, 50 aa (N = 100). The sample is split between two homozygote classes with no heterozygotes whatsoever.
Input: AA = 50, Aa = 0, aa = 50 (N = 100) Allele frequencies: p = (100 + 0) / 200 = 0.5, q = 0.5 HWE expected counts: p²N = 25, 2pqN = 50, q²N = 25 χ² = 100.00, p-value ≈ 1.5 × 10⁻²², HWE rejected with extreme significance F = 1.00, the population has zero heterozygosity PIC = 0.375, the marker is still maximally informative by PIC
Such an extreme deficit is never seen in real random-mating populations, it would suggest the sample is from two different species, two different subspecies, or two different generations, or that Aa individuals are inviable (lethal heterozygote).
Example 4: A monomorphic locus
A pilot study finds 100 AA, 0 Aa, 0 aa (N = 100). The locus carries only one allele.
Input: AA = 100, Aa = 0, aa = 0 (N = 100) Allele frequencies: p = 1.0, q = 0.0 HWE expected counts: p²N = 100, 2pqN = 0, q²N = 0 χ² = 0, p-value = 1.0000, HWE is trivially satisfied (no information to reject it) F = N/A (H_exp = 0), inbreeding coefficient is undefined PIC = 0, the locus is monomorphic and uninformative
A monomorphic locus is useless for population-genetics studies, parentage analysis, or linkage mapping. It also fails the Hardy-Weinberg test vacuously (the data are perfectly consistent with HWE because there is no variation to deviate from it).
Example 5: A common allele with a rare variant (p = 0.89)
A pharmacogenomic study finds 80 AA (normal metabolizers), 18 Aa (intermediate), 2 aa (poor metabolizers) at a CYP locus (N = 100).
Input: AA = 80, Aa = 18, aa = 2 (N = 100) Allele frequencies: p = 0.89, q = 0.11 HWE expected counts: p²N = 79.21, 2pqN = 19.58, q²N = 1.21 χ² ≈ 0.65, p-value ≈ 0.42, HWE not rejected F ≈ 0.08, small heterozygote deficit, well within sampling noise PIC ≈ 0.18, low informativeness, typical for a marker with one common and one rare allele
A PIC below 0.25 is common for rare-variant loci, useful for some clinical applications but not informative enough for forensic identification or linkage mapping in small families.
Example 6: A heterozygote excess
A plant population shows 35 AA, 60 Aa, 5 aa (N = 100). Far more heterozygotes than expected under random mating.
Input: AA = 35, Aa = 60, aa = 5 (N = 100) Allele frequencies: p = 0.65, q = 0.35 HWE expected counts: p²N = 42.25, 2pqN = 45.50, q²N = 12.25 χ² ≈ 10.16, p-value ≈ 0.0014, HWE rejected at α = 0.05 F ≈ −0.32, substantial heterozygote excess PIC ≈ 0.351, moderately informative
A negative F (heterozygote excess) is rarer than a positive F in natural populations but does occur, it can be a signature of disassortative mating, overdominance (heterozygote advantage, as in sickle-cell trait), or recent admixture between differentiated subpopulations.
Where It Shows Up
- Population genetics, testing whether a sampled population is in Hardy-Weinberg equilibrium is the first analysis performed on any new genetic dataset. Significant deviation prompts further investigation (inbreeding, substructure, selection, null alleles).
- Conservation genetics, small, isolated populations of endangered species often show heterozygote deficits (positive F) due to inbreeding. The Allele Frequency Calculator is the standard first pass.
- Forensic DNA, population allele frequencies are tabulated for the CODIS and European Standard Set loci. The Hardy-Weinberg framework is the legal foundation for DNA match probabilities in court.
- Linkage mapping and GWAS, the PIC statistic was developed by Botstein et al. (1980) to choose markers for the first human genetic linkage map. Markers with PIC > 0.5 are highly informative for linkage, while PIC < 0.25 are uninformative.
- Pharmacogenomics, allele frequencies at CYP genes (CYP2D6, CYP2C19, CYP3A4) determine the probability of a poor metabolizer in a population. The Hardy-Weinberg framework predicts how many individuals of each phenotype to expect.
- Animal and plant breeding, HWE tests on breeding populations detect inbreeding depression, population substructure, and the effectiveness of selection. The inbreeding coefficient F directly informs mate-pair selection.
- Microbial and viral genetics, allele frequencies at drug-resistance loci (e.g., k13 mutations in malaria, reverse-transcriptase mutations in HIV) are tracked over time. Deviation from HWE can signal clonal expansion or selection.
- Ancient DNA and aDNA studies, authenticating ancient DNA samples by checking for Hardy-Weinberg consistency (degraded samples often show heterozygote deficits due to allelic dropout).
Common Mistakes
1. Confusing "Hardy-Weinberg" with "no evolution"
Hardy-Weinberg equilibrium is a null model that describes the genotype frequencies expected under random mating with no selection, no mutation, no migration, no drift, and infinite population size. Failing to reject HWE does not prove a population is "not evolving", it just means the data are consistent with the null. Significant HWE deviations can be caused by any of the five forces (selection, mutation, migration, drift, non-random mating) or by genotyping error.
2. Using df = 3 instead of df = 1
For a 3-class chi-square test with three observed and three expected counts, the "naive" degrees of freedom is 3 − 1 = 2 (after the constraint Σpᵢ = 1). But the HWE test estimates one extra parameter (p) from the data, so the conventional df is 3 − 1 − 1 = 1. Always use df = 1 for the standard HWE goodness-of-fit test; using df = 2 is overly conservative and under-rejects HWE.
3. Treating a "not rejected" result as proof of equilibrium
A non-significant p-value (p > 0.05) means the data are consistent with HWE, not that the population is in HWE. With small samples (N < 30) the test has very low power: you can't reject HWE even when the true deviation is substantial. Always report the χ² statistic alongside the p-value, and consider the effect size (the F coefficient) and not just the significance test.
4. Computing p and q as if from one allele each
The correct gene-counting formula is p = (2·AA + Aa) / (2·N), not p = (AA + Aa) / (2·N) or p = AA / (AA + Aa). The AA class contributes two A alleles per individual, the Aa class contributes one A allele, and the aa class contributes zero. Off-by-a-factor-of-two errors are common in hand calculations and lead to allele frequencies between 0.5 and 1.0 even when p = q = 0.5 in a balanced sample.
5. Reporting PIC for a multiallelic locus with the biallelic formula
The expression PIC = 1 − p² − q² − 2p²q² is for a biallelic locus (two alleles). For multiallelic markers (microsatellites, HLA, multiallelic SNPs), use the full Botstein et al. formula: PIC = 1 − Σ pᵢ² − Σᵢ Σⱼ₌ᵢ₊₁ 2pᵢ²pⱼ². The biallelic formula underestimates PIC for loci with more than two alleles.
6. Ignoring expected-count assumptions
The chi-square approximation is unreliable when any expected count is below 5. For small samples (N < 50) or rare genotypes, consider Fisher's exact test, simulation-based p-values, or pooling genotype classes. The calculator flags N < 5 with a warning but still produces a result.
7. Using F as a percentage
Wright's F is a unitless coefficient bounded by −1 and +1 (theoretical limits are wider in small samples). It is not a percentage. F = 0.1 does NOT mean "10% inbred", it means the observed heterozygosity is 10% lower than the HWE expectation. Report F as a decimal (e.g., 0.31) or with a clear symbol (e.g., F = 0.31), never as a percentage.
8. Confusing q² with the disease allele frequency
For autosomal recessive diseases (cystic fibrosis, sickle cell, Tay-Sachs), the disease allele frequency is q, but the disease frequency is q² (under HWE). The "1 in 2500" frequency of CF is q² ≈ 0.0004, which means q ≈ 0.02, which means the carrier frequency is 2pq ≈ 0.04 (1 in 25). Conflating q and q² is the most common error in clinical-genetics teaching.
Frequently Asked Questions
What is the difference between allele frequency and genotype frequency? An allele frequency (p, q) is the proportion of all alleles in the population that are of a given type. A genotype frequency (f(AA), f(Aa), f(aa)) is the proportion of all individuals with a given genotype. The two are related by the gene-counting formula p = (2·AA + Aa) / (2N), which counts the two A alleles in each AA individual plus the one A allele in each Aa individual, divided by the total number of alleles (2N).
What is Hardy-Weinberg equilibrium? Hardy-Weinberg equilibrium (HWE) is the genotype-frequency distribution expected under random mating in an ideal population: AA = p², Aa = 2pq, aa = q². The distribution is reached in a single generation of random mating, regardless of the starting genotype frequencies, and is stable across generations in the absence of selection, mutation, migration, drift, or non-random mating. HWE was independently derived by G. H. Hardy (1908) and Wilhelm Weinberg (1908).
How is the chi-square goodness-of-fit test performed? The observed counts (AA, Aa, aa) are compared to the HWE expected counts (p²N, 2pqN, q²N) using Pearson's chi-square statistic: χ² = Σ (O − E)² / E, summed over the three genotype classes. With 1 degree of freedom (3 classes minus 1 constraint minus 1 estimated parameter), the χ² statistic is compared to the chi-square distribution; the p-value is the probability of observing a χ² value at least this large by chance alone.
What does the inbreeding coefficient F mean? F = 1 − H_obs / H_exp measures the proportional deficit (or excess) of heterozygotes relative to the Hardy-Weinberg expectation. F = 0 means the population is in HWE. F > 0 (positive F) means there are fewer heterozygotes than expected, a signature of inbreeding, population substructure, or null alleles. F < 0 (negative F) means there are more heterozygotes than expected, a signature of disassortative mating, overdominance, or recent admixture.
What is the polymorphism information content (PIC)? PIC is a measure of how informative a genetic marker is for linkage analysis, originally developed by Botstein, White, Skolnick, and Davis in 1980 for the first human genetic linkage map. For a biallelic locus, PIC = 1 − p² − q² − 2p²q². A marker is considered "highly informative" if PIC > 0.5, "moderately informative" if 0.25 < PIC < 0.5, and "low informativeness" if PIC < 0.25. Monomorphic loci (p = 0 or p = 1) have PIC = 0.
What does a negative F value mean? A negative F (heterozygote excess) means the population has more heterozygotes than Hardy-Weinberg predicts. This is rarer than a positive F in natural populations but does occur. Causes include disassortative mating (preference for unlike partners), overdominance (heterozygote advantage, as in sickle-cell trait or HLA immune diversity), recent admixture between two differentiated subpopulations, or genotyping error (e.g., calling a true homozygote as a heterozygote).
What is the right sample size for a Hardy-Weinberg test? A common rule of thumb is N ≥ 50 for the chi-square approximation to be valid (all expected counts above 5). For formal statistical testing, simulation studies suggest N ≥ 30 is acceptable if no expected count is below 1, and N ≥ 100 is preferred for stable results. For very small samples (N < 30), use Fisher's exact test or exact HWE tests based on the multinomial distribution rather than the chi-square approximation.
What if one of the genotype counts is zero? A zero count is valid input, the locus is monomorphic or hemizygous for that class. The calculator handles all zeros correctly: p and q are still well-defined (e.g., AA = 100, Aa = 0, aa = 0 gives p = 1, q = 0), the χ² is well-defined (it is exactly 0 for a monomorphic locus because observed and expected counts are identical), and the F coefficient is reported as N/A when H_exp = 0. PIC is 0 for a monomorphic locus.
What is the difference between p and q? By convention, p is the frequency of the major allele (the more common one) and q is the frequency of the minor allele. They always sum to 1 (p + q = 1) under a biallelic model. In the calculator, A is the "reference" allele and a is the "alternate" allele, but this naming is symmetric, so flipping A ↔ a gives identical results for all derived statistics (χ², F, PIC) except the labels.
Can I use this calculator for HLA or other multiallelic loci? The simple biallelic model used here applies to markers with exactly two alleles. For multiallelic loci (HLA-DRB1, microsatellites, multiallelic SNP panels), use a multiallele extension: estimate each pᵢ by gene-counting, compute HWE expected counts from the multinomial (p₁ + p₂ + ... + pₖ)² expansion, and use the full Botstein et al. PIC formula with a sum over all alleles. The biallelic PIC underestimates true PIC for multiallelic markers.
**Q:**Can the Allele Frequency Calculator be used for professional or commercial purposes?A: Yes, the Allele Frequency Calculator provides mathematically correct results that are suitable for professional, commercial, and educational use. For the Allele Frequency Calculator, For the Allele Frequency Calculator, For high-stakes applications (medical, legal, financial), verify results with a domain expert. For the Allele Frequency Calculator, the Allele Frequency Calculator formulas used are well-established and validated against reference standards.
**Q:**For the Allele Frequency Calculator, How often are the underlying formulas updated?A: the Allele Frequency Calculator formulas are based on established scientific, mathematical, or industry-standard references and rarely require updates. When standards change (e.g., new physical constants, revised tax brackets, updated standards), the Allele Frequency Calculator is updated to reflect the current authoritative source. For the Allele Frequency Calculator, For the Allele Frequency Calculator, Each calculator's references section lists the specific sources used.
References
- Hardy, G. H. (1908), "Mendelian proportions in a mixed population." Science 28(706): 49 to 50. The original derivation of the Hardy-Weinberg principle (published simultaneously and independently by Weinberg).
- Weinberg, W. (1908), "Über den Nachweis der Vererbung beim Menschen." Jahreshefte des Vereins für vaterländische Naturkunde in Württemberg 64: 368 to 382. The independent co-discovery.
- Wright, S. (1922), "Coefficients of inbreeding and relationship." Genetics 6(2): 167 to 178. The original definition of the inbreeding coefficient F.
- Botstein, D., White, R. L., Skolnick, M., Davis, R. W. (1980), "Construction of a genetic linkage map in man using restriction fragment length polymorphisms." American Journal of Human Genetics 32(3): 314 to 331. The original definition of polymorphism information content.
- Hedrick, P. W. (2011), Genetics of Populations, 4th edition, Jones & Bartlett. The standard reference for population-genetics methods including HWE testing and F-statistics.
- Press, W. H., Teukolsky, S. A., Vetterling, W. T., Flannery, B. P. (1992), Numerical Recipes in C: The Art of Scientific Computing, 2nd edition, Cambridge University Press, §6.2 (chi-square CDF via the regularized incomplete gamma function). The numerical algorithm used in this calculator.
- Wigginton, J. E., Cutler, D. J., Abecasis, G. R. (2005), "A note on exact tests of Hardy-Weinberg equilibrium." American Journal of Human Genetics 76(5): 887 to 893. The reference for exact HWE testing, which this calculator approximates with the chi-square distribution.
- Weir, B. S. (1996), Genetic Data Analysis II, Sinauer Associates. A comprehensive treatment of population-genetic data analysis methods.
- Lewis, C. M. (2002), "Genetic association studies: design, analysis and interpretation." Briefings in Bioinformatics 3(2): 146 to 153. A practical guide to interpreting HWE tests in association studies.
Also try these free tools:
- Hardy-Weinberg Equilibrium Calculator, focused HWE p-value calculator
- Shannon Diversity Index, ecological / allele-frequency diversity
- Ecology Biodiversity Index, multi-locus diversity
- Margin of Error Calculator, confidence intervals for the allele-frequency estimates
- Chi-Square Statistic Calculator, standalone chi-square p-value
- Mean, Median, Mode Calculator, descriptive statistics for sample summaries