Allele Frequency Calculator

This professional-grade allele frequency calculator helps students, educators, and researchers compute allele frequencies (p and q), expected genotype frequencies under Hardy–Weinberg equilibrium (HWE), heterozygosity, minor allele frequency (MAF), a chi-square HWE test (when genotype counts are provided), and 95% confidence intervals — all with WCAG-compliant, mobile-first UX.

Interactive Calculator

Choose input mode

Results

Sample size (N)
Allele frequency p (A)
Allele frequency q (a)
Minor allele frequency (MAF)
Expected genotypes (HWE): AA, Aa, aa
Observed genotypes: AA, Aa, aa
Heterozygosity (2pq)
95% CI for p (Wilson)
HWE chi-square (df=1), p-value
Interpretation Provide genotype counts to test HWE.

Note: HWE test is computed only when observed genotype counts are provided and N > 0 with valid expected counts.

Data Source and Methodology

Authoritative sources:

All calculations are strictly based on the formulas and data provided by these sources.

The Formula Explained

If AA, Aa, aa are genotype counts and N = AA + Aa + aa:

Allele frequencies: $$p = \\frac{2\\,AA + Aa}{2N}, \\quad q = 1 - p$$

Hardy–Weinberg expected genotype frequencies: $$P(AA) = p^2,\\quad P(Aa) = 2pq,\\quad P(aa) = q^2$$

Expected counts: $$E[AA] = N p^2,\\quad E[Aa] = N (2pq),\\quad E[aa] = N q^2$$

Heterozygosity: $$H = 2pq$$

Goodness-of-fit statistic (chi-square): $$\\chi^2 = \\sum_{g\\in\\{AA,Aa,aa\\}} \\frac{(O_g - E_g)^2}{E_g} \\quad \\text{with 1 degree of freedom}$$

For df = 1, the p-value is: $$p\\text{-value} = \\operatorname{erfc}\\!\\left(\\sqrt{\\chi^2/2}\\right)$$

Wilson 95% CI for p using k A-alleles in n = 2N trials: $$\\hat{p}_W = \\frac{\\hat{p} + z^2/(2n)}{1 + z^2/n},\\quad \\text{margin} = \\frac{z}{1+z^2/n}\\sqrt{\\frac{\\hat{p}(1-\\hat{p})}{n} + \\frac{z^2}{4n^2}}$$

Glossary of Variables

How It Works: A Step-by-Step Example

Suppose you observed AA = 36, Aa = 48, aa = 16 (N = 100). Then:

  1. Compute p: p = (2×36 + 48) / (2×100) = 0.60; q = 0.40.
  2. Expected genotype frequencies: AA = p^2 = 0.36, Aa = 2pq = 0.48, aa = q^2 = 0.16.
  3. Expected counts: E[AA] = 36, E[Aa] = 48, E[aa] = 16.
  4. HWE test: χ² = Σ (O−E)²/E = 0; p-value = 1 → no evidence against HWE.
  5. MAF = min(0.60, 0.40) = 0.40; Heterozygosity = 2pq = 0.48. The 95% CI for p is computed using the Wilson method.

Frequently Asked Questions (FAQ)

What input should I use: genotype counts, allele counts, or p?

Use genotype counts to compute everything including an HWE test. If you only have allele counts, you can compute p and expected genotypes but not a valid HWE test. If you already know p and N, you can generate expected counts and heterozygosity.

When is the chi-square HWE test appropriate?

It is appropriate for bi-allelic loci with sufficiently large expected counts (common rule of thumb: all expected ≥ 5). For small samples or rare alleles, consider exact tests (e.g., Wigginton et al., 2005).

How is the 95% CI for p calculated?

We use a Wilson score interval treating the 2N chromosomes as binomial trials with k = 2×AA + Aa A-alleles.

Can I change allele labels?

This tool uses A and a for clarity. You can map them to your locus alleles (e.g., reference vs alternate).

