Separate missing measurements from absence
A missing protein abundance is an absent measurement, not a measured concentration of zero. DDA precursor selection, peptide identification, interference, and feature extraction can each remove an observation. A single missing entry does not identify which mechanism caused it.
The canonical matrix preserves missing values explicitly. We inspect their relation to condition, abundance, peptide support, and sample quality before choosing an analysis population.
Keep the detection pattern visible
Section titled “Keep the detection pattern visible”Each group receives a measured-culture count in parental and resistant conditions. The detection table distinguishes complete groups, partially measured groups, groups observed in only one condition, and groups with no usable quantitative signal.
Those categories describe the exported measurements. They do not establish that a protein is biologically absent from a culture. The available cohort has no measurement-specific detection limit that would justify that stronger statement.
Missingness can also depend on abundance. We compare detection frequency with observed intensity and retain the number of observations behind each estimate. A mean based on one culture should not appear as equally supported as a mean based on all three.
Define the main analysis population
Section titled “Define the main analysis population”The main comparison requires two group-unique peptide sequences and observed abundance in at least two cultures per condition. It uses only observed log2 values when it fits each protein group.
This rule preserves some partially measured groups while requiring information on both sides of the contrast. Its statistical interpretation still depends on the missingness mechanism. If missingness depends on unobserved abundance, an observed-value model can be biased.
We do not replace every missing value with a small constant or a random draw from a low-intensity distribution. Those operations add assumptions and apparent precision. A different scientific question could justify an explicit censored model, but this cohort does not supply a validated censoring threshold.
Compare declared sensitivities
Section titled “Compare declared sensitivities”The complete-case sensitivity uses only groups measured in all six cultures. It changes the eligible protein population, so its total discovery count is not directly interchangeable with the main count. We compare effects for groups present in both analyses and report the number retained by each rule.
The normalization sensitivity compares the declared median adjustment with unnormalized log2 abundance. Both analyses use the same observed entries and the same condition contrast. Their difference exposes dependence on the reference distribution rather than pretending to test a new biological experiment.
Groups detected in only one condition receive a separate descriptive table. It includes detection counts, observed values, peptide support, and full group membership. It does not assign a continuous abundance p-value by inventing measurements in the other condition.
Continue with differential abundance after the missingness review defines which protein groups enter each analysis.
Compare the observed-value populations
Section titled “Compare the observed-value populations”The detection grid counts cultures, not spectra. Its axes run from zero through three because each condition has three independent cultures. The abundance display uses each group’s observed log2 median and leaves an entirely absent group without a coordinate.
Interpret this cohort
Section titled “Interpret this cohort”The primary observation filter retains 463 groups, and the complete observation filter retains 341 groups. The descriptive table retains 532 condition-restricted candidates.
Detection differs between conditions in this cohort. The observed value analysis preserves that restriction instead of treating every absent measurement as a small intensity.
library(ggplot2)library(jsonlite)source("/shared/ms_common.R")
data <- PrepareMsAnalysis(LoadMsData())observed <- is.finite(data$log_abundance)medians <- rep(NA_real_, nrow(observed))for (index in seq_len(nrow(observed))) { values <- data$log_abundance[index, observed[index, ]] if (length(values)) medians[index] <- median(values)}restricted <- data$candidate & ((data$n_parental == 0L & data$n_resistant > 0L) | (data$n_resistant == 0L & data$n_parental > 0L))record <- data.frame( group_id = data$groups$group_id, n_parental = data$n_parental, n_resistant = data$n_resistant, observed_median_log2 = medians, candidate = data$candidate, primary_eligible = data$eligible, complete_eligible = data$complete, condition_restricted = restricted)write.csv(record, "outputs/detection_patterns_r.csv", row.names = FALSE, na = "NA")descriptive <- data.frame( record, members = data$groups$members, unique_peptide_count = data$groups$unique_peptide_count, data$abundance, check.names = FALSE)write.csv(descriptive[restricted, ], "outputs/condition_restricted_r.csv", row.names = FALSE, na = "NA")metrics <- list(candidate_groups = sum(data$candidate), primary_eligible = sum(data$eligible), complete_eligible = sum(data$complete), condition_restricted = sum(restricted), absent_measurements = sum(!observed))write_json(metrics, "outputs/metrics_r.json", auto_unbox = TRUE)cat("Groups with two observations per condition:", metrics$primary_eligible, "\n")cat("Groups observed in all six cultures:", metrics$complete_eligible, "\n")cat("Condition-restricted candidate groups:", metrics$condition_restricted, "\n")Groups with two observations per condition: 463Groups observed in all six cultures: 341Condition-restricted candidate groups: 532grid <- as.data.frame(table( factor(record$n_parental[record$candidate], levels = 0:3), factor(record$n_resistant[record$candidate], levels = 0:3)))names(grid) <- c("parental", "resistant", "groups")detection <- ggplot(grid, aes(parental, resistant, fill = groups)) + geom_tile(color = "white") + geom_text(aes(label = groups), color = "black") + scale_fill_gradient(low = "#edf3f5", high = "#4489a4") + labs(x = "Detected parental cultures", y = "Detected resistant cultures", fill = "Groups", title = "Candidate protein-group detection") + theme_minimal(base_size = 12)ggsave("outputs/detection_grid_r.png", detection, width = 6.5, height = 5.5, dpi = 160, bg = "white")intensity <- ggplot(record[record$candidate, ], aes(n_parental + n_resistant, observed_median_log2)) + geom_point(alpha = 0.4, size = 1, position = position_jitter(width = 0.12, height = 0, seed = 73)) + scale_x_continuous(breaks = 0:6) + labs(x = "Detected cultures", y = "Observed median log2 abundance", title = "Detection and measured abundance") + theme_minimal(base_size = 11)ggsave("outputs/detection_intensity_r.png", intensity, width = 8, height = 4.5, dpi = 160, bg = "white")

