Skip to content

Inspect controls and acquisition order

The selected injections span a larger acquisition sequence. Their original counters preserve gaps between selected files, while their timestamps measure elapsed acquisition time. Replacing that sequence with row numbers would obscure both facts.

Pooled QC, blanks, and MM8 standards answer different questions. The pooled QC measures repeatability in a complex extract. The blanks reveal procedural background. The standard mixture supplies known material for a declared set of mass channels. None of these injections adds a biological plant to the species comparison.

The preparation reads acquisition timestamps from every complete mzML file and checks them against the original source selection. Both examples below recalculate elapsed time from those timestamps. They also require every biological injection to lie between the first and last selected pooled QC.

That cohort-wide condition is necessary but insufficient for feature correction. A feature can be absent from an early or late QC. The drift lesson checks the observed QC interval separately for each feature.

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(ggplot2)
library(jsonlite)
source("/shared/validate_fixtures.R")
ValidateFixtures(c("sample_metadata.tsv", "standard_chromatograms.tsv.gz",
"standard_summary.tsv", "standard_extraction.json"))
metadata <- read.delim("/fixtures/sample_metadata.tsv",
stringsAsFactors = FALSE)
metadata <- metadata[order(metadata$acquisition_counter), ]
timestamp_text <- sub("([+-][0-9]{2}):([0-9]{2})$", "\\1\\2",
metadata$acquisition_timestamp)
timestamp <- as.POSIXct(timestamp_text, format = "%Y-%m-%dT%H:%M:%OS%z",
tz = "UTC")
stopifnot(!anyNA(timestamp), all(diff(as.numeric(timestamp)) > 0))
stopifnot(all(diff(metadata$acquisition_counter) > 0))
elapsed <- as.numeric(difftime(timestamp, timestamp[1], units = "hours"))
stopifnot(max(abs(elapsed - metadata$elapsed_hours)) < 1e-8)
qc_time <- elapsed[metadata$role == "pooled_qc"]
plant_time <- elapsed[metadata$role == "biological"]
stopifnot(all(plant_time > min(qc_time)), all(plant_time < max(qc_time)))
chronology <- data.frame(injection_id = metadata$injection_id,
acquisition_counter = metadata$acquisition_counter,
elapsed_hours = elapsed, role = metadata$role)
write.csv(chronology, "outputs/chronology_r.csv", row.names = FALSE)
channels <- read.delim(gzfile("/fixtures/standard_chromatograms.tsv.gz"))
standards <- read.delim("/fixtures/standard_summary.tsv")
stopifnot(!anyDuplicated(standards[c("injection_id", "standard_name")]))
stopifnot(nrow(standards) == 24L)
stopifnot(length(unique(standards$injection_id)) == 8L)
standard_ids <- metadata$injection_id[metadata$role == "system_suitability"]
stopifnot(setequal(unique(standards$injection_id), standard_ids))
stopifnot(all(is.finite(channels$intensity)), all(channels$intensity >= 0))
stopifnot(all(channels$retention_time_seconds >= 0.6))
stopifnot(all(channels$retention_time_seconds < 1080))
recomputed <- numeric(nrow(standards))
for (index in seq_len(nrow(standards))) {
selected <- channels$injection_id == standards$injection_id[index] &
channels$standard_name == standards$standard_name[index]
values <- channels[selected, ]
values <- values[order(values$retention_time_seconds), ]
widths <- diff(values$retention_time_seconds)
stopifnot(length(widths) > 0L, all(widths > 0))
averages <- (head(values$intensity, -1) + tail(values$intensity, -1)) / 2
recomputed[index] <- sum(widths * averages)
}
relative_error <- abs(recomputed - standards$whole_window_area) /
pmax(standards$whole_window_area, 1)
stopifnot(max(relative_error) < 1e-6)
standards$recomputed_area <- recomputed
write.csv(standards, "outputs/standard_areas_r.csv", row.names = FALSE)
metrics <- list(injections = nrow(metadata),
standard_injections = length(unique(standards$injection_id)),
mass_channels = length(unique(standards$standard_name)),
channel_profiles = nrow(standards),
span_hours = max(elapsed),
max_area_relative_error = max(relative_error))
write_json(metrics, "outputs/metrics_r.json", auto_unbox = TRUE, digits = 16)
cat(sprintf("Selected injections: %d\n", nrow(metadata)))
cat(sprintf("Standard injections and mass channels: %d %d\n",
metrics$standard_injections, metrics$mass_channels))
cat(sprintf("Elapsed acquisition span: %.6f hours\n", max(elapsed)))
cat(sprintf("Complete standard channel profiles: %d\n", nrow(standards)))
Selected injections: 38
Standard injections and mass channels: 8 3
Elapsed acquisition span: 37.142175 hours
Complete standard channel profiles: 24
role_order <- c("process_blank", "system_suitability", "pooled_qc",
"biological")
metadata$role <- factor(metadata$role, levels = role_order)
order_plot <- ggplot(metadata, aes(elapsed_hours, role, color = role)) +
geom_point(size = 3) +
geom_vline(xintercept = range(qc_time), linetype = "dotted",
color = "#87919c") +
scale_color_manual(values = c("#87919c", "#9c6930", "#3c8c75", "#286b86")) +
labs(x = "Hours from the first selected acquisition", y = NULL,
title = "Original acquisition times preserve omitted intervals") +
theme_minimal(base_size = 12) + theme(legend.position = "none")
ggsave("outputs/run_order_r.png", order_plot, width = 9, height = 3.6,
dpi = 160, bg = "white")
channel_plot <- ggplot(channels, aes(retention_time_seconds / 60, intensity,
color = injection_id)) +
geom_line(linewidth = 0.35, alpha = 0.8) +
facet_wrap(~ standard_name, scales = "free_y", ncol = 1) +
scale_color_viridis_d() +
labs(x = "Retention time in minutes", y = "Ion signal",
color = "Standard injection",
title = "Three mass channels across eight MM8 injections") +
theme_minimal(base_size = 11)
ggsave("outputs/standard_channels_r.png", channel_plot, width = 9,
height = 7.4, dpi = 160, bg = "white")

The acquisition plot separates biological injections, pooled QC, blanks, and standards.

The standard chromatograms show three declared mass channels across eight injections.

Interpret the standard channels at their supported resolution

Section titled “Interpret the standard channels at their supported resolution”

The source protocol lists kinetin, rutin, and phlorizin in the MM8 mixture. The extraction preserves PubChem properties for those three selected constituents. Each channel uses the deprotonated exact mass with a 10 ppm window.

The interval includes scans from 0.6 seconds and excludes scans at or after 1,080 seconds. The source protocol places lithium-formate infusion at 18 minutes. Complete source files remain available, so this analytical boundary does not erase the calibration data.

Each reported area integrates the whole selected mass channel. It does not isolate one chromatographic peak, establish absolute concentration, or identify a biological feature. Extra peaks and changes in peak shape remain visible in the chromatograms. The identification lesson explains the additional evidence required for a compound assignment.