ForHosting KIT · Science

Allele frequency calculator

Count genotypes, get allele frequencies: 320 AA, 160 Aa and 20 aa individuals hold 1000 gene copies, so p is 0.8 and q is 0.2, adding to one. Negative or all-zero counts are refused. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Homozygous dominant
320
Heterozygous
160
Homozygous recessive
20
You get
Total individuals
500
Total alleles
1,000
Dominant allele count
800
Recessive allele count
200

An allele frequency calculator turns counts of homozygous dominant, heterozygous, and homozygous recessive individuals into the two allele frequencies of a diploid two-allele locus. In the usual classroom notation those frequencies are p for the dominant allele and q for the recessive allele, and they always add to one because every gene copy is one allele or the other. Enter the three genotype counts from a population sample. The tool tallies two copies from each homozygote and one copy of each allele from each heterozygote, divides by twice the sample size, and returns p, q, and the supporting allele counts.

What allele frequency is and how p and q are counted from genotypes

Allele frequency is the share of gene copies at a locus that carry a given allele. For a diploid two-allele locus every individual contributes two copies: a homozygous dominant individual contributes two dominant alleles, a homozygous recessive individual contributes two recessive alleles, and a heterozygote contributes one of each. If AA, Aa, and aa are the three genotype counts and N is their sum, the sample holds 2N gene copies.

The dominant frequency is therefore p equals (2 times AA plus Aa) divided by 2N, and the recessive frequency is q equals (2 times aa plus Aa) divided by 2N. Those two identities are not an extra assumption: they are a census of the alleles you already scored. They also force p plus q to equal one, which is why a result that does not add to one is a sign that a count was dropped or a phenotype table was mistaken for a genotype table.

This calculator is restricted to observed genotype counts. It does not invert a recessive phenotype frequency under Hardy–Weinberg to guess q as the square root of the aa fraction, and it does not test whether the sample matches p squared, 2pq, and q squared. Those are different search intents: one estimates an unseen split, the other is a goodness-of-fit test.

Here the three classes are already separated, so the only arithmetic is the weighted count of alleles. A worked classroom case is 320 AA, 160 Aa, and 20 aa: N is 500, there are 1,000 gene copies, 800 of them are dominant, and the frequencies are p equals 0.8 and q equals 0.2. Another textbook split of 16, 48, and 36 in a sample of 100 yields p equals 0.4 and q equals 0.6.

Zero is a legal count for a missing class, but all three zeros are rejected because a frequency is undefined when nobody was counted.

Classroom p and q checks

Students submit AA, Aa, and aa counts from a lab sample and compare the returned 0.8 / 0.2 or 0.4 / 0.6 split against a hand tally before a write-up.

Population and conservation worksheets

Field notes that already score the three genotypes get a reproducible allele census without opening a population-genetics package for one locus.

Why do the two frequencies always add to one?

Every gene copy at a two-allele locus is either the dominant or the recessive allele.

What happens if a genotype count is negative?

A frequency is not defined for a negative census.

Can I send only the recessive homozygotes and assume Hardy–Weinberg?

No. This calculator needs all three genotype counts. Estimating q as the square root of the aa fraction is a different method and is not applied here.

How do I calculate allele frequency from genotype counts?

Count two copies for each homozygote and one of each allele for each heterozygote, then divide by twice the number of individuals. With 320, 160 and 20 individuals, p is 0.8 and q is 0.2.

Why divide by twice the sample size?

Each diploid individual carries two copies of the gene, so 500 individuals hold 1000 copies. Dividing the allele counts by that total turns them into shares of all gene copies in the sample.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/bio/allele-frequency

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/bio/allele-frequency \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"homozygous_dominant":320,"heterozygous":160,"homozygous_recessive":20}'
{
  "homozygous_dominant": 320,
  "heterozygous": 160,
  "homozygous_recessive": 20
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "bio.allele_frequency",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_count1000000000000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Input contract, response shape, and error behaviour

A sample whose three counts sum to zero is also rejected, because dividing by 2N is undefined. Those failures are not billed. POST a JSON body with three required non-negative finite numbers: homozygous_dominant (aliases AA, n_AA, dominant_homozygous, homo_dominant), heterozygous (aliases Aa, n_Aa, hetero, heterozygotes), and homozygous_recessive (aliases aa, n_aa, recessive_homozygous, homo_recessive). Each value may arrive as a JSON number or as a numeric string. Missing fields, empty strings, non-finite values, values above one trillion, and any negative count fail with invalid_input naming the field. On success the body echoes the three cleaned counts, publishes total_individuals as N and total_alleles as 2N, reports dominant_allele_count and recessive_allele_count as the numerator of each frequency, and returns dominant_allele_frequency (p) and recessive_allele_frequency (q). frequency_sum is always 1: after the two raw shares are computed they are normalized and q is taken as the complement of rounded p so the published pair never drifts by a unit in the last place. formula restates the identities p equals (2·AA + Aa) / 2N and q equals (2·aa + Aa) / 2N. Example: homozygous_dominant 320, heterozygous 160, homozygous_recessive 20 yields total_individuals 500, total_alleles 1000, dominant_allele_count 800, recessive_allele_count 200, dominant_allele_frequency 0.8, recessive_allele_frequency 0.2, and frequency_sum 1. A count of minus one in any field is invalid_input. Pair these frequencies with your own Hardy–Weinberg or chi-square step if you still need expected genotype shares; this endpoint solves the allele census only.

Where an allele frequency calculator earns its keep

Biology classrooms and tutoring platforms use an allele frequency calculator so learners stop treating the recessive phenotype fraction as q, or averaging three genotype percentages as if they were alleles. Population-genetics worksheets and conservation surveys need a deterministic oracle that rejects a negative paste instead of silently publishing a frequency greater than one. Failed validation does not consume balance. Related searches for a Punnett square, a chi-square degrees-of-freedom step, or a Hardy–Weinberg expected-genotype table are different intents: stay on this page when the question is only the allele frequencies implied by the counts you already have. Breeding notes, blood-group teaching modules, and intro lab reports all reduce to the same three-count census at one locus; calling a tiny parse API records p and q without standing up a pedigree or coalescent engine. Exam-prep generators and student coding katas pin 0.8 / 0.2 and 0.4 / 0.6 plus the invalid_input path for a negative count so a buggy grader cannot accept a result that does not add to one. Keep the three genotype counts honest, pin dominant_allele_frequency and recessive_allele_frequency in tests, and you get reproducible pairs that sum to one for homework, LMS plugins, and field notebooks.

Exam oracles and grading fixtures

Generators and student solvers pin expected frequencies that sum to one and invalid_input cases for a negative or all-zero count.

How do I calculate allele frequency from genotype counts?

Send homozygous_dominant (AA), heterozygous (Aa), and homozygous_recessive (aa). The API returns dominant_allele_frequency p = (2·AA + Aa) / 2N and recessive_allele_frequency q = (2·aa + Aa) / 2N, with frequency_sum equal to 1.

What does the allele frequency calculator cost?

The browser tool is free. API requests use prepaid balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →