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

Allele Frequency Calculator

Free allele frequency calculator — gene-count p and q from observed AA, Aa and aa counts. Autosomal or X-linked, with a heterozygosity check.

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
Proportion of all scored gene copies that are the first allele (A), obtained by gene counting: every AA individual contributes two A copies, every Aa contributes one, and in X-linked mode every hemizygous A contributes one. Dimensionless, between 0 and 1. No equilibrium assumption is involved — this is arithmetic on your observed counts.
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.

This allele frequency calculator turns counts you can actually collect — how many individuals in your sample are AA, how many are Aa, how many are aa — into the two allele frequencies p and q, using the gene-counting method. It then does the thing that makes the exercise worth doing: it compares the heterozygosity you observed against the heterozygosity Hardy-Weinberg would predict at those same allele frequencies, and tells you which way the sample departs.

The counting logic is simple enough to do on paper, and it is worth understanding rather than trusting. At an autosomal locus every individual carries exactly two copies of the gene, so a sample of N individuals contains 2N gene copies in total. Each AA individual contributes two A copies. Each Aa individual contributes one A and one a. Each aa individual contributes two a copies. So p is the total number of A copies divided by 2N. With 100 AA, 80 Aa and 20 aa individuals, that is p = (2 × 100 + 80) ÷ 400 = 280 ÷ 400 = 0.7, and correspondingly q = (2 × 20 + 80) ÷ 400 = 120 ÷ 400 = 0.3. The two must sum to 1, and if they do not you have miscounted.

What separates this page from a Hardy-Weinberg calculator is that **nothing here is assumed**. Gene counting is arithmetic on your data. It works in an inbred population, in a population under strong selection, in a population that is really two populations pooled together by accident, and in a population whose genotyping assay is dropping one allele. Allele frequencies are always computable from genotype counts. The Hardy-Weinberg expectation is a separate, much stronger claim, and this calculator prints it as a clearly labelled benchmark rather than as a result. In the example above the expected heterozygosity is He = 2pq = 2 × 0.7 × 0.3 = 0.42, while the observed heterozygosity is Ho = 80 ÷ 200 = 0.40 — 80 heterozygotes where 84 were expected. The deficiency ratio (He − Ho) ÷ He = 0.02 ÷ 0.42 = 0.0476 is positive, which by the sign convention of Holsinger and Weir means a deficiency of heterozygotes.

Interpreting that number is where care is needed, and the caveat belongs here rather than buried below. A positive value is consistent with inbreeding, with assortative mating, and with the Wahlund effect — the artefact you get when two subpopulations with different allele frequencies are analysed as one. But in modern genotyping data, a heterozygote deficiency at a single marker is more often a **technical** failure than a biological signal: allele dropout, a poorly performing probe, or a null allele will all manufacture missing heterozygotes. This is exactly why quality-control pipelines test every marker against Hardy-Weinberg and discard the outliers before any biological interpretation is attempted. A second caveat: the ratio this page prints is the descriptive within-sample quantity. It is what Wright's F_IS estimates, but it is not the Weir and Cockerham (1984) estimator, which corrects for sample size and will differ in a small sample. Do not report this number as F_IS in a publication.

The X-linked mode exists because the denominator changes. Individuals with two X chromosomes carry two copies of an X-linked locus and can be homozygous or heterozygous; hemizygous individuals carry a single copy and are neither. A sample of 100 two-X and 100 hemizygous individuals therefore contains 2 × 100 + 100 = 300 gene copies, not 400. Observed heterozygosity is computed over the two-X individuals only, since a hemizygote has nothing to be heterozygous with. This is also the structural reason an X-linked recessive trait shows up so much more often in the hemizygous sex: its frequency there is q, not q².

Below the calculator you will find the full gene-counting derivation for both ploidies, an independent worked check against a US Department of Justice forensic-genetics training example, the exact conditions under which the deficiency ratio is zero, the domain edges where the calculation is refused rather than faked, and a discussion of what to do when your sample turns out to be monomorphic.

What is allele frequency calculator?

