Verify and explain

1. Recalculate one sample

Choose a sample ID from data/airway/sample-metadata.tsv.

Rscript scripts/R/verify_sample.R data/airway results/airway <sample_id>

Replace <sample_id> with an actual ID when shown. The script sums that sample’s raw gene counts, counts genes with nonzero counts, and compares both numbers with tables/sample-qc.tsv. A passing check supports the saved sample summary, not the whole differential expression model.

2. Inspect the DE result

Open results/airway/tables/differential-expression.tsv. The gene IDs, log2FoldChange, pvalue and padj are central fields. Compare the sign of the estimated fold change with the named contrast. padj < 0.05 is a chosen decision threshold, not proof that every selected gene has a large or biologically important effect. Investigate NA values rather than counting them as discoveries.

Read results/airway/run-log.txt and confirm the number of genes tested. Select one gene and compare its raw counts across samples. Raw counts alone do not reproduce the fitted log2 fold change or adjusted p-value: those depend on normalization, dispersion, the design and multiple-testing adjustment.

3. Explain the PCA

Look at results/airway/figures/sample-pca.png. Describe where samples cluster, any unusual sample and how much variation PC1/PC2 represent. Because the four cell lines each have two conditions, distinguish cell-line separation from treatment separation. The PCA alone does not establish differential expression or causation.

Your evidence: record one verified sample total, one gene with its sign and adjusted p-value (or explain why no gene passes your threshold), and one observation about the PCA. State at least one limitation.

Check the selected-gene figure numerically

In an R console, trace normalized counts back to the raw counts and saved size factors:

raw <- read.delim("data/airway/gene-counts.tsv", check.names = FALSE)
size <- read.delim("results/airway/tables/size-factors.tsv")
gene <- read.delim("results/airway/tables/selected-gene-counts.tsv")
v <- as.numeric(unlist(raw[match(gene$gene_id[1], raw$gene_id), gene$sample_id], use.names = FALSE))
sf <- size$size_factor[match(gene$sample_id, size$sample_id)]
stopifnot(isTRUE(all.equal(v / sf, gene$normalized_count, tolerance = 1e-8)))
print(gene)

This verifies the arithmetic behind the plotted normalized counts, not the model’s p-values. Check the selected gene in differential-expression.tsv and confirm its direction, standard error and adjusted p-value. Paired normalized-count lines can differ from the overall model estimate because the model combines samples and uncertainty.

Explain all six figures

Write one evidence-based sentence per figure. Quote a sample total, PCA axis percentage, sample-pair distance, gene effect or adjusted p-value from its supporting table. Note unavailable values and avoid treating visually separated samples as a significance test. For airway, distinguish treatment effects from cell-line variation; for synthetic data, keep all biological claims fictional.

Next: Write the report