Home Calculators Categories Category: Science & Engineering

Allele Frequency Calculator

This allele frequency calculator turns observed genotype data from one sample into the shares of two alleles, A and a, at a single diploid locus. Enter counts of AA, Aa and aa individuals, or enter genotype percentages, and it returns the allele frequencies pp and qq. In percentage mode it also sets your observed genotype shares beside the Hardy–Weinberg expectations for the same allele frequencies.

Input

Use one diploid locus with two alleles. Enter 0 for a genotype absent from the sample.

Two copies of A per individual.
One copy of A and one copy of a per individual.
Two copies of a per individual.
Replace the current inputs with a sample containing only Aa individuals.
Visual
Allele and genotype proportions Allele A is 65%. Allele a is 35%. A (p) 65% a (q) 35%
Output
Allele A (p)
65%
Allele a (q)
35%

How to use the allele frequency calculator

The calculator has two modes. Both describe the same kind of data: one sample, one locus, two allele types, and two allele copies per individual.

Simple mode (the starting mode) asks for three whole numbers:

  • AA count
  • Aa count
  • aa count

Each field accepts a whole number from 0 to 1,000,000,000, and at least one individual must be entered across the three fields. The defaults are 50, 30 and 20 individuals.

Advanced mode asks for the observed percentage of each genotype:

  • AA percentage
  • Aa percentage
  • aa percentage

Each field accepts a value from 0 to 100 in steps of 0.01 percentage point, and the three must total 99.99%, 100% or 100.01%. The defaults are 50%, 30% and 20%. Enter 30 for an observed proportion of 0.30, not 0.30.

A few practical points:

  • Enter 0 for a genotype that is absent from the sample. Do not leave the field empty.
  • Use all three genotype shares from the same sample. Mixing counts or percentages from different groups gives a number that describes neither.
  • Results update as you type. Each mode keeps its own inputs when you switch between them.
  • In Advanced mode, typing a percentage changes only that field. If the other two fields contain valid percentages, moving a slider redistributes the remaining share in proportion to their existing values (or as evenly as possible if both are zero). The calculator rounds to hundredths of a percentage point and keeps the total at 100%. If either field is blank or invalid, moving the slider leaves both other fields as they are.
  • Load example fills the active mode with an all-heterozygote sample (All individuals are Aa: 0, 100, 0). Reset restores the defaults in both modes and returns to Simple mode.
  • Copy saves the calculation summary to your clipboard, and Export opens your browser's print dialog.
  • If an input is invalid, the tool shows an error and em dashes in the result fields. Typical causes are a missing or malformed value, a number outside the field limits, all-zero counts in Simple mode, or percentages that don't total about 100%.

The results show Allele A (p) and Allele a (q) as percentages, with a stacked bar showing the split. Advanced mode adds a Genotype frequencies table with Observed and Expected columns and paired bars on a common 0–100% scale.

What the calculator measures

An allele is one version of a gene or genetic marker. At a diploid locus, each individual carries two copies, so a sample of NN individuals contains 2N2N allele copies. The allele frequency of A is the fraction of those copies that are A. The same is true for a.

You will also see this called gene frequency, and searches such as "calculating gene frequency" usually mean the same thing: the share of a particular variant in a sample. A locus is a location in the genome, and an allele is a version of the DNA sequence at that location. Allele frequency is the more precise term. This calculator finds the observed shares of A and a.

Two things are worth stating plainly:

  • The calculation does not depend on dominance or phenotype. It works on genotypes. It doesn't matter whether A is dominant, or which allele is more common.
  • Direct allele counting makes no Hardy–Weinberg assumption. The values pp and qq are exactly what is observed in your sample. Hardy–Weinberg only enters when you ask what genotype proportions those allele frequencies would predict.

By convention, pp is the proportion of A and qq the proportion of a, so p+q=1p+q=1 exactly.

Allele frequency formula from genotype counts

Let nAAn_{AA}, nAan_{Aa} and naan_{aa} be the numbers of individuals with each genotype, and let

N=nAA+nAa+naa.N=n_{AA}+n_{Aa}+n_{aa}.

An AA individual contributes two A copies, an Aa individual contributes one A and one a, and an aa individual contributes two a copies. Counting copies gives the allele frequency formula:

p=2nAA+nAa2N,q=2naa+nAa2Np=\frac{2n_{AA}+n_{Aa}}{2N},\qquad q=\frac{2n_{aa}+n_{Aa}}{2N}

The numerators are the total counts of A and a copies. The shared denominator, 2N2N, is the total number of copies. Because the two numerators add up to 2N2N, the two frequencies always sum to 1. This is the same formula people look for under "gene frequency formula": the share of a variant is its copies divided by all copies.