Why do I get “even sum required” with allele counts?

In diploid organisms, the total number of alleles is 2×N. Therefore, A + a must be even to correspond to an integer number of individuals.

Is deviation from HWE always biologically meaningful?

No. Deviations can arise from technical issues (e.g., genotyping error) or sampling noise, not only from evolutionary forces. Always consider context and replicate data quality checks.


Audit: Complete
Formula (LaTeX) + variables + units
This section shows the formulas used by the calculator engine, plus variable definitions and units.
Formula (extracted LaTeX)
\[p = \\frac{2\\,AA + Aa}{2N}, \\quad q = 1 - p\]
p = \\frac{2\\,AA + Aa}{2N}, \\quad q = 1 - p
Formula (extracted LaTeX)
\[P(AA) = p^2,\\quad P(Aa) = 2pq,\\quad P(aa) = q^2\]
P(AA) = p^2,\\quad P(Aa) = 2pq,\\quad P(aa) = q^2
Formula (extracted LaTeX)
\[E[AA] = N p^2,\\quad E[Aa] = N (2pq),\\quad E[aa] = N q^2\]
E[AA] = N p^2,\\quad E[Aa] = N (2pq),\\quad E[aa] = N q^2
Formula (extracted LaTeX)
\[H = 2pq\]
H = 2pq
Formula (extracted LaTeX)
\[\\chi^2 = \\sum_{g\\in\\{AA,Aa,aa\\}} \\frac{(O_g - E_g)^2}{E_g} \\quad \\text{with 1 degree of freedom}\]
\\chi^2 = \\sum_{g\\in\\{AA,Aa,aa\\}} \\frac{(O_g - E_g)^2}{E_g} \\quad \\text{with 1 degree of freedom}
Formula (extracted LaTeX)
\[p\\text{-value} = \\operatorname{erfc}\\!\\left(\\sqrt{\\chi^2/2}\\right)\]
p\\text{-value} = \\operatorname{erfc}\\!\\left(\\sqrt{\\chi^2/2}\\right)
Formula (extracted text)
If AA, Aa, aa are genotype counts and N = AA + Aa + aa: Allele frequencies: $p = \\frac{2\\,AA + Aa}{2N}, \\quad q = 1 - p$ Hardy–Weinberg expected genotype frequencies: $P(AA) = p^2,\\quad P(Aa) = 2pq,\\quad P(aa) = q^2$ Expected counts: $E[AA] = N p^2,\\quad E[Aa] = N (2pq),\\quad E[aa] = N q^2$ Heterozygosity: $H = 2pq$ Goodness-of-fit statistic (chi-square): $\\chi^2 = \\sum_{g\\in\\{AA,Aa,aa\\}} \\frac{(O_g - E_g)^2}{E_g} \\quad \\text{with 1 degree of freedom}$ For df = 1, the p-value is: $p\\text{-value} = \\operatorname{erfc}\\!\\left(\\sqrt{\\chi^2/2}\\right)$ Wilson 95% CI for p using k A-alleles in n = 2N trials: $\\hat{p}_W = \\frac{\\hat{p} + z^2/(2n)}{1 + z^2/n},\\quad \\text{margin} = \\frac{z}{1+z^2/n}\\sqrt{\\frac{\\hat{p}(1-\\hat{p})}{n} + \\frac{z^2}{4n^2}}$
Variables and units
  • No variables provided in audit spec.
Sources (authoritative):
Changelog
Version: 0.1.0-draft
Last code update: 2026-01-19
0.1.0-draft · 2026-01-19
  • Initial audit spec draft generated from HTML extraction (review required).
  • Verify formulas match the calculator engine and convert any text-only formulas to LaTeX.
  • Confirm sources are authoritative and relevant to the calculator methodology.
Verified by Ugo Candido on 2026-01-19
Profile · LinkedIn
, '

Allele Frequency Calculator

