Skip to content

Reuse public data with an accession and file manifest

A study accession identifies an experiment, but it does not tell you which matrix column belongs to which donor. That link needs evidence from the sample records and the processed data. This lesson connects GEO study GSE52778 to its sequencing runs, checks downloaded files, and builds a manifest for an analysis that can run without network access.

The study contains four primary airway smooth muscle cell lines under four conditions. We use the eight untreated and dexamethasone samples distributed in the airway count object. Each cell line contributes one sample to each of these two conditions, so the biological sample size is four paired cell lines. The other eight GEO samples received albuterol, alone or with dexamethasone.

Download the complete lesson bundle. It contains the archived inputs, the source manifest, the retrieval script, and the R analysis script. Extract the bundle and run the analysis from its root. The bundle’s execution_notes.md describes the pinned rnaseq:0.5.0 environment. Building that image requires the private companion repository’s build files. With that image available, bash run.sh executes the bundled analysis in Podman with network access disabled. The analysis script also runs in an R environment with SummarizedExperiment installed; use Rscript public_data_reuse.R from the extracted bundle directory.

The source manifest records the upstream URLs, local filenames, byte counts, MD5 values, and SHA256 values. The download receipts record the retrieval time and the hashes of the bytes received from each upstream server. These are different records. A source manifest specifies the expected input; a receipt records what a download returned.

The saved fetch_sources.py script performs the optional network preparation. It uses curl to download GEO metadata, an ENA run report, and the versioned airway source archive. It extracts only the count object from that archive. ENA can return records in different orders, so the script sorts its report by run accession before it checks the local digest. It records the original response digest too. If a source changes, the script stops before it replaces any local input.

Terminal window
uv run --no-project python fetch_sources.py --destination inputs

This command retrieves metadata and processed counts. It does not download FASTQ files or reproduce the alignment that created the count object. The rest of this page reads the saved files and requires no network access.

The first check compares both digests and the byte count for each input with the source manifest. sha256sum is available in the Linux analysis container. Keep the manifest with the data so a later run can detect a replaced or incomplete file.

library(SummarizedExperiment)
dir.create("outputs", showWarnings = FALSE)
source_manifest <- read.csv("source_manifest.csv", stringsAsFactors = FALSE)
input_paths <- file.path("inputs", source_manifest$filename)
stopifnot(all(file.exists(input_paths)))
observed_sha256 <- system2("sha256sum", shQuote(input_paths), stdout = TRUE)
observed_sha256 <- sub(" .*", "", observed_sha256)
stopifnot(
identical(observed_sha256, source_manifest$local_sha256),
identical(unname(tools::md5sum(input_paths)), source_manifest$local_md5),
all(file.info(input_paths)$size == source_manifest$local_bytes)
)
cat(sprintf("Verified input files: %d\n", length(input_paths)))
cat("Checks: SHA256, MD5, and byte count\n")
Verified input files: 3
Checks: SHA256, MD5, and byte count

The GEO family file contains one block per sample. We read the treatment and cell line from those blocks, together with their BioSample and SRA experiment accessions. We do not infer a treatment from a matrix column’s position.

The parser requires each field exactly once. That rule suits this study’s records; another study can use different characteristic names or repeated fields. Inspect those records before you change the parser.

#' Read one required field from a GEO SOFT sample block.
#'
#' @param block Character vector containing one sample block.
#' @param prefix Exact field prefix, including its separator.
#' @return The single field value.
GetSoftValue <- function(block, prefix) {
values <- block[startsWith(block, prefix)]
if (length(values) != 1L) {
stop("Expected one GEO field: ", prefix)
}
substring(values, nchar(prefix) + 1L)
}
soft <- readLines(gzfile("inputs/gse52778_family.soft.gz"), warn = FALSE)
sample_starts <- grep("^\\^SAMPLE = ", soft)
sample_ends <- c(sample_starts[-1] - 1L, length(soft))
sample_records <- vector("list", length(sample_starts))
for (index in seq_along(sample_starts)) {
block <- soft[sample_starts[index]:sample_ends[index]]
sample_records[[index]] <- data.frame(
geo_accession = GetSoftValue(block, "!Sample_geo_accession = "),
title = GetSoftValue(block, "!Sample_title = "),
cell = GetSoftValue(block, "!Sample_characteristics_ch1 = cell line: "),
treatment = GetSoftValue(
block, "!Sample_characteristics_ch1 = treatment: "
),
biosample = basename(GetSoftValue(
block, "!Sample_relation = BioSample: "
)),
experiment = sub(".*term=", "", GetSoftValue(
block, "!Sample_relation = SRA: "
)),
stringsAsFactors = FALSE
)
}
geo_samples <- do.call(rbind, sample_records)
stopifnot(!anyDuplicated(geo_samples$geo_accession))
design <- table(geo_samples$cell, geo_samples$treatment)
stopifnot(all(design == 1L))
cat(sprintf("GEO samples: %d\n", nrow(geo_samples)))
cat(sprintf("Cell lines: %d\n", nrow(design)))
print(as.data.frame.matrix(design))
GEO samples: 16
Cell lines: 4
Albuterol Albuterol_Dexamethasone Dexamethasone Untreated
N052611 1 1 1 1
N061011 1 1 1 1
N080611 1 1 1 1
N61311 1 1 1 1

