Skip to content

Verify the paired plant dataset

The biological comparison uses six matched plots. Each plot supplies one plant from each selected species, while the remaining injections measure analytical controls. A correct file count is insufficient if a join assigns an injection to the wrong species or collapses repeated QC labels.

The examples read the same preserved MTBLS865 selection and sample table. They check every file identity, control role, acquisition counter, and paired design before any feature result enters the analysis.

The source responses remain compressed in the companion repository, which requires access. The public source remains available from MetaboLights. Every fixture has a recorded SHA-256, and the preparation joins the selection to the complete source assay and sample metadata.

The sample identifier and injection identifier have different purposes. SCH_QC identifies the pooled material across repeated injections. An identifier such as run_2732 identifies one acquisition. The model uses biological plants only.

The model includes an intercept, five plot indicators, and one species indicator. Dactylis glomerata supplies the reference species. Both examples preserve the full design matrix so equal dimensions cannot conceal different sample order or coefficient definitions.

The source data are Dietz and colleagues’ MTBLS865 deposit, released publicly by MetaboLights in 2020 under EMBL-EBI Terms of Use. The repository’s public data policy permits reuse, and its data guide permits modification. The source notice identifies the authors, original files, and this analysis’s selection and transformations.

library(digest)
library(ggplot2)
library(jsonlite)
library(patchwork)
checksums <- read.table("/fixtures/SHA256SUMS", colClasses = "character")
for (index in seq_len(nrow(checksums))) {
actual <- digest(file = file.path("/fixtures", checksums[index, 2]),
algo = "sha256")
stopifnot(identical(actual, checksums[index, 1]))
}
metadata <- read.delim("/fixtures/sample_metadata.tsv",
stringsAsFactors = FALSE)
selected <- fromJSON(gzfile("/fixtures/source/selected_inputs.json.gz"))
source <- selected$records
source <- source[match(metadata$source_file, source$file), ]
stopifnot(nrow(metadata) == 38L, !anyDuplicated(metadata$injection_id))
stopifnot(!anyDuplicated(metadata$source_file))
stopifnot(identical(metadata$source_file, source$file))
stopifnot(identical(metadata$sample_id, source$sample_id))
stopifnot(identical(metadata$role, source$role))
stopifnot(identical(metadata$provider_sha256, source$provider_sha256))
stopifnot(all(metadata$source_bytes == source$bytes))
stopifnot(all(metadata$acquisition_counter == source$provisional_counter))
role_levels <- c("biological", "pooled_qc", "process_blank",
"system_suitability")
role_counts <- table(factor(metadata$role, levels = role_levels))
stopifnot(identical(as.integer(role_counts), c(12L, 8L, 10L, 8L)))
plants <- metadata[metadata$role == "biological", ]
plants <- plants[order(plants$plot, plants$species), ]
plants$plot <- factor(plants$plot)
plants$species <- factor(plants$species,
levels = c("Dactylis glomerata", "Galium mollugo"))
stopifnot(!anyDuplicated(plants$sample_id))
stopifnot(all(table(plants$plot, plants$species) == 1L))
design <- model.matrix(~ plot + species, plants)
colnames(design) <- c("intercept", paste0("plot_", levels(plants$plot)[-1]),
"species_galium")
stopifnot(qr(design)$rank == ncol(design))
design_table <- data.frame(injection_id = plants$injection_id, design)
write.csv(design_table, "outputs/design_r.csv", row.names = FALSE)
metrics <- list(injections = nrow(metadata), plants = nrow(plants),
plots = nlevels(plants$plot), pooled_qc = role_counts[[2]],
blanks = role_counts[[3]], standards = role_counts[[4]],
input_bytes = sum(metadata$source_bytes),
design_rank = qr(design)$rank,
residual_df = nrow(design) - qr(design)$rank)
write_json(metrics, "outputs/metrics_r.json", auto_unbox = TRUE)
cat(sprintf("Selected injections: %d\n", nrow(metadata)))
cat(sprintf("Biological plants: %d\n", nrow(plants)))
cat(sprintf("Complete plot pairs: %d\n", nlevels(plants$plot)))
cat(sprintf("Pooled QC, blanks, standards: %d %d %d\n",
role_counts[[2]], role_counts[[3]], role_counts[[4]]))
cat(sprintf("Expected source bytes: %.0f\n", sum(metadata$source_bytes)))
cat(sprintf("Design rank and residual degrees of freedom: %d %d\n",
qr(design)$rank, nrow(design) - qr(design)$rank))
Selected injections: 38
Biological plants: 12
Complete plot pairs: 6
Pooled QC, blanks, standards: 8 10 8
Expected source bytes: 1090534231
Design rank and residual degrees of freedom: 7 5
pair_plot <- ggplot(plants, aes(species, plot, color = species)) +
geom_line(aes(group = plot), color = "#b8c2cc", linewidth = 0.7) +
geom_point(size = 3.5) +
geom_text(aes(label = sample_id), nudge_y = 0.18, size = 3,
color = "#263238") +
scale_color_manual(values = c("#286b86", "#b85c38")) +
labs(x = NULL, y = "Field plot", title = "Six matched plant pairs") +
theme_minimal(base_size = 11) +
theme(legend.position = "none", axis.text.x = element_text(size = 9))
role_table <- data.frame(role = factor(role_levels, levels = role_levels),
injections = as.integer(role_counts))
role_plot <- ggplot(role_table, aes(injections, role)) +
geom_col(fill = "#286b86", width = 0.65) +
geom_text(aes(label = injections), hjust = -0.3, size = 3.5) +
scale_x_continuous(limits = c(0, 14), breaks = c(0, 4, 8, 12)) +
labs(x = "Injections", y = NULL, title = "Controls remain separate") +
theme_minimal(base_size = 11)
ggsave("outputs/design_r.png", pair_plot + role_plot,
width = 10, height = 4.2, dpi = 160, bg = "white")

Six plot pairs form the biological design, and four input roles remain separate.

These checks establish metadata agreement and an estimable complete-pair design. The primary execution record preserves those separate checks, and controls and run order examine the acquisition sequence.

  • MTBLS865 study and protocols

    The deposit identifies the plant experiment and its analytical protocols. Compare its biological samples, repeated pooled QC material, blanks, and standards before joining injection records.

  • MSI chemical-analysis reporting standards

    The paper specifies metadata for sample preparation, instruments, acquisition, and preprocessing. These records explain the experimental context that a file checksum cannot supply.