The same plant measured twice

Day 18 — Paired changes and identity

Data Analysis in Life Sciences

About this lecture

In a plant physiology lab you measure the photosynthesis rate of ten plants, then raise the light and measure the same ten plants again. The plants differ a lot from each other before anything changes. Did the rate go up, and by how much? The same design appears whenever a patient, an animal or a culture is measured before and after something: blood pressure before and after exercise, a leaf before and after shading.

Today you will:

  • keep the two readings of each plant together, using its identifier;
  • turn each pair into one change and look at the ten changes;
  • run a paired t-test and read its estimate, interval and p-value;
  • say what a before/after design can and cannot show.

Day 17 compared two separate groups. Today each unit is measured twice, which needs a different analysis. Day 19 moves on to calibration lines.

The problem: twenty readings, ten plants

  • data/paired.csv: ten plants, each measured before and after the light was increased (µmol CO₂ m⁻² s⁻¹).
  • Before readings range from 5.20 to 8.81: plants differ from each other.
  • Yet almost every line goes up by a similar amount.
  • The two readings of one plant are not independent: a high plant before is likely high after.

Question: how large is the change within a plant?

Each of ten plants has a line from its before reading to its after reading; starting levels differ, but every line rises.

Pair by identity, not by position

  • plant_id says which two readings belong together.
  • In paired.csv each row holds one plant’s before and after, so the pair is already kept together.
  • If the readings came in two files, match them by ID before subtracting. Ten rows in each file is not enough.
  • Sorting the whole table is safe: rows move together. Sorting one column on its own breaks the pairs.

Plant identifiers connect before and after readings even when the two lists are in different orders.

One change per plant

Three example plants show their after-minus-before change: L01 +1.08, L02 +4.17, L03 +1.31.
  • Change = after − before for the same plant. Positive means the rate went up.
  • L01: 6.95 − 5.87 = +1.08. L02: 11.92 − 7.75 = +4.17. L03: 10.12 − 8.81 = +1.31.
  • Each plant is its own reference, so differences in starting level drop out.

In R: check the pairs, then compute the change

> paired <- read_csv("data/paired.csv", show_col_types = FALSE)
> anyDuplicated(paired$plant_id)
[1] 0
> paired <- paired |>
+   mutate(change_umol_m2_s = after_umol_m2_s - before_umol_m2_s)
> paired
# A tibble: 10 × 4
   plant_id before_umol_m2_s after_umol_m2_s change_umol_m2_s
   <chr>               <dbl>           <dbl>            <dbl>
 1 L01                  5.87            6.95             1.08
 2 L02                  7.75           11.9              4.17
 3 L03                  8.81           10.1              1.31
...
10 L10                  6.03            8.31             2.28
> mean(paired$change_umol_m2_s)
[1] 1.983
  • anyDuplicated() prints 0: no plant ID appears twice, so ten rows are ten plants.
  • mutate() adds a fourth column with one change per plant. L01: 6.95 − 5.87 = 1.08, as by hand.
  • The mean change is 1.983 µmol m⁻² s⁻¹.
  • R shows 11.92 as 11.9: the printout rounds, the stored value does not.

Look at the ten changes

  • All ten changes are positive, from +1.08 to +4.17.
  • Mean change 1.983; SD of the changes 1.02.
  • The dashed line is no change.
  • L02 changed much more than the others. That alone is not an error: keep it.

Each point is one plant’s after-minus-before change, all above the dashed zero line.

The paired t-test

> paired_comparison <- t.test(paired$after_umol_m2_s,
+                             paired$before_umol_m2_s,
+                             paired = TRUE)
> paired_comparison

        Paired t-test

data:  paired$after_umol_m2_s and paired$before_umol_m2_s
t = 6.1613, df = 9, p-value = 0.0001664
alternative hypothesis: true mean difference is not equal to 0
95 percent confidence interval:
 1.254935 2.711065
