Genetics and Heredity

Chi-Square Tests for Genetics Data: A Worked Method

Test whether offspring counts fit a predicted ratio: expected values, the chi-square statistic, degrees of freedom and p values.

Key takeaways

  • The statistic is χ² = ∑ (O − E)² ÷ E, summed over every class, where O is observed and E is expected.
  • Degrees of freedom for a simple ratio test equal the number of classes minus one.
  • A χ² above the critical value means data this far from expectation would be unusual if the hypothesis were true.
  • Use raw counts, never percentages or proportions.
  • Failing to reject a hypothesis shows the data are compatible with it, not that it is proven.

A chi-square goodness-of-fit test tells you whether observed offspring counts differ from a predicted ratio by more than chance would usually produce. You calculate the expected count in each class, measure how far each observed count strays from it, add up those scaled differences, and compare the total with a threshold.

Real counts almost never match a ratio like 3 : 1 exactly. The test gives you a consistent way to decide when a gap is ordinary sampling noise and when it suggests your genetic model is wrong.

State the hypothesis first

The null hypothesis is a specific model that predicts numbers. For example: "This trait is controlled by one gene with complete dominance, both parents are heterozygous, and all genotypes survive equally, so offspring appear in a 3 : 1 ratio."

Write it down before you analyze. If you search through ratios until one fits, the test no longer means what it claims.

Why the formula looks like this

Each part of the statistic does a specific job. The difference O − E measures how far a class strays from the prediction. Squaring it makes shortfalls and surpluses count equally, since otherwise they would cancel to zero. Dividing by E puts the gap in proportion.

That last step matters. Being 10 individuals away from an expected 20 is a large departure. Being 10 away from an expected 2,000 is trivial. Scaling by the expected count captures the difference.

If the model is right and samples are reasonably large, the total follows a known mathematical distribution called the chi-square distribution. Its shape depends on the degrees of freedom. More classes means more terms in the sum, so a larger total is expected from chance alone, and the critical value rises to match.

The British statistician Karl Pearson introduced the test in 1900, the same year Mendel's work came back to attention. R. A. Fisher later clarified how degrees of freedom should be counted. The method now appears far outside genetics, wherever counts in categories are compared with a prediction, but offspring ratios remain one of the clearest places to learn it, because the expectation comes from a mechanism you can state in a sentence.

The five steps

  1. Predict a ratio from the genetic hypothesis.
  2. Compute expected counts by multiplying each predicted fraction by the total number observed.
  3. Calculate (O − E)² ÷ E for every class and add the results.
  4. Find the degrees of freedom and look up the critical value.
  5. Decide and interpret in words that refer to the biology.
A chi-square goodness-of-fit test
1 Hypothesis Name the ratio your model predicts 2 Expected counts Predicted fraction times total 3 Statistic Sum of (O - E) squared over E 4 Threshold Degrees of freedom and significance level 5 Interpret Compatible or not, and what next Hypothesis Name the ratio your model predicts 1 Expected counts Predicted fraction times total 2 Statistic Sum of (O - E) squared over E 3 Threshold Degrees of freedom and significance level 4 Interpret Compatible or not, and what next 5

Worked example 1: a 3 : 1 ratio

A cross of two heterozygotes produces 400 offspring: 290 with the dominant trait and 110 with the recessive one. Does this fit 3 : 1?

Class O E O − E (O − E)² ÷ E
dominant 290 300 −10 100 ÷ 300 = 0.333
recessive 110 100 +10 100 ÷ 100 = 1.000
total 400 400 0 χ² = 1.333

Notice that the expected counts add to the observed total, and the O − E column adds to zero. Both are quick checks on your arithmetic.

Degrees of freedom and critical values

Degrees of freedom count how many class totals are free to vary. With two classes and a fixed total of 400, once you know one count the other is determined, so there is 1 degree of freedom.

Degrees of freedom Critical value, 0.05 level Critical value, 0.01 level
1 3.841 6.635
2 5.991 9.210
3 7.815 11.345
4 9.488 13.277

In example 1, χ² = 1.333 is below 3.841. You do not reject the 3 : 1 hypothesis at the 0.05 level. The corresponding p value is about 0.25.

What the p value means

The p value is the probability of getting a statistic at least as large as yours if the hypothesis and the test's assumptions are true. A p of 0.25 says that about one experiment in four would stray this far or further by chance.

It is not the probability that your hypothesis is correct. Nor is 0.05 a law of nature. It is a convention that accepts a 1 in 20 risk of rejecting a true hypothesis.

Worked example 2: Mendel's two-gene data

Mendel counted 556 seeds from a cross of double heterozygotes. The prediction for a dihybrid cross is 9 : 3 : 3 : 1.

Class O E (O − E)² ÷ E
round yellow 315 312.75 0.016
round green 108 104.25 0.135
wrinkled yellow 101 104.25 0.101
wrinkled green 32 34.75 0.218
total 556 556 χ² = 0.470

With four classes there are 3 degrees of freedom. The statistic is far below 7.815, and p is roughly 0.9. The data are very compatible with the model. Fits this close recurring across many experiments are what prompted later debate about Mendel's results.

Worked example 3: a hypothesis that fails

A test cross of a double heterozygote gives 1,000 offspring in classes of 410, 90, 95 and 405. Independent assortment predicts 250 in each.

(410 − 250)² ÷ 250 = 25,600 ÷ 250 = 102.4
( 90 − 250)² ÷ 250 = 25,600 ÷ 250 = 102.4
( 95 − 250)² ÷ 250 = 24,025 ÷ 250 =  96.1
(405 − 250)² ÷ 250 = 24,025 ÷ 250 =  96.1
χ² = 397.0   with 3 degrees of freedom

This dwarfs 7.815, so p is far below 0.001. Rejecting the model does not tell you why it failed. The pattern, with two large and two small classes, suggests linkage. A good next step is to estimate the recombination fraction, as in test crosses, and to confirm that each gene alone still gives 1 : 1. Here the A trait splits 500 to 500 and the B trait 505 to 495, so segregation looks normal.

What to do after a rejection

A rejected hypothesis is the start of an investigation. Look first at which classes contribute most to the total, then ask which biological explanation would produce that pattern.

Pattern in the data Possible explanation to test
One recessive class is short reduced survival of that genotype
Parental combinations are in excess linkage between two genes
Ratio near 9 : 7 or 9 : 3 : 4 two genes interacting
Ratio near 2 : 1 instead of 3 : 1 a genotype that dies before it is counted
Odd ratios that differ between batches scoring errors, contamination or environment

Each explanation predicts something new. Linkage predicts that single genes still segregate normally. Reduced survival predicts more failed seeds or embryos in crosses that should produce the missing genotype. Test the new prediction on fresh data where you can.

Choosing a new ratio after seeing the counts and then testing it on the same counts is circular. It will usually appear to fit, because you picked it to fit. Treat that result as a suggestion, then repeat the cross.

It is also worth checking the basics before reaching for new biology. Recount a sample, confirm how ambiguous individuals were classified and make sure the parents really had the genotypes you assumed. Many surprising ratios turn out to come from a mislabeled seed packet or a trait that is hard to score at an early stage.

Conditions for a trustworthy test

  • Counts only. Converting 290 and 110 into 72.5 and 27.5 percent would change the statistic.
  • Independent observations. Each individual is counted once and falls in one class.
  • Large enough expectations. A common rule asks for at least 5 expected in each class. With fewer, combine classes sensibly or use an exact test.
  • A model fixed in advance. If you estimate a quantity from the same data, you lose a degree of freedom. In a test of Hardy-Weinberg proportions with two alleles, three genotype classes leave only 1 degree of freedom once the allele frequency is estimated.

When there is only one degree of freedom

With just two classes and modest expected counts, some courses apply Yates's continuity correction, which subtracts 0.5 from the size of each difference before squaring. It makes the test slightly more cautious. Practice differs, so follow the convention of your course or journal and say which you used. An exact binomial test avoids the question altogether when numbers are small and software is available.

Sample size and its effect

The statistic grows with sample size when proportions stay the same. Multiply every count in example 1 by ten, giving 2,900 and 1,100, and χ² becomes 13.33, which rejects 3 : 1.

A small study may lack the power to detect a real departure. A huge study may flag a departure too small to matter biologically. Report the actual proportions alongside the statistic so readers can judge both.

Practice problem with a solution

Say a cross expected to give a 1 : 2 : 1 ratio produces 200 offspring: 60 red, 95 pink and 45 white, in a plant with incomplete dominance for flower color. Does it fit?

The expected counts are 50, 100 and 50. The contributions are 100 ÷ 50 = 2.00 for red, 25 ÷ 100 = 0.25 for pink and 25 ÷ 50 = 0.50 for white. The statistic is 2.75.

Three classes give 2 degrees of freedom, with a critical value of 5.991 at the 0.05 level. Since 2.75 is smaller, the counts are consistent with 1 : 2 : 1. The surplus of red over white looks suggestive to the eye, but a gap of this size arises fairly often by chance. If you suspected a real bias, you would state that as a new question and collect new data. The pattern behind this ratio is described in incomplete dominance and codominance.

Writing up the conclusion

A clear sentence includes the hypothesis, the numbers and the decision. For example 1: "The counts of 290 dominant and 110 recessive offspring did not differ significantly from a 3 : 1 ratio (χ² = 1.33, 1 degree of freedom, p ≈ 0.25)."

Avoid "the test proved the gene is dominant." Several different mechanisms can produce similar ratios, and only further crosses or molecular evidence can separate them.

Written for 4Biology with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 44 articles in Genetics and Heredity →

Latest news on this topic