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
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.
- 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.
- 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.
- 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.
- Read p and q, then check that they add to 1. They always will unless a count was mistyped.
- 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.
- 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.
- 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.
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.
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.
Frequently asked questions.
How do you calculate allele frequency from genotype counts?
What is the difference between this and a Hardy-Weinberg calculator?
Why is the X-linked denominator not just twice the sample size?
What does a positive heterozygote deficiency actually mean?
Is this number the same as Wright's F_IS?
What happens if every individual in my sample has the same genotype?
How precise are the allele frequencies from a small sample?
Can this handle a locus with more than two alleles?
References& sources.
- [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]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]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]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]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]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