sample estimates:
mean difference
          1.983
  • paired = TRUE matches the first after with the first before, and so on: the rows must hold true pairs.
  • Estimate: mean change 1.983 µmol m⁻² s⁻¹, after − before.
  • 95% CI: 1.25 to 2.71: uncertainty in the mean change. Single plants changed by 1.08 to 4.17.
  • p = 0.00017: a change this large would be very rare if the true mean change were zero.
  • df = 9: ten pairs minus one.
  • t.test(paired$change_umol_m2_s, mu = 0) prints the same numbers: it is the same analysis.

Why not use Day 17’s Welch test?

  • Treating before and after as two separate groups gives the same estimate, 1.98, but an interval of 0.74 to 3.23.
  • That interval is wider because plant-to-plant differences stay in the calculation.
  • The paired analysis removes them: each plant is compared with itself.
  • The design decides which test to use, not which result looks better.

The paired interval 1.25 to 2.71 is narrower than the 0.74 to 3.23 interval from wrongly treating the readings as two separate groups.

Pitfall: sorting the columns separately

  • Sorting before and after one column at a time matches the smallest with the smallest, not plant with plant.
  • The mean change is still 1.983: means cannot detect the mistake.
  • But the SD of the changes drops from 1.02 to 0.50, and p shrinks to about 0.0000006.
  • A smaller p after breaking the pairs is not better evidence; it is a wrong analysis.

Left: correct within-plant pairings cross each other. Right: matching by rank gives parallel lines that connect readings from different plants.

Pitfall: few pairs leave much uncertainty

  • Illustrative example: three plants, before 5, 8, 6 and after 7, 9, 9.
  • Changes +2, +1, +3: all positive, mean 2.
  • 95% interval for the mean change: −0.48 to 4.48 (p ≈ 0.07).
  • With three pairs we cannot even be sure of the direction. That is not proof of no effect: report the uncertainty.

Three observed changes of 1, 2 and 3 have a mean of 2, but the 95 percent interval for the mean change runs from about −0.48 to 4.48 and includes zero.

What the design cannot show

  • Every plant was measured before, then after. Light changed, but time also passed: acclimation, time of day or instrument drift could contribute.
  • There is no group of plants measured twice without a light change.
  • A small p-value does not separate light from time.
  • Better design: add plants measured twice under unchanged light, and use more plants.

Plants are measured in lower light and later in higher light; light and elapsed time change together.

Write the result

“Across 10 plants, photosynthesis rate was on average 1.98 µmol m⁻² s⁻¹ higher after the light was increased than before (95% CI 1.25 to 2.71; paired t-test, p ≈ 0.0002). Light and measurement order changed together, so the change cannot be attributed to light alone.”

Misreading Better
“We had 20 observations.” 10 plants, each measured twice: 10 pairs.
“Most plants changed by 1.25 to 2.71.” The interval is for the mean change; plants changed by 1.08 to 4.17.
“Light caused the increase.” Light and time changed together; no unchanged-light group.
“Sorting the columns gave a smaller p, so it is better.” Sorting destroyed the pairs; the result is invalid.

Summary

Concept Key fact
Paired design Each unit measured twice; the unit, not the reading, is independent (10 plants, not 20 readings)
Identity Match readings by plant_id; never sort one column on its own
Change after − before per plant; the direction is a choice you write down first
Paired t-test t.test(after, before, paired = TRUE) = one-sample test of the changes against 0
Estimate and CI Mean change 1.98, 95% CI 1.25 to 2.71 µmol m⁻² s⁻¹; about the mean change
Why pair Removes plant-to-plant differences: narrower than treating the columns as two groups
Few pairs Three pairs: CI −0.48 to 4.48; uncertain, not “no effect”
Design limit Fixed before/after order: light and time are mixed; a test cannot separate them

Next (Day 19, calibration): a straight line that turns an instrument reading into a concentration.

Now: open the Day 18 exercises. Make paired-report.Rmd with the ID check, the change plot, the paired test and a limitation; save output/day18-changes.png and render.