Four conditions do not create four independent donors per cell line. The treatment samples share the same biological source. Keep cell in the metadata when you form a paired contrast or a model with a cell line term.

Connect GEO samples to raw sequencing runs

Section titled “Connect GEO samples to raw sequencing runs”

GEO identifies samples with GSM accessions and SRA experiments with SRX accessions. ENA’s run report links each experiment to its SRR run accession, BioSample accession, FASTQ locations, and archive MD5 values.

This study has one run per experiment. The checks below make that relationship explicit before the join. A study with several runs per experiment needs a separate run table; those runs are technical partitions of the library and must not increase the biological sample size.

ena_runs <- read.delim("inputs/ena_runs.tsv", stringsAsFactors = FALSE)
stopifnot(
!anyDuplicated(geo_samples$experiment),
!anyDuplicated(ena_runs$experiment_accession),
!anyDuplicated(ena_runs$run_accession),
setequal(geo_samples$experiment, ena_runs$experiment_accession),
all(ena_runs$study_accession == "PRJNA229998")
)
sample_manifest <- merge(
geo_samples, ena_runs, by.x = "experiment",
by.y = "experiment_accession", all = TRUE, sort = FALSE
)
stopifnot(
!anyNA(sample_manifest),
all(sample_manifest$biosample == sample_manifest$sample_accession),
all(sample_manifest$geo_accession == sample_manifest$sample_alias),
all(sample_manifest$geo_accession == sample_manifest$experiment_alias),
all(sample_manifest$library_layout == "PAIRED"),
all(sample_manifest$library_strategy == "RNA-Seq")
)
sample_manifest <- sample_manifest[
order(sample_manifest$geo_accession),
]
write.csv(
sample_manifest, "outputs/study_sample_manifest.csv", row.names = FALSE
)
cat(sprintf("Matched GEO samples and ENA runs: %d\n", nrow(sample_manifest)))
cat("BioSample and both GEO alias checks agree for every run.\n")
Matched GEO samples and ENA runs: 16
BioSample and both GEO alias checks agree for every run.

The airway package contains gene counts from a separate analysis of these reads. Its construction vignette documents STAR alignment to GRCh37 with Ensembl release 75 and summarizeOverlaps counts. These counts are not the FPKM values in GEO’s submitted supplementary matrix. FPKM values must not be passed to a count model as if they were raw gene counts.

The count object comes from Michael Love’s airway 1.32.0 source archive, which declares LGPL. The source and license notice identifies the object and its construction source. The input bundle includes the unchanged data/airway.RData member under the local filename airway_counts.rdata; the source manifest records both names and digests.

loaded_names <- load("inputs/airway_counts.rdata")
stopifnot(identical(loaded_names, "airway"))
counts <- assay(airway, "counts")
package_metadata <- as.data.frame(colData(airway))
column_match <- match(colnames(counts), sample_manifest$run_accession)
stopifnot(!anyNA(column_match), !anyDuplicated(column_match))
analysis_manifest <- sample_manifest[column_match, ]
expected_treatment <- ifelse(
package_metadata$dex == "trt", "Dexamethasone", "Untreated"
)
stopifnot(
identical(colnames(counts), analysis_manifest$run_accession),
all(package_metadata$SampleName == analysis_manifest$geo_accession),
all(package_metadata$cell == analysis_manifest$cell),
all(expected_treatment == analysis_manifest$treatment),
all(package_metadata$albut == "untrt"),
all(is.finite(counts)), all(counts >= 0), all(counts == round(counts))
)
analysis_design <- table(analysis_manifest$cell, analysis_manifest$treatment)
stopifnot(all(analysis_design == 1L), ncol(analysis_design) == 2L)
analysis_manifest$count_column <- colnames(counts)
analysis_manifest$assembly <- "GRCh37"
analysis_manifest$annotation <- "Ensembl release 75"
analysis_manifest$processed_source <- "airway 1.32.0"
analysis_manifest$library_count_sum <- colSums(counts)
write.csv(
analysis_manifest, "outputs/analysis_sample_manifest.csv", row.names = FALSE
)
write.csv(counts, "outputs/airway_gene_counts.csv")
cat("Count matrix:", nrow(counts), "genes by", ncol(counts), "samples\n")
cat("Paired biological units:", nrow(analysis_design), "cell lines\n")
print(analysis_manifest[, c("geo_accession", "run_accession", "cell",
"treatment")], row.names = FALSE)
Count matrix: 63677 genes by 8 samples
Paired biological units: 4 cell lines
geo_accession run_accession cell treatment
GSM1275862 SRR1039508 N61311 Untreated
GSM1275863 SRR1039509 N61311 Dexamethasone
GSM1275866 SRR1039512 N052611 Untreated
GSM1275867 SRR1039513 N052611 Dexamethasone
GSM1275870 SRR1039516 N080611 Untreated
GSM1275871 SRR1039517 N080611 Dexamethasone
GSM1275874 SRR1039520 N061011 Untreated
GSM1275875 SRR1039521 N061011 Dexamethasone

