Audited 29 Jul 2026·Last updated 28 Oct 2026·6 citations·Tier 1·0 uses

Allele Frequency Calculator

Count allele frequencies p and q from observed AA, Aa and aa genotype counts, autosomal or X-linked, and compare observed with expected heterozygosity.

Allele Frequency Calculator

Type of locus
Number of individuals homozygous for the first allele. In X-linked mode count only the two-X individuals with genotype X^A X^A. Whole numbers only.
individuals
Number of heterozygotes. In X-linked mode count only the two-X individuals with genotype X^A X^a — hemizygous individuals cannot be heterozygous.
individuals
Number of individuals homozygous for the second allele. In X-linked mode count only the two-X individuals with genotype X^a X^a.
individuals
Number of one-X individuals carrying the A allele (genotype X^A Y). Ignored entirely in autosomal mode.
individuals
Number of one-X individuals carrying the a allele (genotype X^a Y). These are the individuals who express an X-linked recessive trait at frequency q rather than q². Ignored in autosomal mode.
individuals
Allele frequency p
0.7
p, the share of all scored gene copies that are allele A, from 0 to 1, found by counting copies rather than assuming equilibrium.
Allele frequency q
0.3
Gene copies scored
400 copies
Individuals scored
200 individuals
Observed heterozygosity (Ho)
0.4
Expected heterozygosity (He = 2pq)
0.42
Heterozygote deficiency, (He − Ho) ÷ He
0.0476
Reading
Heterozygote deficiency: fewer heterozygotes than Hardy–Weinberg predicts (F = +0.0476).

Background.

Suppose 200 people have been genotyped at one SNP and the calls come back as 100 AA, 80 Aa and 20 aa. How common is the a allele in that group? Not 20 in 200. Allele frequency counts gene copies, not people: each person carries two copies, so there are 400 copies in the sample, and a accounts for 2 × 20 + 80 = 120 of them. Its frequency is 0.3.

That gene-counting method makes one demand: every genotype must be visible. It suits DNA genotyping, codominant blood groups such as MN, and any marker where a heterozygote can be told apart from both homozygotes. It cannot be used for a trait with complete dominance, where AA and Aa look the same; there the allele frequency has to be inferred from the recessive phenotype by assuming Hardy–Weinberg equilibrium, which is what the Hardy–Weinberg calculator does. When counting is possible, it assumes nothing about the population at all — not random mating, not a large size, not the absence of selection.

Because the counts are real data, they can be held up against the model. Expected heterozygosity, 2pq, is the share of heterozygotes Hardy–Weinberg proportions would give at the frequencies you just counted: 0.42 for the sample above, against 0.40 observed. The relative gap, (He − Ho) ÷ He, is reported with its direction — positive when heterozygotes are missing, negative when there are too many.

A gap of 0.0476 in 200 people is well within chance. Larger ones have a short list of explanations. Inbreeding and assortative mating thin out heterozygotes, and so does pooling two groups whose allele frequencies differ. In laboratory data the commonest cause is technical: an allele that fails to amplify turns true heterozygotes into apparent homozygotes.

For X-linked loci a separate mode counts hemizygous individuals as carrying one copy, which changes the denominator and confines the heterozygosity comparison to individuals with two X chromosomes.

What is allele frequency calculator?

An allele frequency is the share of all copies of a gene at one locus, in one sample, that are a particular allele. It describes a group, not a person: an individual has a genotype, while a population or sample has allele frequencies. With two alleles the frequencies p and q always add to 1, and p can be written either as copies counted over copies scored or as f(AA) + ½ f(Aa) — the homozygote share plus half the heterozygote share, since half a heterozygote's copies are A. In genomics the smaller of the two is called the minor allele frequency.

Two heterozygosity figures sit alongside. Observed heterozygosity, Ho, is the share of two-copy individuals who are actually heterozygous. Expected heterozygosity, He = 2pq, is the share that Hardy–Weinberg proportions predict at the observed allele frequencies; the US National Research Council's forensic DNA report describes it as twice the product of the two frequencies. Ho is an observation and He a model prediction. Their relative difference, (He − Ho) ÷ He, is the within-sample quantity that Wright's inbreeding coefficient F_IS describes, and following Holsinger and Weir a positive value indicates a deficiency of heterozygotes and a negative value an excess.

