Distinguish ion evidence from compound identity
A reproducible feature can remain chemically unknown. Its accurate mass, retention time, isotope pattern, and proposed adduct describe an ion signal. They do not establish a unique molecular structure. The species comparison therefore keeps feature identifiers through its tables and figures.
This workflow supplies negative-mode MS1 evidence. It does not analyze the study’s separate pooled MS/MS files or compare biological features with reference standards under an identity-confirmation procedure. A significant species effect changes neither boundary.
Preserve what the adduct algorithm actually reports
Section titled “Preserve what the adduct algorithm actually reports”MetaboliteAdductDecharger proposes groups of related ions. The executed workflow preserves its annotated feature map, which retains individual ion areas. It does not replace each group with a summed neutral-compound quantity.
The distinction also affects annotations. OpenMS assigns the default deprotonation formula to an ungrouped ion with a known charge. That default is an assumption, not evidence from another matching ion. The preparation preserves the original Group field and the ungrouped flags from the OpenMS 3.0.0 implementation.
Both examples count a candidate relation only when at least two retained observations share an injection and group. They also require the observation to lack an ungrouped flag. Group numbers are local to an injection; matching numbers in two files do not define the same compound.
The executed data produce no retained candidate ion relations under that rule. Default deprotonation labels do not turn the ungrouped observations into supporting adduct pairs.
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", "features.tsv.gz", "feature_observations.tsv.gz"))
features <- read.delim(gzfile("/fixtures/features.tsv.gz"), colClasses = c(feature_id = "character"))observations <- read.delim(gzfile("/fixtures/feature_observations.tsv.gz"), colClasses = c(feature_id = "character", source_feature_id = "character", adduct_group = "character"))metadata <- read.delim("/fixtures/sample_metadata.tsv")stopifnot(!anyDuplicated(features$feature_id))stopifnot(setequal(features$feature_id, observations$feature_id))stopifnot(!anyDuplicated(observations[c("feature_id", "injection_id")]))stopifnot(!anyNA(observations$adduct_group))group_key <- paste(observations$injection_id, observations$adduct_group, sep = ":")group_sizes <- table(group_key)observations$group_size <- as.integer(group_sizes[group_key])observations$candidate_relation <- observations$group_size > 1L & observations$ungrouped == 0Lfeature_index <- match(observations$feature_id, features$feature_id)evidence <- data.frame( feature_id = features$feature_id, observations = tabulate(feature_index, nbins = nrow(features)), related_observations = tabulate( feature_index[observations$candidate_relation], nbins = nrow(features)), default_only_observations = tabulate( feature_index[observations$ungrouped == 1L], nbins = nrow(features)))evidence$msms_identification <- FALSEevidence$confirmed_identity <- FALSEwrite.csv(evidence, "outputs/evidence_r.csv", row.names = FALSE)metrics <- list(features = nrow(features), related_features = sum(evidence$related_observations > 0), related_observations = sum(observations$candidate_relation), msms_identifications = 0L, confirmed_identities = 0L)write_json(metrics, "outputs/metrics_r.json", auto_unbox = TRUE)cat(sprintf("Retained ion features: %d\n", metrics$features))cat(sprintf("Features with candidate ion relations: %d\n", metrics$related_features))cat("MS/MS identifications in this analysis: 0\n")cat("Confirmed biological compound identities: 0\n")Retained ion features: 96101Features with candidate ion relations: 0MS/MS identifications in this analysis: 0Confirmed biological compound identities: 0qc_id <- metadata$injection_id[metadata$role == "pooled_qc"][1]qc <- observations[observations$injection_id == qc_id, ]qc$evidence <- ifelse(qc$candidate_relation, "Candidate relation", "No retained partner")ion_plot <- ggplot(qc, aes(aligned_retention_time_seconds / 60, mz, color = evidence)) + geom_point(size = 1.1, alpha = 0.65) + scale_color_manual(values = c("Candidate relation" = "#c46536", "No retained partner" = "#7b8c99")) + labs(x = "Aligned retention time in minutes", y = "Observed m/z", color = NULL, title = paste("Ion evidence in", qc_id)) + theme_minimal(base_size = 12) + theme(legend.position = "bottom")ggsave("outputs/adduct_evidence_r.png", ion_plot, width = 8.5, height = 5, dpi = 160, bg = "white")counts <- data.frame( evidence = factor(c("Observed features", "Candidate ion relations", "MS/MS identities", "Confirmed identities"), levels = c("Observed features", "Candidate ion relations", "MS/MS identities", "Confirmed identities")), features = c(metrics$features, metrics$related_features, 0, 0))evidence_plot <- ggplot(counts, aes(evidence, features)) + geom_col(fill = "#286b86") + geom_text(aes(label = features), vjust = -0.3) + scale_y_continuous(expand = expansion(mult = c(0, 0.12))) + labs(x = NULL, y = "Features", title = "Available evidence has distinct limits") + theme_minimal(base_size = 11)ggsave("outputs/identity_evidence_r.png", evidence_plot, width = 8.5, height = 4.4, dpi = 160, bg = "white")