This professional-grade allele frequency calculator helps students, educators, and researchers compute allele frequencies (p and q), expected genotype frequencies under Hardy–Weinberg equilibrium (HWE), heterozygosity, minor allele frequency (MAF), a chi-square HWE test (when genotype counts are provided), and 95% confidence intervals — all with WCAG-compliant, mobile-first UX.

Interactive Calculator

Choose input mode

Results

Sample size (N)
Allele frequency p (A)
Allele frequency q (a)
Minor allele frequency (MAF)
Expected genotypes (HWE): AA, Aa, aa
Observed genotypes: AA, Aa, aa
Heterozygosity (2pq)
95% CI for p (Wilson)
HWE chi-square (df=1), p-value
Interpretation Provide genotype counts to test HWE.

Note: HWE test is computed only when observed genotype counts are provided and N > 0 with valid expected counts.

Data Source and Methodology

Authoritative sources:

All calculations are strictly based on the formulas and data provided by these sources.

The Formula Explained

If AA, Aa, aa are genotype counts and N = AA + Aa + aa:

Allele frequencies: $$p = \\frac{2\\,AA + Aa}{2N}, \\quad q = 1 - p$$

Hardy–Weinberg expected genotype frequencies: $$P(AA) = p^2,\\quad P(Aa) = 2pq,\\quad P(aa) = q^2$$

Expected counts: $$E[AA] = N p^2,\\quad E[Aa] = N (2pq),\\quad E[aa] = N q^2$$

Heterozygosity: $$H = 2pq$$

Goodness-of-fit statistic (chi-square): $$\\chi^2 = \\sum_{g\\in\\{AA,Aa,aa\\}} \\frac{(O_g - E_g)^2}{E_g} \\quad \\text{with 1 degree of freedom}$$

For df = 1, the p-value is: $$p\\text{-value} = \\operatorname{erfc}\\!\\left(\\sqrt{\\chi^2/2}\\right)$$

Wilson 95% CI for p using k A-alleles in n = 2N trials: $$\\hat{p}_W = \\frac{\\hat{p} + z^2/(2n)}{1 + z^2/n},\\quad \\text{margin} = \\frac{z}{1+z^2/n}\\sqrt{\\frac{\\hat{p}(1-\\hat{p})}{n} + \\frac{z^2}{4n^2}}$$

Glossary of Variables

How It Works: A Step-by-Step Example

Suppose you observed AA = 36, Aa = 48, aa = 16 (N = 100). Then:

  1. Compute p: p = (2×36 + 48) / (2×100) = 0.60; q = 0.40.
  2. Expected genotype frequencies: AA = p^2 = 0.36, Aa = 2pq = 0.48, aa = q^2 = 0.16.
  3. Expected counts: E[AA] = 36, E[Aa] = 48, E[aa] = 16.
  4. HWE test: χ² = Σ (O−E)²/E = 0; p-value = 1 → no evidence against HWE.
  5. MAF = min(0.60, 0.40) = 0.40; Heterozygosity = 2pq = 0.48. The 95% CI for p is computed using the Wilson method.

Frequently Asked Questions (FAQ)

What input should I use: genotype counts, allele counts, or p?

Use genotype counts to compute everything including an HWE test. If you only have allele counts, you can compute p and expected genotypes but not a valid HWE test. If you already know p and N, you can generate expected counts and heterozygosity.

When is the chi-square HWE test appropriate?

It is appropriate for bi-allelic loci with sufficiently large expected counts (common rule of thumb: all expected ≥ 5). For small samples or rare alleles, consider exact tests (e.g., Wigginton et al., 2005).

How is the 95% CI for p calculated?

We use a Wilson score interval treating the 2N chromosomes as binomial trials with k = 2×AA + Aa A-alleles.

Can I change allele labels?

This tool uses A and a for clarity. You can map them to your locus alleles (e.g., reference vs alternate).

