Day 25 — practise the complete workflow

Lecture slides · Quiz · Weekly revision

Today’s question

In a later lab course or thesis project, someone will hand you a data file and ask what it shows. Can you find the files, check them, make a figure, explain the result and produce a report that someone else can render, without the course telling you each step? Today you practise exactly that on familiar data, using the reference pages whenever you need them.

Start with the station where you feel least sure. Over the day, do stations 1–3, then the A11 investigation and the handover.

Save today: recovery.R, reports/final-investigation.txt, a tested handover package, reports/next-lab.txt and reports/readiness-review.txt.

Station 1: finding and inspecting lab files

Download a fresh copy of lab-data.zip. In your shell, list the archive, extract it into a new folder and read its README. Then use grep -F treated on the sample manifest, piped into wc -l, to find out how many samples were treated; predict the number before you run it. Save the matching lines as treated-samples.txt, and finally pack the extracted folder into a new ZIP placed outside it.

The commands from days 3–4 are enough: pwd, ls, cd, unzip -l, unzip … -d …, less, grep -F, wc -l and zip -r; see the terminal reference. The manifest has two treated records; the header line does not match. > writes only to treated-samples.txt; the manifest itself is unchanged.

Station 2: repairing a broken analysis

This code is meant to calculate the mean growth of the seedlings, but it contains several errors:

seedling <- read_csv("seedlings.csv")
seedlings <- mutate(seedlings, growth_mm = final_mm + initial_mm)
mean(seedlings$Growth_mm)

Write a working version in recovery.R in your project root. Use P01 to find out whether your repaired growth calculation is right: it started at 25.7 mm and ended at 44.3 mm. Then save a labelled plot of growth by treatment.

library(readr)
library(dplyr)
library(ggplot2)
seedlings <- read_csv("data/seedlings.csv", show_col_types = FALSE)
seedlings <- seedlings |>
  mutate(growth_mm = final_mm - initial_mm)
mean(seedlings$growth_mm)

P01 grew 18.6 mm. The original had no library() calls, a path without data/, two different object names (seedling and seedlings), addition instead of subtraction, and Growth_mm with a capital G, which R treats as a different name. The fourth error is the dangerous one: code that adds instead of subtracts runs without any error message, which is why checking one row by hand matters.

Station 3: explaining results

Answer each question in one or two sentences, then compare with the answers.

  1. One treated plant has 100 cells measured, and so does one control plant. Are there 100 replicates per group?
  2. Two groups have the same mean, but one has twice the SD. What do their observations look like?
  3. A missing biomass value is replaced by zero. What happens to the group mean?
  4. A treatment-minus-control estimate is 3 mm with a 95% interval from −2 to 8 mm. Does this show that the treatment has no effect?
  5. An unknown sample reads a higher absorbance than the highest calibration standard. What should happen before its concentration is reported?
  6. Leaf mass rises with leaf area. Would enlarging a leaf add the same mass?
  1. No. There is one treated and one control plant; the cells inside a plant share its treatment, so they are not independent replicates.
  2. The values in the second group are spread much more widely around the same centre.
  3. The mean drops, because zero is an invented, very low value. Leave it as NA and report one fewer measurement.
  4. No. The interval includes zero but also effects in both directions up to 8 mm, so the study cannot tell. Report it as inconclusive.
  5. Flag it as above the range; dilute the sample and measure it again.
  6. Not necessarily. Area was measured, not changed, and older or better-lit plants may have both larger and heavier leaves.

Station 4: your complete report

Open your report from day 23 (duckweed-report.Rmd or organic-study.Rmd). Restart R and render it without running anything in the Console first. Then read the HTML as a stranger would, and find out whether it tells you:

  • the question and the independent unit (a flask, or a synthesis run);
  • the input file, the units and what happened to missing values;
  • a plot of individual units and a small summary;
  • the comparison in a stated direction, with size, spread or uncertainty, and a limitation.

Fix whatever is missing and render again. The organic study stays descriptive: group means and SDs are enough.

Station 5: the remote computer

If remote access works, repeat day 22: log in, find out which computer and folder you are in, locate a supplied file, disconnect, reconnect and find it again, then copy one output to your laptop. If access is still pending, note it in your readiness review as a skill still to practise.

Is A11 a mistake?

In the algae data from days 23–24, reference culture A11 has the largest biomass of all, 41.7 mg. A high value like this is tempting to remove. Find out whether there is a reason to remove it, and how much it changes the result. Record each step in reports/final-investigation.txt.

  1. Without using “recent files”, find your project, algae-transfer.R, algae-brief.Rmd, data/algae.csv and the HTML, and write their paths.
  2. Read the algae section of data/README.md. It records that A19 was spilled, and says nothing wrong about A11, so A11 belongs in the primary result.
  3. Use your summary code on all available measurements to find out the supplement-minus-reference difference. Label it “primary, all available measurements”.
  4. Make a separate object without A11 and repeat the calculation to find out how much this one culture moves the difference:
algae_without_a11 <- filter(algae, culture_id != "A11")
  1. In a copy of algae-brief.Rmd, add a limitations paragraph that separates three things: A19 is missing, A11 is high but recorded, and the study is small and simulated. Render it and check that the main figure and numbers still use all available measurements.

Primary: reference 28.20 mg (12 cultures), supplement 33.92 mg (11), difference 5.72 mg. Without A11: reference 26.97 mg (11 cultures), difference 6.95 mg. The supplement mean does not change, because A11 is a reference culture. Report the primary result; if you show the second one, label it “A11 omitted without evidence of error”.

Can someone else follow your instructions?

Write a short README.txt for your report: the question, where the raw data are, what one row means, what blank cells mean, which file to render and what the result should look like. For the organic study, include the yield formula.

Then test it. Pack the project, extract it into a new folder, and follow only your README: open the .Rproj, restart R, render, and find the main result and a limitation in the HTML. If something is unclear, fix the README or the report, make a new, clearly named package and test that one too. A copy you edited in one place, for example on Windows, does not update a copy already packed or moved elsewhere; use the version checks from day 22.

What will you take to your next lab?

Save reports/next-lab.txt with your own workflow for a new dataset: where raw data go, how to open the project, which checks to make, how to choose a figure, and how to render and back up the report. Add the questions you would ask a lab teacher first, such as “What was randomly assigned?” and “What do blank cells mean?”

Finally, save reports/readiness-review.txt: three things you can now do reliably, two that need more practice, and one concrete practice task for each of those two. List remote login and file transfer as pending if you have not used the real service.

Leave with: recovery.R, reports/final-investigation.txt with the primary and A11-omitted results, a tested handover package, reports/next-lab.txt and reports/readiness-review.txt. Keep the reference pages and your project for later lab courses.