How to use this calculator.

  1. Choose the type of locus: Autosomal for any gene not on a sex chromosome, X-linked for genes on the X.
  2. Enter the number of individuals in each genotype class as whole numbers. If your data are proportions, multiply by the sample size first. Which allele you call A is arbitrary — a SNP's reference allele, M in the MN system — but keep the labelling consistent; swapping it swaps p and q and changes nothing else.
  3. In X-linked mode, put individuals with two X chromosomes in the AA, Aa and aa boxes and one-X individuals in the two hemizygous boxes. In autosomal mode the hemizygous boxes are ignored.
  4. Score each individual once. A duplicated sample, or several members of one family, adds extra copies of whatever genotypes they share and skews both p and the heterozygosity comparison.
  5. Read p and q, then compare observed with expected heterozygosity. For a formal test at a two-allele locus, the chi-square statistic equals the number of individuals times F squared; compare it with 3.841, the 5% critical value on one degree of freedom.

The formula.

p = (2·n(AA) + n(Aa) + n(A hemi)) ⁄ (2·N₂ₓ + N₁ₓ)

Gene counting builds a numerator and a denominator from the same rule. An AA individual holds two A copies, an Aa individual one, an aa individual none, and a hemizygous A individual one. Every gene copy in the sample goes into the denominator.

Autosomal: p = (2·n(AA) + n(Aa)) ÷ 2N and q = (2·n(aa) + n(Aa)) ÷ 2N, where N is the number of individuals. Add the two and the numerator becomes 2N, so p + q = 1 is guaranteed by the arithmetic rather than imposed.

X-linked: p = (2·n(AA) + n(Aa) + n(A hemi)) ÷ (2·N₂ₓ + N₁ₓ), where N₂ₓ counts individuals with two X chromosomes and N₁ₓ hemizygous individuals. A common error is to use twice the total head-count; with 100 of each type that gives 400 copies instead of 300 and understates every frequency.

Observed heterozygosity is n(Aa) ÷ N₂ₓ — in autosomal mode N₂ₓ is simply N. Hemizygous individuals are left out because a single copy cannot be heterozygous. Expected heterozygosity is 2pq using the pooled allele frequencies, which presumes the frequency is the same in both sexes; at an X-linked locus where it differs, the comparison mixes the two.

The departure is F = (He − Ho) ÷ He. For a two-allele locus it links directly to the usual goodness-of-fit test: the chi-square statistic comparing observed counts with p²N, 2pqN and q²N equals N × F², tested on one degree of freedom because p was estimated from the same counts. F here is the plain descriptive ratio, not the sample-size-corrected estimator of Weir and Cockerham (1984), which differs noticeably in small samples.

Some samples cannot give an answer and are refused: negative or fractional counts, a sample with nobody in it, an X-linked sample with no two-X individuals (Ho would be 0 ÷ 0), and a monomorphic sample in which every copy is the same allele. In the last case He is zero and F would be 0 ÷ 0; frequencies of 1 and 0 are the complete answer.

A worked example.

Example

Take the sample of 200 people at an autosomal SNP: 100 AA, 80 Aa and 20 aa. Gene copies: 200 × 2 = 400. A copies: 2 × 100 from the AA group plus 80 from the heterozygotes = 280, so p = 280 ÷ 400 = 0.7. a copies: 2 × 20 + 80 = 120, so q = 120 ÷ 400 = 0.3. The two add to 1. Observed heterozygosity is 80 ÷ 200 = 0.4. Expected heterozygosity at these frequencies is 2 × 0.7 × 0.3 = 0.42, which in head-count terms is 84 heterozygotes against the 80 found. The relative shortfall is (0.42 − 0.40) ÷ 0.42 = 0.0476, positive, so the reading is a heterozygote deficiency with F = +0.0476. Is that shortfall meaningful? The chi-square statistic is 200 × 0.0476² = 0.454 on one degree of freedom, far below the 3.841 needed for significance at 5%. Four missing heterozygotes in 200 people is the sort of gap sampling alone produces, and these counts are consistent with Hardy–Weinberg proportions.