Multiply a proportion by 100 to express it as a percentage.

Allele frequency calculation example

Suppose a sample has 50 AA, 30 Aa and 20 aa individuals. This is the calculator's default Simple input.

  1. Count the individuals: N=50+30+20=100N=50+30+20=100.
  2. Count all allele copies: 2N=2002N=200.
  3. Count A copies: 2×50+30=1302\times 50+30=130.
  4. Count a copies: 2×20+30=702\times 20+30=70.
  5. Divide by the total: p=130/200=0.65p=130/200=0.65 and q=70/200=0.35q=70/200=0.35.

The calculator reports 65% for Allele A (p) and 35% for Allele a (q). You can check the work with a quick sum: 130+70=200130+70=200.

A second example with unequal homozygotes: 12 AA, 36 Aa and 52 aa. Here N=100N=100 and 2N=2002N=200. The A copies number 2(12)+36=602(12)+36=60 and the a copies number 2(52)+36=1402(52)+36=140, so p=0.30p=0.30 and q=0.70q=0.70.

Calculate allele frequency from genotype frequency

Sometimes you have genotype proportions rather than counts, for example from a published table. Let fAAf_{AA}, fAaf_{Aa} and faaf_{aa} be the observed genotype proportions. Each AA individual is entirely A, and each Aa individual is half A, so:

p=fAA+fAa2,q=faa+fAa2p=f_{AA}+\frac{f_{Aa}}{2},\qquad q=f_{aa}+\frac{f_{Aa}}{2}

This is the answer to "allele frequency from genotype frequency": add the homozygote's whole share to half of the heterozygote share.

Using the default Advanced input of 50%, 30% and 20%:

p=0.50+0.302=0.65,q=0.20+0.302=0.35p=0.50+\frac{0.30}{2}=0.65,\qquad q=0.20+\frac{0.30}{2}=0.35

This matches the counts example, as it should, because 50, 30 and 20 individuals out of 100 are the same proportions.

How Advanced mode handles percentages that don't total 100

Rounded percentages often fall just short of or just over 100. Advanced mode accepts totals of 99.99%, 100% and 100.01%. Writing the entered percentages as xAAx_{AA}, xAax_{Aa} and xaax_{aa}, it computes the actual total

S=xAA+xAa+xaaS=x_{AA}+x_{Aa}+x_{aa}

and normalizes each genotype as fg=xg/Sf_g=x_g/S. It uses the actual total, so 99.99 or 100.01 is not silently treated as 100. When the rounded total is 99.99% or 100.01%, the calculator shows the advisory The genotype percentages were scaled to total 100%.

For example, 33.33%, 33.33%, 33.33% is accepted. The total is 99.99, each normalized proportion is exactly one-third, and

p=13+16=12,p=\frac{1}{3}+\frac{1}{6}=\frac{1}{2},

so the allele shares are 50% and 50%.

If your data come as counts, Simple mode is usually the better choice. It avoids the rounding that comes from converting counts to percentages first.

Hardy–Weinberg calculation: expected genotype frequencies

Once you have pp and qq, you can ask what genotype proportions would occur if the two allele copies in each individual were paired at random. That gives the Hardy–Weinberg formula:

p2,2pq,q2p^2,\qquad 2pq,\qquad q^2

for AA, Aa and aa respectively. These three sum to (p+q)2=1(p+q)^2=1.

The factor of 2 in 2pq2pq appears because an Aa individual can arise in two ways: A from one parent and a from the other, or the reverse. The two orders of pairing unlike alleles each have probability pqpq.

For the default Advanced input, p=0.65p=0.65 and q=0.35q=0.35:

  • Expected AA: 0.652=0.42250.65^2=0.4225, or 42.25%
  • Expected Aa: 2(0.65)(0.35)=0.4552(0.65)(0.35)=0.455, or 45.5%
  • Expected aa: 0.352=0.12250.35^2=0.1225, or 12.25%

The observed genotype shares were 50%, 30% and 20%. Observed Aa is lower than expected, and both homozygotes are higher.

How the calculator uses Hardy–Weinberg

In Advanced mode, the Genotype frequencies table lists observed and expected percentages in the order AA, Aa, aa, with paired bars on the same 0–100% scale. Three details matter:

  • The expected values are calculated from the unrounded pp and qq, not from the displayed rounded percentages.
  • The comparison is descriptive. The calculator does not show a difference column, expected counts, a chi-square statistic, a p-value or a verdict about equilibrium.
  • A visible gap does not by itself show that a sample departs from Hardy–Weinberg equilibrium. Sampling variation can produce gaps, especially in small samples.