import jsonimport sysfrom pathlib import Path
import matplotlib.pyplot as pltimport numpy as npimport pandas as pd
sys.path.insert(0, "/shared")from validate_fixtures import validate_fixtures
validate_fixtures(["sample_metadata.tsv", "features.tsv.gz", "feature_observations.tsv.gz"])
features = pd.read_csv("/fixtures/features.tsv.gz", sep="\t", dtype={"feature_id": str})observations = pd.read_csv( "/fixtures/feature_observations.tsv.gz", sep="\t", dtype={"feature_id": str, "source_feature_id": str, "adduct_group": str})metadata = pd.read_csv("/fixtures/sample_metadata.tsv", sep="\t")assert features["feature_id"].is_uniqueassert set(features["feature_id"]) == set(observations["feature_id"])assert not observations.duplicated(["feature_id", "injection_id"]).any()assert observations["adduct_group"].notna().all()groups = observations.groupby(["injection_id", "adduct_group"])observations["group_size"] = groups["feature_id"].transform("size")observations["candidate_relation"] = observations["group_size"].gt(1)observations["candidate_relation"] &= observations["ungrouped"].eq(0)observations["default_only"] = observations["ungrouped"].eq(1)evidence = observations.groupby("feature_id").agg( observations=("injection_id", "size"), related_observations=("candidate_relation", "sum"), default_only_observations=("default_only", "sum"),)evidence = evidence.reindex(features["feature_id"]).reset_index()evidence["msms_identification"] = Falseevidence["confirmed_identity"] = Falseevidence.to_csv("outputs/evidence_python.csv", index=False)r_evidence = pd.read_csv("outputs/evidence_r.csv", dtype={"feature_id": str})pd.testing.assert_frame_equal(evidence, r_evidence, check_dtype=False)metrics = { "features": len(features), "related_features": int(evidence["related_observations"].gt(0).sum()), "related_observations": int(observations["candidate_relation"].sum()), "msms_identifications": 0, "confirmed_identities": 0,}Path("outputs/metrics_python.json").write_text(json.dumps(metrics, indent=2))print(f"Retained ion features: {metrics['features']}")print("Features with candidate ion relations:", metrics["related_features"])print("MS/MS identifications in this analysis: 0")print("Confirmed biological compound identities: 0")Retained ion features: 96101Features with candidate ion relations: 0MS/MS identifications in this analysis: 0Confirmed biological compound identities: 0qc_id = metadata.loc[metadata["role"].eq("pooled_qc"), "injection_id"].iloc[0]qc = observations.loc[observations["injection_id"].eq(qc_id)]figure, axis = plt.subplots(figsize=(8.5, 5))for flag, label, color in [ (False, "No retained partner", "#7b8c99"), (True, "Candidate relation", "#c46536"),]: selected = qc.loc[qc["candidate_relation"].eq(flag)] axis.scatter(selected["aligned_retention_time_seconds"] / 60, selected["mz"], s=9, alpha=0.65, color=color, label=label)axis.set_xlabel("Aligned retention time in minutes")axis.set_ylabel("Observed m/z")axis.set_title(f"Ion evidence in {qc_id}")axis.legend(loc="upper center", bbox_to_anchor=(0.5, -0.16), ncol=2)figure.tight_layout()figure.savefig("outputs/adduct_evidence_python.png", dpi=160, facecolor="white")plt.close(figure)labels = ["Observed features", "Candidate ion relations", "MS/MS identities", "Confirmed identities"]counts = [metrics["features"], metrics["related_features"], 0, 0]figure, axis = plt.subplots(figsize=(8.5, 4.4))positions = np.arange(len(labels))axis.bar(positions, counts, color="#286b86")for index, count in enumerate(counts): axis.text(index, count + max(counts) * 0.02, str(count), ha="center")axis.set_xticks(positions, labels, fontsize=9)axis.set_ylim(0, max(counts) * 1.15)axis.set_ylabel("Features")axis.set_title("Available evidence has distinct limits")figure.tight_layout()figure.savefig("outputs/identity_evidence_python.png", dpi=160, facecolor="white")plt.close(figure)

Keep the standard checks within their scope
Section titled “Keep the standard checks within their scope”The control lesson extracts three declared mass channels from known MM8 material. A channel can contain more than one chromatographic peak, and a matching mass can have several chemical explanations. Its total area therefore supports a repeatability check for that channel. It does not transfer a compound name to every biological feature inside the same mass window.
Confirmation requires a declared identity procedure with suitable orthogonal evidence and reference material. The selected workflow has neither biological MS/MS matching nor a validated retention-time match to a reference standard. The pathway lesson consequently uses feature-level figures and explains the additional evidence required for a pathway analysis.
Further reading
Section titled “Further reading”-
Sumner and colleagues on chemical-analysis reporting
The MSI paper distinguishes identified compounds, putative annotations, compound classes, and unknowns. It requires orthogonal evidence against authentic material for its highest identification level.
-
OpenMS 3.0.0 adduct-deconvolution source
The original implementation records ungrouped ions and assigns default adducts to eligible singletons. These operations explain why a default label does not establish a related-ion group.