hemizygous Recessive Count40
hemizygous Dominant Count60
homozygous Dominant Count100
data Typeautosomal
heterozygous Count80
homozygous Recessive Count20

Frequently asked questions.

Why isn't the a allele frequency just the number of aa people divided by the sample size?
Because that measures a genotype, not an allele. In the sample of 100 AA, 80 Aa and 20 aa, 20 ÷ 200 = 0.1 is the frequency of the aa genotype. The a allele also sits inside every heterozygote, and each aa person carries two copies, so the allele frequency is (2 × 20 + 80) ÷ 400 = 0.3. Counting people instead of copies understates a recessive allele badly.
Can I count alleles for a trait where AA and Aa look the same?
No. Gene counting needs every genotype identified, and with complete dominance the heterozygotes hide among the dominant phenotype. The usual workaround is to take the square root of the recessive phenotype's frequency, which estimates q only if the population is in Hardy–Weinberg equilibrium. That inference is what the Hardy–Weinberg calculator does; this tool is for genotype data, where nothing needs assuming.
Is there a published example I can check the method against?
The US National Institute of Justice's forensic training describes a sample of 5,000 people from 'Forensic Town' with 1,460 MM, 2,550 MN and 990 NN. Gene counting gives p = (2 × 1,460 + 2,550) ÷ 10,000 = 0.547 and q = 0.453, the frequencies the training reports. The same counts give Ho = 0.51 against He = 0.4956, F = −0.0291, a slight heterozygote excess, and a chi-square of about 4.23.
How does the X-linked mode change the numbers?
Take 35 AA, 50 Aa and 15 aa individuals with two X chromosomes plus 60 hemizygous A and 40 hemizygous a. Gene copies are 2 × 100 + 100 = 300, so p = (70 + 50 + 60) ÷ 300 = 0.6 and q = 0.4. Ho uses only the 100 two-X individuals: 50 ÷ 100 = 0.5, against He = 0.48, giving F = −0.0417. Hemizygotes show a recessive X-linked trait at frequency q, not q².
What produces a heterozygote deficiency?
Pooling is a classic cause. Two groups each in perfect equilibrium — one with 81 AA, 18 Aa, 1 aa (p = 0.9), the other with 1, 18, 81 (p = 0.1) — give F = 0 separately but F = +0.64 when entered together, the Wahlund effect. Inbreeding and assortative mating do the same. So does allele dropout: 110 AA, 60 Aa, 30 aa still gives p = 0.7 but F = +0.2857 and a chi-square near 16.3.
What does a negative value, a heterozygote excess, point to?
More heterozygotes than 2pq predicts. Biological causes include selection favouring heterozygotes at that locus, avoidance of mating between similar genotypes, and samples descended from few parents whose allele frequencies differed. Technical causes are common too: duplicated stretches of genome can make a marker call nearly everyone heterozygous. The extreme case, a sample of 50 heterozygotes and no homozygotes, gives F = −1.
Can I report the deficiency ratio as F_IS in a paper?
Not without saying what it is. (He − Ho) ÷ He is the descriptive ratio computed from one sample. The estimator widely used in population-genetics software, from Weir and Cockerham (1984), corrects for sample size and for the fact that allele frequencies were themselves estimated, and the two diverge in small samples. Use this ratio to see the direction and rough size of a departure, and a dedicated package for published estimates.
How many individuals do I need for a reliable allele frequency?
Precision depends on the number of gene copies. The standard error of p is roughly the square root of pq divided by the number of copies: at p = 0.7, about 0.023 with 200 individuals (400 copies) and about 0.072 with 20. A sample of 20 with counts 10, 8 and 2 gives exactly the same p and F as the 200-person example, but its chi-square is only 0.045, so it can detect almost nothing.
What about markers with more than two alleles?
The counting logic carries over: for each allele, count its copies and divide by all copies scored. Expected heterozygosity becomes 1 minus the sum of the squared allele frequencies, and k alleles give k(k − 1) ÷ 2 different heterozygous genotypes instead of one. Microsatellites and HLA genes fall into this category. Pooling their alleles into two groups to fit a two-allele form changes every number, including the heterozygosity comparison.
Why is a sample where everyone is AA rejected?
Because the comparison has nothing to work with. If every gene copy is A, then p = 1, q = 0 and expected heterozygosity is zero, so the departure ratio is 0 ÷ 0. Showing 0 would wrongly suggest a perfect fit to Hardy–Weinberg. The locus is simply fixed in your sample, which is a valid finding in its own right; most positions in a genome look like that.