If you need a formal test, compute expected counts (Np2N p^2, 2Npq2Npq and Nq2Nq^2) and compare them with observed counts using a goodness-of-fit test. This calculator supplies pp and qq for that purpose but doesn't run the test.

What Hardy–Weinberg expectations assume

The expected proportions describe an idealized population: random pairing of alleles with respect to this locus, no selection on it, no mutation or migration changing allele frequencies, and a large enough population that chance changes are negligible. Real populations often depart from these conditions, and departures from the expected genotype shares can be informative. They can also come from sampling error or genotyping problems. Treat the comparison as a starting point for questions, not as an answer.

Calculate allele frequencies in the 5th generation

A common homework or lab question asks you to calculate allele frequencies in the fifth generation. The method is the same for any generation. Take the genotype counts or percentages observed in that generation, then apply the formulas above.

The calculator has no field for the generation number. To compare generations, run each generation's own observed data separately and compare the results.

If a problem gives you only starting frequencies and asks you to predict generation five, that requires a population-genetics model with stated assumptions, which this tool does not provide. If the problem instead gives genotype data collected in generation five, enter it here.

Edge cases and checks

Sample Allele result Advanced comparison
All Aa (0, 100, 0) 50% A, 50% a 100% observed Aa, 50% expected Aa
All AA 100% A, 0% a 100% expected AA
All aa 0% A, 100% a 100% expected aa
33.33, 33.33, 33.33 50% and 50% 25%, 50%, 25% expected

The all-Aa case is a useful reminder that allele frequencies and genotype frequencies are different things. Every individual is heterozygous, yet the two alleles are equally common.

Display precision. Values are shown with up to four decimal places. A positive share smaller than 0.0001% displays as <0.0001%, and a share above 99.9999% but below 100% displays as >99.9999%. Exact endpoints display as 0% and 100%.

Limits of this calculator

The tool is deliberately narrow so that its output is unambiguous. It handles:

  • one sample at one diploid locus with two alleles, labeled A and a
  • observed genotype counts or percentages as input

It does not handle:

  • loci with three or more alleles
  • phenotype data, such as counting dominant and recessive individuals, where heterozygotes can't be seen directly
  • sequencing reads or pooled data
  • generation-by-generation projections
  • confidence intervals, significance tests or equilibrium verdicts

The result describes the sample you enter. If the sample is a small subset of a larger population, the true population frequencies may differ, and the calculator does not quantify that uncertainty.

Frequently asked questions

How do you calculate allele frequency from genotype counts?

Count the copies of each allele, then divide by the total number of copies. For A, that is 2nAA+nAa2N\frac{2n_{AA}+n_{Aa}}{2N}. For a, it is 2naa+nAa2N\frac{2n_{aa}+n_{Aa}}{2N}.

What is the allele frequency formula if I have percentages?

Add the homozygote's proportion to half the heterozygote proportion. For A, p=fAA+fAa/2p=f_{AA}+f_{Aa}/2. To get the genotype proportions, divide each entered percentage by the actual total of the three entries (99.99, 100, or 100.01).

Do p and q always add up to 1?

Yes. Every allele copy in the sample is either A or a, so the two frequencies sum to exactly 1, or 100%. Displayed values may differ from 100% in the last decimal place only because of display rounding.

Is allele frequency the same as genotype frequency?

No. Allele frequency counts individual allele copies, while genotype frequency counts individuals with a given pair of alleles. The two are linked by the formulas above, and Hardy–Weinberg expectations connect them under random pairing.

Does the calculator tell me whether my sample is in Hardy–Weinberg equilibrium?

No. It shows observed and expected genotype percentages side by side but does not test the difference. A formal goodness-of-fit test is needed for that.

Does it matter which allele I call A?

No. The labels are interchangeable. Swapping them swaps pp and qq and the matching genotype shares, and nothing else changes.

Can I use it for a dominant trait?

Only if you know the genotypes. The calculator works from genotype data. If you only have phenotype counts, you cannot count allele copies directly without an extra assumption, and this tool does not make one.

Calculation Methodology Documented

Read the formula definitions, supported input ranges, and limitations before using this estimate.

Review Methodology
Debjeet Bhowmick
Author Debjeet Bhowmick AWS Certified Solutions Architect • Cloud & DevOps Consultant

AWS Certified Solutions Architect Professional and Senior Cloud & DevOps Consultant with over 14 years of hands-on expertise architecting resilient cloud infrastructure across AWS, GCP, and Azure. Specializes in infrastructure as code, continuous delivery automation, and telemetry across Terraform, Ansible, Docker, Kubernetes, ELK, Python, and SQL. Creator of OrangeCalc, delivering client-side high-precision computational tools.