Skip to content

The section, the array, and the files

The example follows one anterior sagittal brain section from one mouse. Its capture array contains positions both under and outside tissue, while the filtered expression matrix contains only the provider’s tissue spots. Those two matrices describe different observation sets from the same experiment.

The 10x Genomics dataset provides the counts, coordinates, images, and archived reports under CC BY 4.0. Space Ranger 1.1.0 produced the archived outputs with the mm10-2020-A reference. This section starts with those outputs and calculates new downstream results. It does not rerun read alignment or validate the provider’s tissue classification.

Input Role
Filtered HDF5 matrix The matrix contains the provider-selected tissue spots.
Unfiltered HDF5 matrix The matrix contains every supplied array barcode.
Spatial archive The archive links barcodes to positions, images, and scale factors.
Metrics CSV The table contains archived Space Ranger metrics.
Web report The report records the archived primary analysis.

The unfiltered matrix is a count output. It is not a collection of raw sequencing reads. The local SHA-256 values identify the exact downloaded bytes; they are not independent checksums supplied by 10x Genomics.

The private companion repository contains the source manifest, preparation scripts, and locked spatial:0.1.0 image. Its runners mount the public input fixture at /fixtures and shared format readers at /shared. Access to that repository requires permission. The public dataset remains available directly from 10x Genomics.

Both examples check every selected column against its unfiltered source. The R example uses the same HDF5 reader through reticulate, then performs matrix comparisons in R. Later R calculations also run in R; the shared reader only handles the file format. Run each language’s blocks in order.

source("/shared/spatial_utils.R")
provenance <- fromJSON("/fixtures/provenance.json")
for (index in seq_len(nrow(provenance$files))) {
record <- provenance$files[index, ]
path <- file.path("/fixtures/source", record$filename)
stopifnot(file.info(path)$size == record$bytes)
stopifnot(digest::digest(file = path, algo = "sha256") == record$sha256)
}
data <- ReadCounts()
unfiltered <- ReadCounts("raw")
positions <- ReadPositions()
stopifnot(identical(data$features$feature_id, unfiltered$features$feature_id))
stopifnot(identical(data$features$symbol, unfiltered$features$symbol))
stopifnot(setequal(unfiltered$barcodes, positions$barcode))
tissue <- positions$barcode[positions$in_tissue == 1]
stopifnot(setequal(data$barcodes, tissue))
index <- match(data$barcodes, unfiltered$barcodes)
stopifnot(Matrix::nnzero(data$counts - unfiltered$counts[, index]) == 0)
dir.create("outputs", showWarnings = FALSE)
png("outputs/array_r.png", width = 1000, height = 760, res = 130)
plot(positions$array_col, -positions$array_row, pch = 16, cex = 0.45,
col = ifelse(positions$in_tissue == 1, "#168080", "#c9cdd2"),
asp = sqrt(3), xlab = "Array column", ylab = "Negative array row",
main = "One section on the complete capture array")
legend("bottomleft", c("Under tissue", "Outside tissue"),
col = c("#168080", "#c9cdd2"), pch = 16, bty = "n")
invisible(dev.off())
metrics <- list(features = nrow(data$counts), spots = ncol(data$counts),
array_spots = nrow(positions), umi = sum(data$counts),
raw_umi = sum(unfiltered$counts), donors = 1, sections = 1)
WriteMetrics(metrics)
cat(sprintf("The matrix contains %d genes and %d tissue spots.\n",
metrics$features, metrics$spots))
cat(sprintf("The array contains %d positions from one section.\n",
metrics$array_spots))
cat(sprintf("All filtered columns match their unfiltered source.\n"))
The matrix contains 32285 genes and 2695 tissue spots.
The array contains 4992 positions from one section.
All filtered columns match their unfiltered source.

The R figure shows all array positions and the provider tissue mask.

The colors distinguish the archived tissue mask from positions outside tissue. The array contains one section from one donor.

The equality check establishes that the filtered file selects columns without changing their stored counts. It cannot establish whether the tissue mask is biologically correct. The coordinate lesson puts those positions over the supplied image so that the geometry can be read.

The 10x Genomics specimen record identifies the section, software version, and downloadable archive. Use it to establish which specimen the file checks describe.

The Space Ranger spatial output specification defines tissue-position fields and image scale factors. Its version notes explain the headerless position file in this older archive.