Why do I get “even sum required” with allele counts?

In diploid organisms, the total number of alleles is 2×N. Therefore, A + a must be even to correspond to an integer number of individuals.

Is deviation from HWE always biologically meaningful?

No. Deviations can arise from technical issues (e.g., genotyping error) or sampling noise, not only from evolutionary forces. Always consider context and replicate data quality checks.


Audit: Complete
Formula (LaTeX) + variables + units
This section shows the formulas used by the calculator engine, plus variable definitions and units.
Formula (extracted LaTeX)
\[p = \\frac{2\\,AA + Aa}{2N}, \\quad q = 1 - p\]
p = \\frac{2\\,AA + Aa}{2N}, \\quad q = 1 - p
Formula (extracted LaTeX)
\[P(AA) = p^2,\\quad P(Aa) = 2pq,\\quad P(aa) = q^2\]
P(AA) = p^2,\\quad P(Aa) = 2pq,\\quad P(aa) = q^2
Formula (extracted LaTeX)
\[E[AA] = N p^2,\\quad E[Aa] = N (2pq),\\quad E[aa] = N q^2\]
E[AA] = N p^2,\\quad E[Aa] = N (2pq),\\quad E[aa] = N q^2
Formula (extracted LaTeX)
\[H = 2pq\]
H = 2pq
Formula (extracted LaTeX)
\[\\chi^2 = \\sum_{g\\in\\{AA,Aa,aa\\}} \\frac{(O_g - E_g)^2}{E_g} \\quad \\text{with 1 degree of freedom}\]
\\chi^2 = \\sum_{g\\in\\{AA,Aa,aa\\}} \\frac{(O_g - E_g)^2}{E_g} \\quad \\text{with 1 degree of freedom}
Formula (extracted LaTeX)
\[p\\text{-value} = \\operatorname{erfc}\\!\\left(\\sqrt{\\chi^2/2}\\right)\]
p\\text{-value} = \\operatorname{erfc}\\!\\left(\\sqrt{\\chi^2/2}\\right)
Formula (extracted text)
If AA, Aa, aa are genotype counts and N = AA + Aa + aa: Allele frequencies: $p = \\frac{2\\,AA + Aa}{2N}, \\quad q = 1 - p$ Hardy–Weinberg expected genotype frequencies: $P(AA) = p^2,\\quad P(Aa) = 2pq,\\quad P(aa) = q^2$ Expected counts: $E[AA] = N p^2,\\quad E[Aa] = N (2pq),\\quad E[aa] = N q^2$ Heterozygosity: $H = 2pq$ Goodness-of-fit statistic (chi-square): $\\chi^2 = \\sum_{g\\in\\{AA,Aa,aa\\}} \\frac{(O_g - E_g)^2}{E_g} \\quad \\text{with 1 degree of freedom}$ For df = 1, the p-value is: $p\\text{-value} = \\operatorname{erfc}\\!\\left(\\sqrt{\\chi^2/2}\\right)$ Wilson 95% CI for p using k A-alleles in n = 2N trials: $\\hat{p}_W = \\frac{\\hat{p} + z^2/(2n)}{1 + z^2/n},\\quad \\text{margin} = \\frac{z}{1+z^2/n}\\sqrt{\\frac{\\hat{p}(1-\\hat{p})}{n} + \\frac{z^2}{4n^2}}$
Variables and units
  • No variables provided in audit spec.
Sources (authoritative):
Changelog
Version: 0.1.0-draft
Last code update: 2026-01-19
0.1.0-draft · 2026-01-19
  • Initial audit spec draft generated from HTML extraction (review required).
  • Verify formulas match the calculator engine and convert any text-only formulas to LaTeX.
  • Confirm sources are authoritative and relevant to the calculator methodology.
Verified by Ugo Candido on 2026-01-19
Profile · LinkedIn
]], displayMath: [['\\[','\\]']] }, svg: { fontCache: 'global' } };