The processed columns and their metadata now share the same order because match() used the run accessions. The package’s GEO identifiers, cell lines, and treatments provide a second check against the independently retrieved archive records. A match in row count alone would miss a swapped sample.

ENA separates multiple file locations, MD5 values, and byte counts with semicolons. Split these three fields together. Some paired libraries also have an unpaired FASTQ file, so a rule that keeps exactly two files per run loses part of the archived data.

raw_records <- list()
record_index <- 0L
for (index in seq_len(nrow(sample_manifest))) {
sample <- sample_manifest[index, ]
urls <- strsplit(sample$fastq_ftp, ";", fixed = TRUE)[[1]]
md5_values <- strsplit(sample$fastq_md5, ";", fixed = TRUE)[[1]]
byte_counts <- strsplit(sample$fastq_bytes, ";", fixed = TRUE)[[1]]
stopifnot(length(urls) == length(md5_values))
stopifnot(length(urls) == length(byte_counts))
for (file_index in seq_along(urls)) {
record_index <- record_index + 1L
raw_records[[record_index]] <- data.frame(
geo_accession = sample$geo_accession,
run_accession = sample$run_accession,
selected_for_analysis = sample$run_accession %in% colnames(counts),
url = paste0("https://", urls[file_index]),
archive_md5 = md5_values[file_index],
archive_bytes = as.numeric(byte_counts[file_index]),
download_status = "not_downloaded",
stringsAsFactors = FALSE
)
}
}
raw_manifest <- do.call(rbind, raw_records)
stopifnot(
!anyDuplicated(raw_manifest$url),
all(grepl("^[0-9a-f]{32}$", raw_manifest$archive_md5)),
all(is.finite(raw_manifest$archive_bytes)),
all(raw_manifest$archive_bytes > 0)
)
write.csv(raw_manifest, "outputs/raw_file_manifest.csv", row.names = FALSE)
files_per_run <- table(raw_manifest$run_accession)
cat(sprintf("Raw files listed: %d\n", nrow(raw_manifest)))
cat(sprintf("Runs with more than two files: %d\n", sum(files_per_run > 2L)))
cat(sprintf("Listed raw bytes: %.0f\n", sum(raw_manifest$archive_bytes)))
cat("Raw files downloaded by this lesson: 0\n")
Raw files listed: 39
Runs with more than two files: 7
Listed raw bytes: 50359986052
Raw files downloaded by this lesson: 0

An archive MD5 describes the file that the archive expects. It does not prove that a local FASTQ file exists or that its bytes are correct. After a raw read download, calculate its digest, compare it with archive_md5, and record that result with the local path. Keep not_downloaded until that work is complete.

The sum of assigned gene counts differs between libraries. This plot shows those totals by cell line and condition so an unexpected sample label or library total has a visible place in the review. A total is not a normalized expression measurement, and it does not test a treatment effect.

colors <- c(Untreated = "#31708e", Dexamethasone = "#bd6439")
cell_levels <- sort(unique(analysis_manifest$cell))
positions <- match(analysis_manifest$cell, cell_levels)
positions <- positions + ifelse(
analysis_manifest$treatment == "Untreated", -0.12, 0.12
)
png("outputs/public_data_reuse_libraries.png", width = 1500, height = 950,
res = 180)
par(mar = c(5, 5, 3, 1))
plot(
positions, analysis_manifest$library_count_sum / 1e6,
col = colors[analysis_manifest$treatment], pch = 19, cex = 1.5,
xaxt = "n", xlim = c(0.5, length(cell_levels) + 0.5),
xlab = "Cell line", ylab = "Assigned gene counts, millions",
main = "Eight libraries retain four paired cell lines"
)
axis(1, at = seq_along(cell_levels), labels = cell_levels)
legend("topright", legend = names(colors), col = colors, pch = 19, bty = "n")
invisible(dev.off())

The plot shows assigned gene counts for the untreated and dexamethasone libraries from each of four cell lines.

The study manifest preserves all GEO samples. The analysis manifest preserves the selected count columns and their paired design. The raw file manifest preserves the file locations, expected digests, and download status. Use the selected counts and metadata with the RNA sequencing workflow when you are ready to fit a count model.

Himes and colleagues, 2014 report the airway smooth muscle RNA-seq experiment that the airway data package holds.

The GSE52778 study record describes the treatments, sample records, and submitted processed files. Read the processing description before you decide whether an available matrix contains counts or normalized expression.

The airway 1.32.0 construction vignette explains how the processed count object was built and how its sample table connects to GEO and SRA. Its alignment and annotation differ from the submitted GEO FPKM matrix.

The ENA programmatic search documentation explains how to select fields from archive records. The FASTQ location, MD5, and size fields let you prepare a raw file manifest before a large download.