import importlib.utilimport jsonfrom pathlib import Path
import matplotlib.pyplot as pltimport numpy as npimport pandas as pd
spec = importlib.util.spec_from_file_location("ms", "/shared/ms_common.py")ms = importlib.util.module_from_spec(spec)spec.loader.exec_module(ms)data = ms.prepare_ms_analysis(ms.load_ms_data())observed = np.isfinite(data["log_abundance"])medians = np.full(len(observed), np.nan)for index, present in enumerate(observed): if present.any(): medians[index] = np.median(data["log_abundance"][index, present])restricted = data["candidate"] & ( ((data["n_parental"] == 0) & (data["n_resistant"] > 0)) | ((data["n_resistant"] == 0) & (data["n_parental"] > 0)))record = pd.DataFrame({ "group_id": data["groups"]["group_id"], "n_parental": data["n_parental"], "n_resistant": data["n_resistant"], "observed_median_log2": medians, "candidate": data["candidate"], "primary_eligible": data["eligible"], "complete_eligible": data["complete"], "condition_restricted": restricted,})record.to_csv("outputs/detection_patterns_python.csv", index=False, na_rep="NA")descriptive = record.copy()descriptive["members"] = data["groups"]["members"]descriptive["unique_peptide_count"] = data["groups"]["unique_peptide_count"]descriptive[data["samples"]["sample_id"]] = data["abundance"]descriptive = descriptive.loc[restricted].reset_index(drop=True)descriptive.to_csv("outputs/condition_restricted_python.csv", index=False, na_rep="NA")expected = pd.read_csv("outputs/condition_restricted_r.csv")pd.testing.assert_frame_equal(descriptive, expected, check_dtype=False, rtol=1e-12, atol=1e-12)expected = pd.read_csv("outputs/detection_patterns_r.csv")pd.testing.assert_frame_equal(record, expected, check_dtype=False, rtol=1e-12, atol=1e-12)metrics = { "candidate_groups": int(data["candidate"].sum()), "primary_eligible": int(data["eligible"].sum()), "complete_eligible": int(data["complete"].sum()), "condition_restricted": int(restricted.sum()), "absent_measurements": int((~observed).sum()),}Path("outputs/metrics_python.json").write_text(json.dumps(metrics, indent=2))print("Groups with two observations per condition:", metrics["primary_eligible"])print("Groups observed in all six cultures:", metrics["complete_eligible"])print("Condition-restricted candidate groups:", metrics["condition_restricted"])Groups with two observations per condition: 463Groups observed in all six cultures: 341Condition-restricted candidate groups: 532grid = np.zeros((4, 4), dtype=int)for row in record.loc[record["candidate"]].itertuples(index=False): grid[row.n_resistant, row.n_parental] += 1figure, axis = plt.subplots(figsize=(6.5, 5.5))image = axis.imshow(grid, origin="lower", cmap="Blues")for row in range(4): for column in range(4): axis.text(column, row, str(grid[row, column]), ha="center", va="center")axis.set_xticks(range(4))axis.set_yticks(range(4))axis.set_xlabel("Detected parental cultures")axis.set_ylabel("Detected resistant cultures")axis.set_title("Candidate protein-group detection")figure.colorbar(image, ax=axis, label="Groups")figure.tight_layout()figure.savefig("outputs/detection_grid_python.png", dpi=160, facecolor="white")plt.close(figure)selected = record.loc[record["candidate"]]rng = np.random.default_rng(73)x = selected["n_parental"] + selected["n_resistant"]x = x.to_numpy(dtype=float) + rng.uniform(-0.12, 0.12, len(selected))figure, axis = plt.subplots(figsize=(8, 4.5))axis.scatter(x, selected["observed_median_log2"], s=5, alpha=0.4)axis.set_xticks(range(7))axis.set_xlabel("Detected cultures")axis.set_ylabel("Observed median log2 abundance")axis.set_title("Detection and measured abundance")figure.tight_layout()figure.savefig("outputs/detection_intensity_python.png", dpi=160, facecolor="white")plt.close(figure)

Scientific references
Section titled “Scientific references”Creedon et al., 2016 describe the parental and resistant cell cultures, biological triplicates and original mass spectrometry analysis. The teaching reanalysis uses a different software workflow.
Further reading
Section titled “Further reading”The pinned OpenMS ProteomicsLFQ implementation defines targeted-only feature detection and the peptide restrictions used for protein quantification. These settings help explain why a group can lack a reported abundance in one run.
Creedon and colleagues, 2016, describe the six biological cultures. Keep that design beside the missingness table before deciding which condition comparisons have observed support.