Allele Frequency Calculator

This professional-grade allele frequency calculator helps students, educators, and researchers compute allele frequencies (p and q), expected genotype frequencies under Hardy–Weinberg equilibrium (HWE), heterozygosity, minor allele frequency (MAF), a chi-square HWE test (when genotype counts are provided), and 95% confidence intervals — all with WCAG-compliant, mobile-first UX.

Interactive Calculator

Choose input mode

Results

Sample size (N)
Allele frequency p (A)
Allele frequency q (a)
Minor allele frequency (MAF)
Expected genotypes (HWE): AA, Aa, aa
Observed genotypes: AA, Aa, aa
Heterozygosity (2pq)
95% CI for p (Wilson)
HWE chi-square (df=1), p-value
Interpretation Provide genotype counts to test HWE.

Note: HWE test is computed only when observed genotype counts are provided and N > 0 with valid expected counts.

Data Source and Methodology

Authoritative sources:

All calculations are strictly based on the formulas and data provided by these sources.

The Formula Explained

If AA, Aa, aa are genotype counts and N = AA + Aa + aa:

Allele frequencies: $$p = \\frac{2\\,AA + Aa}{2N}, \\quad q = 1 - p$$

Hardy–Weinberg expected genotype frequencies: $$P(AA) = p^2,\\quad P(Aa) = 2pq,\\quad P(aa) = q^2$$

Expected counts: $$E[AA] = N p^2,\\quad E[Aa] = N (2pq),\\quad E[aa] = N q^2$$

Heterozygosity: $$H = 2pq$$

Goodness-of-fit statistic (chi-square): $$\\chi^2 = \\sum_{g\\in\\{AA,Aa,aa\\}} \\frac{(O_g - E_g)^2}{E_g} \\quad \\text{with 1 degree of freedom}$$

For df = 1, the p-value is: $$p\\text{-value} = \\operatorname{erfc}\\!\\left(\\sqrt{\\chi^2/2}\\right)$$

Wilson 95% CI for p using k A-alleles in n = 2N trials: $$\\hat{p}_W = \\frac{\\hat{p} + z^2/(2n)}{1 + z^2/n},\\quad \\text{margin} = \\frac{z}{1+z^2/n}\\sqrt{\\frac{\\hat{p}(1-\\hat{p})}{n} + \\frac{z^2}{4n^2}}$$

Glossary of Variables

How It Works: A Step-by-Step Example

Suppose you observed AA = 36, Aa = 48, aa = 16 (N = 100). Then:

  1. Compute p: p = (2×36 + 48) / (2×100) = 0.60; q = 0.40.
  2. Expected genotype frequencies: AA = p^2 = 0.36, Aa = 2pq = 0.48, aa = q^2 = 0.16.
  3. Expected counts: E[AA] = 36, E[Aa] = 48, E[aa] = 16.
  4. HWE test: χ² = Σ (O−E)²/E = 0; p-value = 1 → no evidence against HWE.
  5. MAF = min(0.60, 0.40) = 0.40; Heterozygosity = 2pq = 0.48. The 95% CI for p is computed using the Wilson method.

Frequently Asked Questions (FAQ)

What input should I use: genotype counts, allele counts, or p?

Use genotype counts to compute everything including an HWE test. If you only have allele counts, you can compute p and expected genotypes but not a valid HWE test. If you already know p and N, you can generate expected counts and heterozygosity.

When is the chi-square HWE test appropriate?

It is appropriate for bi-allelic loci with sufficiently large expected counts (common rule of thumb: all expected ≥ 5). For small samples or rare alleles, consider exact tests (e.g., Wigginton et al., 2005).

How is the 95% CI for p calculated?

We use a Wilson score interval treating the 2N chromosomes as binomial trials with k = 2×AA + Aa A-alleles.

Can I change allele labels?