An allele frequency is the proportion of all copies of a gene, at one locus, in one sample, that are a particular allele. It is a property of a population or a sample, not of an individual — an individual has a genotype, a population has allele frequencies. Because it is a proportion of gene copies rather than of individuals, the denominator is the number of gene copies, which for an autosomal locus is twice the number of individuals. The National Institute of Justice's training for forensic analysts describes the method plainly: allele frequencies are obtained by counting up all of the alleles, remembering that each individual carries two alleles and that heterozygous individuals carry one of each. That is the whole method, and it goes by the name 'gene counting'. There is an equivalent route that some textbooks prefer: p equals the frequency of the homozygous class plus half the frequency of the heterozygous class, p = f(AA) + ½f(Aa). It gives the identical answer, because half of the heterozygotes' gene copies are A. Two other quantities on this page need defining. Observed heterozygosity, Ho, is simply the fraction of two-copy individuals that are heterozygous — 80 out of 200 gives Ho = 0.40. Expected heterozygosity, He, is 2pq, the fraction that would be heterozygous if the genotypes were in Hardy-Weinberg proportions at the observed allele frequencies — 2 × 0.7 × 0.3 = 0.42. The two are different kinds of number: Ho is data, He is a model prediction. Their relative difference, (He − Ho) ÷ He, is the standard summary of how far the sample sits from the Hardy-Weinberg benchmark. Holsinger and Weir describe the corresponding statistic as a measure of the frequency of heterozygotes compared with that expected when genotypes are in Hardy-Weinberg proportions, and state the sign convention this page uses: positive values indicate a deficiency of heterozygotes, negative values an excess.

How to use this calculator.

  1. Choose autosomal or X-linked. Autosomal is the default and covers every locus not on a sex chromosome — pick it unless you are specifically working on the X.
  2. Enter the number of individuals in each genotype class as whole numbers. Fractional counts are rejected, because you cannot observe a fraction of a person; if your data are already proportions rather than counts, multiply them by your sample size first.
  3. In X-linked mode, put only the two-X individuals in the AA, Aa and aa boxes, and put the one-X individuals in the two hemizygous boxes. The hemizygous boxes are ignored completely in autosomal mode, so you can leave whatever is in them.
  4. Read p and q, then check that they add to 1. They always will unless a count was mistyped.
  5. Compare observed heterozygosity with expected heterozygosity. If they are close, the sample is consistent with Hardy-Weinberg at this locus; if they are far apart, the deficiency ratio tells you the direction and rough size of the departure.
  6. Before you interpret a departure biologically, rule out the boring explanations: a mistyped count, two populations pooled by mistake, or — in genotyping data — allele dropout or a null allele at that specific marker.
  7. If you need a formal test rather than a descriptive ratio, take the observed counts to the genetics chi-square calculator and run the Hardy-Weinberg goodness-of-fit mode, which uses one degree of freedom because p was estimated from the same data.

The formula.

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

Gene counting is exactly what its name says. Build the numerator by counting copies of the allele of interest: an AA individual holds two of them, an Aa individual holds one, an aa individual holds none, and an individual hemizygous for A holds one. Build the denominator by counting every gene copy in the sample the same way. Divide. For autosomal data the denominator collapses to 2N because every individual contributes two copies, giving p = (2·n(AA) + n(Aa)) ÷ 2N and q = (2·n(aa) + n(Aa)) ÷ 2N. Adding these two expressions gives (2·n(AA) + 2·n(Aa) + 2·n(aa)) ÷ 2N = 2N ÷ 2N = 1, so p + q = 1 is an identity rather than a constraint you have to impose.

The X-linked denominator is where mistakes get made. Individuals with two X chromosomes contribute two copies each; hemizygous individuals contribute one. The total is 2·N₂ₓ + N₁ₓ, not 2·(N₂ₓ + N₁ₓ). With 100 two-X and 100 hemizygous individuals that is 300 gene copies, and using 400 instead would shift every frequency. Observed heterozygosity is computed over N₂ₓ alone, because a hemizygote carries a single allele and cannot be heterozygous. In the worked X-linked fixture — 35 AA, 50 Aa, 15 aa two-X individuals plus 60 A and 40 a hemizygotes — p = (70 + 50 + 60) ÷ 300 = 0.6, q = (30 + 50 + 40) ÷ 300 = 0.4, Ho = 50 ÷ 100 = 0.5, He = 2 × 0.6 × 0.4 = 0.48, and the deficiency ratio is (0.48 − 0.50) ÷ 0.48 = −0.0417, a heterozygote excess.

ROUNDING STAGE — FINAL ONLY. Every count, sum, division and ratio is carried in arbitrary-precision decimal arithmetic; each returned number is rounded exactly once, to ten decimal places, at the moment it is returned. The interpretation sentence re-renders the deficiency ratio at four decimal places from the unrounded value, so the words and the number beside them can never disagree.

