Verify the mass spectrometry cohort
The source manifest connects each raw file to a biological culture. We verify that connection before the search because a correct statistical model with reversed condition labels answers the wrong question.
PXD002057 contains three parental SKBR3 cultures and three cultures of the resistant SKBR3-AZDRc derivative. The original XML experiment titles state each condition and replicate. The archive README links those XML records to the raw files.
These examples inspect source metadata. The primary execution record tracks those separate checks.
The separate input preparation accepts all six complete raw files, totaling 13,972,629,221 bytes. Each matches its provider size and MD5, and the companion integrity record preserves its local SHA-256 value. The complete cohort passes its fresh primary gate and downstream sample review.
Read the same source records
Section titled “Read the same source records”The fixtures preserve the source annotations independently of the analysis labels. Both languages check exact raw-file joins, condition assignments, biological units, and source sizes. The expected source size describes the complete raw file, not a downloaded prefix.
library(digest)library(ggplot2)library(jsonlite)
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]))}samples <- read.delim("/fixtures/sample_metadata.tsv", check.names = FALSE)source <- read.delim("/fixtures/source_annotations.tsv", check.names = FALSE)samples <- samples[order(samples$run_id), ]source <- source[match(samples$raw_file, source$raw_file), ]condition_names <- c( parental = "Parental SKBR3 cells", resistant = "AZD8931-resistant SKBR3-AZDRc cells")stopifnot( nrow(samples) == 6L, !anyDuplicated(samples$sample_id), !anyDuplicated(samples$biological_unit), !anyDuplicated(samples$raw_file), !anyDuplicated(source$raw_file), identical(samples$raw_file, source$raw_file), all(source$source_condition == condition_names[samples$condition]), all(source$source_replicate == samples$biological_replicate), all(samples$source_xml == source$source_xml), all(samples$fraction == 1L), all(samples$acquisition == "DDA"), all(table(samples$condition) == 3L))samples$condition <- factor(samples$condition, levels = c("parental", "resistant"))design <- model.matrix(~ condition, data = samples)stopifnot(qr(design)$rank == ncol(design))design_table <- data.frame( sample_id = samples$sample_id, intercept = design[, 1], resistant = design[, 2])write.csv(design_table, "outputs/design_r.csv", row.names = FALSE)metrics <- list(samples = nrow(samples), parental = sum(samples$condition == "parental"), resistant = sum(samples$condition == "resistant"), expected_bytes = sum(samples$expected_bytes), design_rank = qr(design)$rank)write_json(metrics, "outputs/metrics_r.json", auto_unbox = TRUE)cat("Source files:", nrow(samples), "\n")cat("Parental cultures:", sum(samples$condition == "parental"), "\n")cat("Resistant cultures:", sum(samples$condition == "resistant"), "\n")cat("Expected raw bytes:", format(sum(samples$expected_bytes), scientific = FALSE), "\n")cat("Design rank:", qr(design)$rank, "\n")cat("Complete-profile residual degrees of freedom:", nrow(design) - qr(design)$rank, "\n")Source files: 6Parental cultures: 3Resistant cultures: 3Expected raw bytes: 13972629221Design rank: 2Complete-profile residual degrees of freedom: 4design_plot <- ggplot(samples, aes(biological_replicate, condition, color = condition)) + geom_point(size = 5) + geom_text(aes(label = sample_id), nudge_y = 0.17, color = "#263238", size = 3.8) + scale_x_continuous(breaks = 1:3, limits = c(0.6, 3.4)) + scale_y_discrete(expand = expansion(add = 0.5)) + scale_color_manual(values = c("#246783", "#b84b3b")) + labs(x = "Biological replicate within condition", y = NULL, title = "Six independently prepared cultures", subtitle = "Replicate numbers do not establish pairs") + theme_minimal(base_size = 12) + theme(legend.position = "none", panel.grid.minor = element_blank())ggsave("outputs/design_r.png", design_plot, width = 8, height = 3.8, dpi = 160, bg = "white")
import hashlibimport jsonfrom pathlib import Path
import matplotlib.pyplot as pltimport numpy as npimport pandas as pd
fixtures = Path("/fixtures")for entry in (fixtures / "SHA256SUMS").read_text().splitlines(): expected, filename = entry.split(maxsplit=1) actual = hashlib.sha256((fixtures / filename).read_bytes()).hexdigest() assert actual == expectedsamples = pd.read_csv(fixtures / "sample_metadata.tsv", sep="\t")source = pd.read_csv(fixtures / "source_annotations.tsv", sep="\t")samples = samples.sort_values("run_id").reset_index(drop=True)assert source["raw_file"].is_uniquesource = source.set_index("raw_file").loc[samples["raw_file"]]condition_names = { "parental": "Parental SKBR3 cells", "resistant": "AZD8931-resistant SKBR3-AZDRc cells",}assert len(samples) == 6for column in ("sample_id", "biological_unit", "raw_file"): assert samples[column].is_uniqueassert np.array_equal(source.index, samples["raw_file"])assert np.array_equal( source["source_condition"], samples["condition"].map(condition_names))assert np.array_equal( source["source_replicate"], samples["biological_replicate"])assert np.array_equal(source["source_xml"], samples["source_xml"])assert samples["fraction"].eq(1).all()assert samples["acquisition"].eq("DDA").all()assert samples["condition"].value_counts().eq(3).all()design = np.column_stack([ np.ones(len(samples)), samples["condition"].eq("resistant").astype(int)])assert np.linalg.matrix_rank(design) == design.shape[1]design_table = pd.DataFrame({ "sample_id": samples["sample_id"], "intercept": design[:, 0], "resistant": design[:, 1],})pd.testing.assert_frame_equal( design_table, pd.read_csv("outputs/design_r.csv"), check_dtype=False, check_exact=True)design_table.to_csv("outputs/design_python.csv", index=False)metrics = { "samples": len(samples), "parental": int(samples["condition"].eq("parental").sum()), "resistant": int(samples["condition"].eq("resistant").sum()), "expected_bytes": int(samples["expected_bytes"].sum()), "design_rank": int(np.linalg.matrix_rank(design)),}Path("outputs/metrics_python.json").write_text(json.dumps(metrics) + "\n")print(f"Source files: {len(samples)}")print(f"Parental cultures: {samples['condition'].eq('parental').sum()}")print(f"Resistant cultures: {samples['condition'].eq('resistant').sum()}")print(f"Expected raw bytes: {samples['expected_bytes'].sum()}")print(f"Design rank: {np.linalg.matrix_rank(design)}")print("Complete-profile residual degrees of freedom:", len(samples) - np.linalg.matrix_rank(design))Source files: 6Parental cultures: 3Resistant cultures: 3Expected raw bytes: 13972629221Design rank: 2Complete-profile residual degrees of freedom: 4figure, axis = plt.subplots(figsize=(8, 3.8))colors = {"parental": "#246783", "resistant": "#b84b3b"}for condition_index, condition in enumerate(("parental", "resistant")): subset = samples.loc[samples["condition"].eq(condition)] axis.scatter(subset["biological_replicate"], np.repeat(condition_index, len(subset)), color=colors[condition], s=100) for row in subset.itertuples(): axis.text(row.biological_replicate, condition_index + 0.15, row.sample_id, ha="center", color="#263238")axis.set(xlim=(0.6, 3.4), ylim=(-0.5, 1.5), xticks=[1, 2, 3], yticks=[0, 1], yticklabels=["parental", "resistant"], xlabel="Biological replicate within condition", title="Six independently prepared cultures")axis.text(0.5, 1.04, "Replicate numbers do not establish pairs", transform=axis.transAxes, ha="center", fontsize=10)axis.spines[["top", "right"]].set_visible(False)figure.tight_layout()figure.savefig("outputs/design_python.png", dpi=160, facecolor="white")plt.close(figure)
The two-column design contains an intercept and a resistant-condition indicator. Its residual degrees of freedom apply to a protein group observed in every culture. Missing measurements can reduce that number for an individual group.
The figure displays the biological design, not a measured quality result. The primary workflow converts all six raw files and retains identification and quantification evidence for the later lessons.
Further reading
Section titled “Further reading”The PXD002057 archive record supplies the deposited sample description and links the source experiment. The methods in Creedon and colleagues, 2016, describe the biological triplicates. Use both records when connecting raw filenames to independent cultures.