Probability & the χ² test

Part 1: Mendelian genetics

Basic and molecular genetics (5MO104)

About this lecture

Mendel’s laws predict ratios, such as 3:1 or 9:3:3:1. Real crosses give counts, such as 5474 round and 1850 wrinkled seeds. Today we connect the two.

  • Probability rules: the product rule (AND), the sum rule (OR) and conditional probability (“given that …”).
  • Families: the chance that 2 of 4 children are affected (the binomial), and “at least one”.
  • Testing a ratio: why observed counts never match the expected ones exactly, and the χ² goodness-of-fit test, which tells us whether the gap is bigger than chance would give. A six-step recipe, one example that fits, one that does not, and the common mistakes.
  • p-values: what they mean, what “fail to reject” means, and Fisher’s claim that Mendel’s data fit too well.

Book: Hartwell, Mendel’s principles chapter (the sections on probability and on the chi-square test).

A cross is a random experiment

Each child (or seed) of Aa × Aa is a fresh, independent draw:

  • each parent passes on A or a with probability ½ each (segregation);
  • the egg and the sperm are chosen independently of each other;
  • one child’s genotype says nothing about the next child’s genotype.

So a Punnett square is a probability table: each cell is one equally likely outcome. “3:1” means P(dominant phenotype) = ¾ for each offspring. It is not a promise that exactly 3 out of every 4 will be dominant.

Two rules let us combine these probabilities, and we use them all through the course: in pedigrees, in mapping and in population genetics.

Product rule and sum rule

  • Product rule: P(A and B) = P(A) × P(B), if A and B are independent.
  • Sum rule: P(A or B) = P(A) + P(B), if A and B are mutually exclusive (cannot both happen).

Using both rules: a dihybrid cross

AaBb × AaBb, with the two genes on different chromosomes (independent assortment):

  • P(aabb) = P(aa) × P(bb) = ¼ × ¼ = 1/16
  • P(A_B_) = P(A_) × P(B_) = ¾ × ¾ = 9/16
  • P(A_bb or aaB_) = 3/16 + 3/16 = 6/16

This works for any number of genes. For AaBbCc × AaBbCc:

P(aabbcc) = \tfrac14 \times \tfrac14 \times \tfrac14 = \tfrac{1}{64}

No 64-cell Punnett square is needed. Split the cross into one gene at a time, then multiply.

Conditional probability: “given that …”

Two Aa carriers have a child who is unaffected. What is the chance that this child is a carrier?

Knowing something shrinks the table. We only count the outcomes that are still possible:

P(\text{carrier} \mid \text{unaffected}) = \frac{P(\text{carrier and unaffected})}{P(\text{unaffected})} = \frac{1/2}{3/4} = \frac23

Families: how many children are affected?

Aa × Aa, four children. Each child is affected (aa) with p = ¼. What is P(exactly 2 affected)?

P(k \text{ of } n) = \binom{n}{k}\, p^k\, (1-p)^{n-k}, \qquad \binom{n}{k} = \frac{n!}{k!\,(n-k)!} \text{ ("$n$ choose $k$")}

“At least one”: use the complement

P(at least one of 4 children affected) has many cases (1, 2, 3 or 4). The opposite event has only one case:

P(\text{at least one}) = 1 - P(\text{none}) = 1 - \left(\tfrac34\right)^4 = 1 - \tfrac{81}{256} \approx 0.68

  • “None affected” means every child is unaffected, so by the product rule it is (¾)⁴.
  • Not 4 × ¼ = 1, which would make an affected child certain. Adding is wrong here, because “child 1 affected” and “child 2 affected” can both happen.

Real counts deviate from the ratio

Every dot is a family simulated with the 3:1 rule exactly true. With 20 seeds the fraction ranges from 0.50 to 0.90. With 2000 seeds it stays close to 0.75.

  • Deviation from the expected ratio is normal. It is sampling variation, or chance.
  • Small samples deviate a lot (in proportion); large samples deviate little.
  • The question is never “does it match exactly?” but “is the deviation larger than chance would usually produce?”

The χ² statistic

Turn “how far is observed (O) from expected (E)?” into one number:

\chi^2 = \sum_{\text{classes}} \frac{(O - E)^2}{E}

Mendel’s F2 seeds: 5474 round, 1850 wrinkled, total N = 7324. H0: 3:1.

class O E = N × p O − E (O − E)²/E
round 5474 7324 × ¾ = 5493 −19 361/5493 = 0.066
wrinkled 1850 7324 × ¼ = 1831 +19 361/1831 = 0.197
χ² = 0.263
  • Square, so that positive and negative deviations do not cancel.
  • Divide by E, so that a deviation of 19 counts for more when only 1831 were expected than when 5493 were.

Degrees of freedom

The degrees of freedom (df) count how many classes are free to vary once the total is fixed.

  • 2 classes (round, wrinkled): once N and the round count are known, the wrinkled count is fixed. df = 1.
  • k classes, with the ratio given in advance: df = k − 1.
hypothesis classes k df
3:1, 1:1, 9:7 2 1
1:2:1 3 2
9:3:3:1, 1:1:1:1 4 3

More classes give more terms in the sum, so χ² tends to be bigger by chance alone. The df tells us which reference curve to use.

The χ² distribution

If H0 is true, repeating the experiment many times gives χ² values that follow this curve. Most are small; large values are rare.

The p-value

p-value = P(χ² at least as large as the observed one, if H0 is true) = the area of the tail to the right of the observed χ².

df p = 0.10 p = 0.05 p = 0.01
1 2.71 3.84 6.63
2 4.61 5.99 9.21
3 6.25 7.81 11.34
4 7.78 9.49 13.28
  • Rule: if χ² > the 5% critical value (p < 0.05), reject H0: the deviation is too big to blame on chance.
  • Mendel’s seeds: χ² = 0.263 < 3.84, so p > 0.05 (exactly, p = 0.61). The data are consistent with 3:1.

“Fail to reject” is not “proven”

  • p < 0.05: the data are unlikely under H0. We reject H0. (We may still be wrong in 1 in 20 tests of a true H0.)
  • p ≥ 0.05: we fail to reject H0. The data are consistent with H0, but this does not prove it.
    • Other ratios may fit too: 5474:1850 is also consistent with 2.95:1.
    • Small samples can rarely reject anything. 6:4 seeds gives χ² = 1.2 against 3:1 (p = 0.27).
  • A p-value is not the probability that H0 is true.

Two rules for using χ²

1. Use counts, never percentages or proportions.

60% vs 40% against 3:1:

data χ² p
6 : 4 seeds 1.2 0.27
60 : 40 seeds 12 0.0005
“60 : 40” as percentages 12, whatever N really was meaningless

The same proportions are much stronger evidence when N is large. A percentage throws N away.

2. Every expected count should be at least 5. Otherwise the χ² curve is a poor approximation. Pool classes, collect more data, or use an exact test.

The χ² test in six steps

  1. State H0 as a ratio and turn it into proportions: 3 : 1 → ¾, ¼.
  2. Expected counts: E = N × proportion, with N the total observed. Do not round E.
  3. Statistic: χ² = Σ (O − E)²/E over all classes. Check: Σ O = Σ E, and Σ (O − E) = 0.
  4. Degrees of freedom: df = number of classes − 1.
  5. Compare χ² with the critical value for that df (3.84, 5.99, 7.81, …), or compute p.
  6. Conclude in words, about the biology: “reject 3 : 1: there are too few recessives” or “consistent with 3 : 1”.

The next two slides are two worked examples: one that fits, and one that does not.

Worked example: Mendel’s dihybrid cross

F2 of round yellow × wrinkled green: 556 seeds. H0: 9:3:3:1 (independent assortment).

class O E (O − E)²/E
round yellow 315 556 × 9/16 = 312.75 0.016
round green 108 556 × 3/16 = 104.25 0.135
wrinkled yellow 101 556 × 3/16 = 104.25 0.101
wrinkled green 32 556 × 1/16 = 34.75 0.218
556 556 χ² = 0.470

df = 4 − 1 = 3. The critical value is 7.81, and 0.470 is far below it (p = 0.93). Fail to reject 9:3:3:1. The data are consistent with independent assortment of seed shape and seed colour.

Worked example: a ratio that does not fit

An F2 from Aa × Aa gives 290 dominant : 70 recessive (N = 360; illustrative counts). H0: 3 : 1.

class O E O − E (O − E)²/E
dominant 290 360 × ¾ = 270 +20 400/270 = 1.48
recessive 70 360 × ¼ = 90 −20 400/90 = 4.44
360 360 0 χ² = 5.93

df = 1. 5.93 > 3.84, so p < 0.05 (exactly, p = 0.015): reject 3 : 1 at the 5% level. (But 5.93 < 6.63, so not at the 1% level.)

Now the biology. Which way do the data deviate? Too few recessives: 70 instead of 90. Possible reasons:

  • aa individuals survive less well (reduced viability), so some died before they were counted;
  • aa is hard to score, and some were misclassified as dominant;
  • the trait is not controlled by one gene in the way we assumed.

The test tells us that the model fails, not why. The next experiment has to decide.

Common mistakes with χ²

Mistake Why it is wrong Do instead
Using the ratio numbers as E (E = 3 and 1) E must be counts on the same scale as O E = N × ¾, N × ¼
Using percentages or proportions as O χ² grows with N; percentages pretend N = 100 always use counts
Rounding E to whole numbers E is an average, not a count; rounding changes χ² keep E as decimals
df = number of classes one count is fixed by the total df = classes − 1
“p = 0.3, so the ratio is proven” failing to reject is not proof “consistent with 3 : 1”
“p = 0.03, so the hypothesis has a 3% chance of being true” p is computed assuming H0 “data this far off happen 3% of the time if H0 is true”
Testing with a class that expects 1.2 the χ² curve is a poor approximation pool classes or get more data (E ≥ 5)
Picking the ratio after seeing the data, then testing it the test assumes the ratio is given in advance state H0 from the genetics first

Try it: χ² goodness of fit

Fisher: Mendel’s data fit too well

  • In 1936 R. A. Fisher added up χ² over many of Mendel’s experiments. The total was smaller than chance would usually allow.
  • With honest sampling, p-values are spread evenly between 0 and 1. A whole series of p-values close to 1 is itself suspicious.
  • Here: the 7 monohybrid experiments give a total of 2.14 on 7 df. A fit this close happens only about 1 time in 20.

Possible explanations include unconscious bias in classifying ambiguous seeds, selective reporting, or an assistant “helping”. The debate continues; you will look up a modern analysis in the exercise.

Summary

Concept Key fact
Product rule independent events, AND: multiply
Sum rule mutually exclusive events, OR: add
Conditional P(B given C): count only the outcomes still possible. P(carrier | unaffected, Aa × Aa) = 2/3
Binomial P(k of n) = (n choose k) pᵏ (1 − p)ⁿ⁻ᵏ
At least one 1 − P(none)
χ² Σ (O − E)²/E, with E = N × expected proportion
df k − 1 for k classes and a ratio given in advance
p-value P(χ² this large or larger, if H0 is true). p < 0.05: reject H0
Fail to reject consistent with H0, not proof of it
Reject say which way the data deviate, and suggest a biological reason (e.g. reduced viability)
Rules counts not percentages; all E ≥ 5
Too good χ² far below df, repeatedly, is suspicious too

Where this leads

  • Extensions to Mendel: modified ratios such as 9:7 and 12:3:1. You use χ² to decide which ratio fits.
  • Pedigrees: conditional probability and the product rule give carrier and disease risks in families.
  • Linkage: a χ² test against 1:1:1:1 is the first test for whether two genes are linked.
  • Hardy–Weinberg: χ² again, with one df lost because the allele frequency is estimated from the data.
  • In R (this unit’s exercise): chisq.test, pchisq, dbinom, and simulation with replicate().