This tool uses A and a for clarity. You can map them to your locus alleles (e.g., reference vs alternate).

Why do I get “even sum required” with allele counts?

In diploid organisms, the total number of alleles is 2×N. Therefore, A + a must be even to correspond to an integer number of individuals.

Is deviation from HWE always biologically meaningful?

No. Deviations can arise from technical issues (e.g., genotyping error) or sampling noise, not only from evolutionary forces. Always consider context and replicate data quality checks.


Audit: Complete
Formula (LaTeX) + variables + units
This section shows the formulas used by the calculator engine, plus variable definitions and units.
Formula (extracted LaTeX)
\[p = \\frac{2\\,AA + Aa}{2N}, \\quad q = 1 - p\]
p = \\frac{2\\,AA + Aa}{2N}, \\quad q = 1 - p
Formula (extracted LaTeX)
\[P(AA) = p^2,\\quad P(Aa) = 2pq,\\quad P(aa) = q^2\]
P(AA) = p^2,\\quad P(Aa) = 2pq,\\quad P(aa) = q^2
Formula (extracted LaTeX)
\[E[AA] = N p^2,\\quad E[Aa] = N (2pq),\\quad E[aa] = N q^2\]
E[AA] = N p^2,\\quad E[Aa] = N (2pq),\\quad E[aa] = N q^2
Formula (extracted LaTeX)
\[H = 2pq\]
H = 2pq
Formula (extracted LaTeX)
\[\\chi^2 = \\sum_{g\\in\\{AA,Aa,aa\\}} \\frac{(O_g - E_g)^2}{E_g} \\quad \\text{with 1 degree of freedom}\]
\\chi^2 = \\sum_{g\\in\\{AA,Aa,aa\\}} \\frac{(O_g - E_g)^2}{E_g} \\quad \\text{with 1 degree of freedom}
Formula (extracted LaTeX)
\[p\\text{-value} = \\operatorname{erfc}\\!\\left(\\sqrt{\\chi^2/2}\\right)\]
p\\text{-value} = \\operatorname{erfc}\\!\\left(\\sqrt{\\chi^2/2}\\right)
Formula (extracted text)
If AA, Aa, aa are genotype counts and N = AA + Aa + aa: Allele frequencies: $p = \\frac{2\\,AA + Aa}{2N}, \\quad q = 1 - p$ Hardy–Weinberg expected genotype frequencies: $P(AA) = p^2,\\quad P(Aa) = 2pq,\\quad P(aa) = q^2$ Expected counts: $E[AA] = N p^2,\\quad E[Aa] = N (2pq),\\quad E[aa] = N q^2$ Heterozygosity: $H = 2pq$ Goodness-of-fit statistic (chi-square): $\\chi^2 = \\sum_{g\\in\\{AA,Aa,aa\\}} \\frac{(O_g - E_g)^2}{E_g} \\quad \\text{with 1 degree of freedom}$ For df = 1, the p-value is: $p\\text{-value} = \\operatorname{erfc}\\!\\left(\\sqrt{\\chi^2/2}\\right)$ Wilson 95% CI for p using k A-alleles in n = 2N trials: $\\hat{p}_W = \\frac{\\hat{p} + z^2/(2n)}{1 + z^2/n},\\quad \\text{margin} = \\frac{z}{1+z^2/n}\\sqrt{\\frac{\\hat{p}(1-\\hat{p})}{n} + \\frac{z^2}{4n^2}}$
Variables and units
  • No variables provided in audit spec.
Sources (authoritative):
Changelog
Version: 0.1.0-draft
Last code update: 2026-01-19
0.1.0-draft · 2026-01-19
  • Initial audit spec draft generated from HTML extraction (review required).
  • Verify formulas match the calculator engine and convert any text-only formulas to LaTeX.
  • Confirm sources are authoritative and relevant to the calculator methodology.
Verified by Ugo Candido on 2026-01-19
Profile · LinkedIn