The only branch on this page is the sign of the deficiency ratio, and it is decided by an exact comparison of Ho against He rather than against a tolerance. That makes the boundary reproducible: a sample of 98 AA, 84 Aa and 18 aa gives p = 0.7 and Ho = He = 0.42 exactly, so the ratio is exactly 0 and the page says the observation matches the expectation. Moving one individual from a homozygous class into the heterozygous class (97 / 86 / 17) holds p at 0.7 and flips the sign negative; moving one the other way (99 / 82 / 19) flips it positive. All three cases are asserted in the test suite.

Four situations are refused rather than answered. A negative count, a fractional count, and an empty sample are all data-entry errors. The fourth is subtler: a monomorphic sample, in which every gene copy is the same allele. There, He = 2pq = 0, and the deficiency ratio becomes 0 ÷ 0. Returning 0 would look like 'a perfect match to Hardy-Weinberg', which is exactly the wrong reading — the truth is that a locus with only one allele present has no heterozygosity to compare, and p = 1 with q = 0 is already the complete answer. In X-linked mode a sample containing no two-X individuals is refused for the same reason: observed heterozygosity would be 0 ÷ 0.

A worked example.

Example

You genotype 200 individuals at one autosomal locus and find 100 AA, 80 Aa and 20 aa. What are the allele frequencies, and is the sample consistent with Hardy-Weinberg? Start with the denominator: 200 individuals × 2 copies each = 400 gene copies. Now count A copies. The 100 AA individuals hold 2 × 100 = 200 of them. The 80 heterozygotes hold one each, adding 80. The aa individuals hold none. So there are 280 A copies out of 400, giving p = 280 ÷ 400 = 0.7. Counting a copies the same way: 2 × 20 = 40 from the aa individuals plus 80 from the heterozygotes = 120 copies, so q = 120 ÷ 400 = 0.3. The two sum to 1.0, as they must. Now the comparison. Observed heterozygosity is the raw fact: 80 heterozygotes out of 200 individuals, Ho = 0.40. Expected heterozygosity is the model's prediction at these same allele frequencies: He = 2pq = 2 × 0.7 × 0.3 = 0.42. In head-count terms the model expected 0.42 × 200 = 84 heterozygotes and you found 80. The relative shortfall is (0.42 − 0.40) ÷ 0.42 = 0.02 ÷ 0.42 = 0.0476, positive, which the page reads as a heterozygote deficiency. Is a shortfall of four individuals out of 200 worth interpreting? On its own, no — this is a descriptive ratio, not a significance test, and a departure this small in a sample this size is well inside what chance alone produces. The honest next step is a formal goodness-of-fit test on the counts. But the direction is worth noting even so, because a heterozygote deficiency has a short list of usual suspects: inbreeding, assortative mating, two subpopulations pooled by mistake (the Wahlund effect), or — if these are genotyping calls rather than phenotypes — allele dropout at that marker. The last of those is by far the most common cause in real genotyping data, and it is a technical fault rather than anything about the population. As an independent check that the gene counting is right, feed in the published figures from the US National Institute of Justice's forensic-genetics training, which analyses a sample of 5,000 individuals with 1,496 MM, 2,478 MN and 1,026 NN. Gene counting gives p = (2 × 1,496 + 2,478) ÷ 10,000 = 5,470 ÷ 10,000 = 0.547 and q = (2 × 1,026 + 2,478) ÷ 10,000 = 4,530 ÷ 10,000 = 0.453 — matching the frequencies that training publishes, to every digit it quotes, from a completely separate authority.

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

Frequently asked questions.

How do you calculate allele frequency from genotype counts?
Count gene copies, not people. At an autosomal locus each individual carries two copies, so a sample of N individuals contains 2N copies. Each AA individual contributes two A copies, each Aa contributes one, each aa contributes none. Divide the A copies by 2N to get p, and the a copies by 2N to get q. With 100 AA, 80 Aa and 20 aa: p = (2×100 + 80) ÷ 400 = 0.7 and q = (2×20 + 80) ÷ 400 = 0.3. The identical answer comes from the shortcut p = f(AA) + ½f(Aa) = 0.5 + 0.2 = 0.7, because half of a heterozygote's copies are A. Nothing in this calculation assumes Hardy-Weinberg equilibrium, random mating, or anything else about the population — it is arithmetic on the counts you observed.
What is the difference between this and a Hardy-Weinberg calculator?
The direction of travel and the assumptions. A Hardy-Weinberg calculator starts from one frequency and ASSUMES equilibrium in order to generate the genotype frequencies you would expect. This calculator starts from genotype counts you actually observed and computes the allele frequencies with no assumption at all. The two meet at a single point: this page prints the Hardy-Weinberg expected heterozygosity 2pq next to your observed heterozygosity so you can see the gap. If you have counts, start here. If you have one frequency and a textbook problem, start at the Hardy-Weinberg calculator. If you want a formal significance test on the gap rather than a descriptive ratio, use the genetics chi-square calculator.
Why is the X-linked denominator not just twice the sample size?
Because hemizygous individuals carry one copy of an X-linked locus, not two. A sample of 100 two-X individuals and 100 hemizygous individuals contains 2 × 100 + 100 = 300 gene copies, not 400. Using 400 would understate every frequency by a quarter. The same asymmetry means observed heterozygosity must be computed over the two-X individuals alone: a hemizygote has a single allele and cannot be heterozygous, so including them in the denominator would drag Ho down artificially. This is also the structural explanation for the most familiar fact about X-linked recessive traits — that they appear far more often in the hemizygous sex. A hemizygote expresses the recessive allele whenever it is present, at frequency q, whereas a two-X individual needs two copies, at frequency q².
What does a positive heterozygote deficiency actually mean?
Mechanically, it means you observed fewer heterozygotes than 2pq predicts. The sign convention follows Holsinger and Weir: positive values indicate a deficiency of heterozygotes, negative values an excess. Biologically, a deficiency is consistent with inbreeding, with mating that is assortative for this locus, and with the Wahlund effect — two subpopulations with different allele frequencies analysed as though they were one, which manufactures a heterozygote shortfall even when each subpopulation is individually in equilibrium. Technically, and in practice more often, it is a genotyping artefact: allele dropout, a null allele, or a probe that fails on one allele will all remove heterozygotes from the call set. Quality-control pipelines test every marker for exactly this reason and discard the outliers before drawing any biological conclusion.
Is this number the same as Wright's F_IS?
It is the descriptive quantity that F_IS estimates, but it is not an F_IS estimate in the sense a journal would expect. (He − Ho) ÷ He is a ratio of two numbers computed from your sample. Weir and Cockerham's 1984 estimator applies a correction for finite sample size and for the way allele frequencies are themselves estimated, and it gives a materially different value in small samples. Teaching material routinely calls the simple ratio 'F_IS', which is why this page names it 'heterozygote deficiency' instead and says plainly what it is. Use the simple ratio to see the direction and rough size of a departure; use a package implementing the Weir and Cockerham estimator if the number is going into a publication.
What happens if every individual in my sample has the same genotype?
The calculator refuses, and explains why. If only one allele is present then p = 1 and q = 0, so the expected heterozygosity 2pq is zero and the deficiency ratio becomes 0 ÷ 0. Returning 0 would read as 'a perfect match to Hardy-Weinberg', which is the opposite of the truth: a monomorphic locus has no heterozygosity to compare, and the departure statistic is undefined rather than zero. The complete answer in that case is simply that the locus is fixed for one allele in your sample. This is a real result — it is what you see at the overwhelming majority of positions in a genome — but it is not a Hardy-Weinberg comparison. The same refusal applies in X-linked mode when the sample contains no two-X individuals, because observed heterozygosity would then be 0 ÷ 0.
How precise are the allele frequencies from a small sample?
Less precise than the ten digits the calculator carries internally, which is why the display shows four. The precision of p is governed by the number of gene copies, not by the arithmetic: a sample of 200 individuals gives 400 gene copies and supports roughly three significant figures at best; a sample of 20 individuals gives 40 copies and supports barely two. The standard error of an allele frequency estimate is approximately the square root of pq divided by the number of gene copies, so at p = 0.7 with 400 copies it is about 0.023 — meaning the third digit is already noise. Report p as 0.70, not 0.7000000000. The counts themselves are exact; it is the inference from sample to population that is uncertain.
Can this handle a locus with more than two alleles?
No. The page is built for exactly two alleles, which is the case for a biallelic SNP and for the classic textbook problems, and the expected heterozygosity 2pq is the two-allele expression. For a locus with k alleles the same gene-counting logic still applies to each allele in turn — count copies of that allele, divide by the total gene copies — but the expected heterozygosity becomes 1 minus the sum of the squared allele frequencies, and there are k(k−1)/2 distinct heterozygous genotypes rather than one. Highly polymorphic markers such as microsatellites and HLA loci fall into that category, and forcing them into a two-allele form by pooling alleles will change every number on this page.

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.

In this category

Embed

Quanta Pro

Paid features are coming later.

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