References& sources.

  1. [1]National Institute of Justice (US Department of Justice). Population Genetics and Statistics for Forensic Analysts, module 'Population Theory — Hardy-Weinberg Principle'. Source for the gene-counting method as stated for practitioners, and for the independent 'Forensic Town, USA' worked example (n = 5,000; p = 0.547, q = 0.453; expected genotype counts 1,496 / 2,478 / 1,026) used as this page's independent cross-check. Independent, free, US Department of Justice; retrieved 2026-07-29.
  2. [2]Holsinger, K. E. & Weir, B. S. (2009). Genetics in geographically structured populations: defining, estimating and interpreting F_ST. Nature Reviews Genetics 10(9):639–650, doi:10.1038/nrg2611. PMC4687486. Source for the sign convention used by the interpretation line: f is a measure of the frequency of heterozygotes compared with that expected under Hardy-Weinberg proportions, and positive values indicate a deficiency of heterozygotes while negative values indicate an excess. Independent, free via PubMed Central; retrieved 2026-07-29.
  3. [3]National Research Council (US) Committee on DNA Forensic Science (1996). The Evaluation of Forensic DNA Evidence, Chapter 4, section 'Random Mating and Hardy-Weinberg Proportions'. National Academies Press; NCBI Bookshelf NBK232608. Source for the expected-heterozygosity benchmark: the proportion of persons with two different alleles is twice the product of the two frequencies. Independent, free, US National Academies; retrieved 2026-07-29.
  4. [4]Weir, B. S. & Cockerham, C. C. (1984). Estimating F-statistics for the analysis of population structure. Evolution 38(6):1358–1370. Cited to mark the boundary of what this page reports: the sample-size-corrected F_IS estimator defined here is NOT the simple (He − Ho)/He ratio this calculator prints, and the two differ in small samples. Independent; paywalled at the publisher and JSTOR — bibliographic reference only, no figure on this page depends on it; checked 2026-07-29.
  5. [5]Hardy, G. H. (1908). Mendelian proportions in a mixed population. Science 28(706):49–50. Free archival reprint in the Yale Journal of Biology and Medicine 76(2):79–80 (2003). The origin of the 2pq expectation this page uses as its benchmark. Independent, free, archival scan; retrieved 2026-07-29.
  6. [6]Ogino, S. & Wilson, R. B. (2004). Bayesian analysis and risk assessment in genetic counseling and testing. Journal of Molecular Diagnostics 6(1):1–9. PMC1867463. Source for the relationship between an allele frequency q and the derived carrier frequency 2(1 − q)q under Hardy-Weinberg equilibrium, which is where an allele frequency computed on this page is most often used next. Independent, free full text; retrieved 2026-07-29.

How this page was produced

Published by
Quanta Calculator
Primary sources
6 cited below
Method
p = (2·n(AA) + n(Aa) + n(A hemi)) ⁄ (2·N₂ₓ + N₁ₓ)
Published
Last verified

Built with AI assistance and verified by automated tests against the cited sources — every worked example on this page is computed by the same code that runs the calculator. How we build and check calculators.

In this category

Embed

Quanta Pro

Paid features are coming later.

  • All 1560 calculators remain free
  • No billing is enabled
Coming soon