From CID Barcodes to Spatial Maps: Stereo-seq Data Analysis Workflow

From CID Barcodes to Spatial Maps: Stereo-seq Data Analysis Workflow

Five-stage SAW pipeline workflow diagram showing Stereo-seq data analysis from FASTQ mapping through counting, image registration, clustering, and final HTML reporting.Figure 1. The SAW (Stereo-seq Analysis Workflow) pipeline — five stages from raw sequencing reads to an annotated spatial gene expression matrix and interactive HTML report.

Summary

Stereo-seq produces raw data that look nothing like a spatial gene expression map. A single 1 × 1 cm chip run generates roughly 1 billion sequencing reads — each carrying a Coordinate Identity (CID) barcode, a Molecular Identifier (MID), and a cDNA insert. Turning those reads into a spatially resolved gene expression matrix that a biologist can interrogate requires a dedicated bioinformatics pipeline: SAW (Stereo-seq Analysis Workflow). This article walks through what SAW does at each stage, what the key output files contain, and how to judge whether a run produced data worth analyzing further.

Key Takeaways

  • SAW is the official Stereo-seq analysis pipeline, developed and maintained by BGI/STOmics. It processes raw FASTQ files through five sequential stages — mapping, counting, image processing, clustering, and reporting — to produce a complete spatial gene expression matrix.
  • CID decoding happens upstream of SAW, during chip manufacturing. The 25 bp CID barcode at the start of Read 1 was decoded by sequencing before tissue was applied, so SAW receives a pre-computed CID-to-coordinate lookup table rather than decoding barcodes de novo.
  • The GEF (Gene Expression File) is the central data object. This HDF5-based format stores expression matrices at multiple spatial resolutions (Bin20 through Bin200) plus, when CellBin is run, a single-cell-resolution layer — all in one file.
  • Image registration is automated but should be verified. SAW's trackline-based auto-registration aligns the sequencing coordinate system with the microscope image; misregistration produces spatial maps that look plausible but are shifted relative to tissue morphology.
  • CellBin segmentation is computational, not imaging-based. It uses a U-Net deep learning model on DAPI or ssDNA nuclear staining images, then expands nuclear boundaries by ~5 μm to approximate cell areas. Results are good enough for most tissue-region analyses but less precise than membrane-staining-based segmentation used by imaging platforms.

From FASTQ to Spatial Coordinates

The first stage of SAW — mapping — takes raw FASTQ files and produces a BAM file in which every aligned read carries a spatial coordinate. This sounds like standard RNA-seq alignment, but the structure of Stereo-seq reads makes it more involved.

Read structure. Each Stereo-seq read pair consists of Read 1 (50 bp) and Read 2 (100 bp on DNBSEQ-T7). Read 1 contains, in order: a 25 bp CID barcode, a 10 bp MID (Molecular Identifier, and a poly(dT) tail followed by a few bases of cDNA insert. Read 2 contains the remaining cDNA insert. The CID tells SAW where on the chip the transcript was captured; the MID tells SAW which molecule it came from, enabling PCR duplicate removal.

CID lookup. The CID barcodes were decoded during chip manufacturing — 25 cycles of sequencing-by-ligation on the bare chip, performed before any tissue was applied. SAW receives a pre-computed lookup table that maps each CID sequence to an (x, y) coordinate on the chip. This is not something the user re-runs; it ships with the chip. SAW's job in the mapping stage is to extract the CID from each Read 1, look up its spatial coordinate, and attach that coordinate to the read pair as a BAM tag.

Alignment and deduplication. After CID extraction, SAW aligns Read 2 to the reference genome using STAR. The recommended reference includes both the target genome and, if applicable, any microbial genomes for host-microbe co-detection studies. After alignment, MID-based deduplication collapses reads that share the same CID, MID, and alignment position into a single count — exactly as molecular Identifier deduplication works in droplet-based scRNA-seq. The output is a coordinate-tagged, deduplicated BAM file in which each aligned read represents one captured mRNA molecule at one spatial coordinate.

What can go wrong at this stage. The most common issue is an incorrect reference genome. Because the CID and MID occupy Read 1, the effective cDNA insert length in Read 1 is short — often only 10–15 bp. If the reference genome is incomplete or mis-annotated, these short anchors fail to align, and reads are lost before counting begins. A second issue is CID mismatch: if the CID lookup table does not match the chip batch, every read maps to the wrong coordinate. This is rare in service-provider workflows (where chip-to-table tracking is automated) but worth verifying if you are processing data independently.

Inside the Spatial Expression Matrix

Once reads are aligned to spatial coordinates, SAW enters the count stage. This stage produces the GEF file — the Gene Expression File that is the central data object for all downstream Stereo-seq analysis.

GEF format. GEF is an HDF5-based format designed specifically for spatial transcriptomics. Unlike the MTX or H5AD formats common in scRNA-seq, GEF stores the expression matrix at multiple spatial resolutions simultaneously. Each resolution is called a "bin layer": Bin1 (~500 nm, the raw DNB level), Bin20 (~10 μm), Bin50 (~25 μm), Bin100 (~50 μm), and Bin200 (~100 μm). Higher bin numbers aggregate signal over larger areas, trading spatial resolution for higher transcript counts per bin and reduced computational requirements.

Why multiple bin layers matter. A researcher analyzing a whole mouse embryo section might start at Bin50 (~25 μm bins) to quickly identify major anatomical compartments — brain, heart, liver, somites — each visible as distinct spatial clusters. Once a region of interest is identified (say, the developing cortical plate), the analysis shifts to Bin20 (~10 μm bins) for near-single-cell resolution. Bin1, the raw DNB level, is rarely used directly for analysis because individual 500 nm spots capture too few transcripts for robust statistics, but it is the foundation on which all higher bin levels are built. SAW computes each bin level by summing the counts of all DNBs whose center coordinates fall within the bin boundary.

What the GEF contains. Beyond expression matrices, the GEF file stores spatial coordinates for every bin, gene annotations, and, after later pipeline stages, clustering labels and cell segmentation boundaries. It is designed to be read by Stereopy, the official Python toolkit for Stereo-seq data analysis, which provides functions for spatial visualization, differential expression, cell-type deconvolution, and data export to standard formats including H5AD (AnnData) for use with Scanpy and other community tools.

Bin Level Approximate Resolution Transcripts per Bin (Typical) Best Use
Bin1 ~500 nm (DNB pitch) 0–2 Raw data layer; not used directly
Bin20 ~10 μm 30–100 Near-single-cell analysis
Bin50 ~25 μm 100–400 Tissue compartment identification
Bin100 ~50 μm 300–800 Rapid visualization; low-resolution screens
Bin200 ~100 μm 800–2000 Coarse anatomy mapping only

Image Registration and TissueCut

Spatial transcriptomics data are only useful if the gene expression signal can be overlaid on the tissue morphology. SAW's image processing stage handles this alignment.

Trackline auto-registration. Before tissue is applied, the Stereo-seq chip is imaged under bright-field microscopy to record the positions of fiducial markers — tracklines etched into the chip surface at known coordinate intervals. After tissue staining and imaging (DAPI or ssDNA plus bright-field), SAW detects the same tracklines in the tissue image and computes an affine transformation that aligns the sequencing coordinate system to the microscope pixel grid. For most chips, this registration is fully automated and accurate to within a few microns.

When to check registration manually. Auto-registration can fail subtly. If the tissue image has low contrast (pale DAPI staining, sparse nuclei), trackline detection confidence drops, and the computed transformation may be off by tens of microns — enough to shift the spatial expression signal across tissue boundaries. The SAW HTML report includes an overlay image showing tracklines detected in both the bare-chip and tissue images. Spend 30 seconds on this image: if the tracklines visibly misalign between the two panels, flag the run for manual registration review before proceeding to clustering and biological interpretation.

TissueCut. After registration, SAW runs TissueCut — an algorithm that identifies the tissue-covered region on the chip image and excludes background areas (empty chip surface) from downstream analysis. TissueCut uses the DAPI or ssDNA channel to distinguish tissue from background based on fluorescence intensity thresholding. Bins whose centers fall outside the tissue mask are discarded. For tissue sections with uneven staining — common in FFPE samples with variable deparaffinization — TissueCut may either include background regions (false positives) or clip thin tissue edges (false negatives). The HTML report includes the TissueCut mask overlaid on the tissue image; verifying that the mask traces the tissue boundary correctly takes a few seconds and prevents garbage bins from entering the clustering analysis.

Educational illustration of Stereo-seq GEF multi-resolution bin structure showing four nested grid levels from Bin200 down to Bin20 with gene expression heatmap and magnified DNA nanoball array inset.Figure 2. Multi-resolution bin hierarchy in the Stereo-seq GEF — from coarse Bin200 tissue compartments down to near-single-cell Bin20 expression maps.

Cell Segmentation With CellBin

Bin-based analysis treats space as a grid. For many biological questions — cell-type mapping, cell-cell communication, spatial niche characterization — single-cell resolution is better. CellBin is SAW's deep-learning-based cell segmentation module.

How CellBin works. CellBin takes the DAPI or ssDNA nuclear staining image as input and applies a U-Net convolutional neural network to segment individual nuclei. U-Net is a widely used architecture for biomedical image segmentation; CellBin's implementation was trained on a large collection of Stereo-seq tissue images with manual nucleus annotations. After nuclei are segmented, CellBin expands each nuclear boundary outward by approximately 5 μm to approximate the cytoplasmic compartment. Transcripts whose spatial coordinates fall within the expanded boundary are assigned to that cell. The result is a cell-by-gene expression matrix, stored as an additional "cellBin" layer inside the GEF file.

What CellBin does well. For tissues with well-separated, round nuclei — liver hepatocytes, most epithelial layers, densely packed tumor cells — CellBin achieves segmentation accuracy comparable to reference-based methods. The 2024 SAW paper benchmarked CellBin against manual annotation and found Dice coefficients above 0.85 for mouse embryo and liver sections.

What CellBin does less well. For tissues with irregular, elongated, or overlapping nuclei — smooth muscle, cardiac muscle, some neuronal populations — U-Net segmentation can split single nuclei or merge adjacent ones. The nuclear expansion step assumes roughly spherical cells with similar nuclear-to-cytoplasmic ratios, which does not hold for all cell types. Neuron segmentation is particularly challenging: a single pyramidal neuron may have a soma only 15–20 μm across but extend dendrites hundreds of microns. CellBin assigns transcripts in the soma region but misses those in processes beyond the ~5 μm expansion radius. For studies where precise single-cell boundaries are essential — ligand-receptor analysis, spatially resolved cell-cell communication — integrating Stereo-seq bin-level data with a matched scRNA-seq reference via deconvolution may complement CellBin results.

CellBin vs. alternative approaches. The SAW pipeline also supports exporting bin-level data to Stereopy, where users can run alternative segmentation methods or import segmentation masks from external tools. Some groups use Cellpose or StarDist for nucleus segmentation before feeding masks back into SAW. The key practical point: CellBin provides a reasonable default segmentation that works for most tissue types, but single-cell analyses with Stereo-seq should acknowledge the computational nature of the cell boundaries they rely on.

Clustering and Cell-Type Mapping

Once the expression matrix is built — at whichever bin resolution is appropriate — SAW provides two clustering approaches and exports to community-standard tools for everything else.

spatialCluster. This method performs standard Louvain or Leiden clustering on the expression matrix, exactly as one would in Scanpy: PCA dimensionality reduction, k-nearest-neighbor graph construction, and community detection. It does not use spatial information — clusters are defined solely by transcriptional similarity. For most projects, spatialCluster at Bin50 is the first analysis run, providing an unsupervised overview of transcriptional compartments in the tissue.

cellCluster. If CellBin has been run, cellCluster clusters the single-cell-resolution cell-by-gene matrix using the same approach. The practical difference is resolution: cellCluster output can be annotated with cell-type labels using marker genes, enabling the identification of specific cell populations (e.g., "L2/3 excitatory neurons," "Kupffer cells," "proximal tubular epithelial cells") rather than broad tissue compartments.

Stereopy and beyond. SAW is not designed to be the final analysis environment. Its role is to produce a clean, spatially registered, bin-or-cell-resolved expression matrix that feeds into downstream tools. Stereopy (the official Python toolkit) reads GEF files and provides: spatial visualization with gene expression overlaid on tissue images, differential expression analysis between spatial regions, cell-type deconvolution using reference scRNA-seq data, and export to H5AD format. From H5AD, the data enters the Scanpy/Squidpy ecosystem for trajectory inference, spatially variable gene detection, niche analysis, and integration with other modalities. For studies that include large capture areas or serial sections — such as the organ-scale designs discussed in the organ-scale Stereo-seq study design guide — Stereopy's multi-slice alignment and 3D reconstruction tools become essential.

If you are still evaluating whether Stereo-seq fits your project before diving into analysis considerations, the Stereo-seq platform decision guide covers resolution, tissue type, and platform comparison factors that determine whether the data coming out of this pipeline will answer your biological questions.

Key Deliverables and QC Checkpoints

A completed SAW run produces a standardized set of output files. Knowing what each file contains and which QC metrics to check prevents the most common downstream mistake: building biological conclusions on data that failed at an early pipeline stage.

Core Deliverables

Deliverable Format Contents When to Use
{sample}.gef HDF5 (.gef) Multi-resolution expression matrices, spatial coordinates, clustering labels, CellBin boundaries All downstream analysis; read with Stereopy
{sample}.h5ad AnnData (.h5ad) Bin-level or cell-level expression matrix exported from GEF Scanpy, Squidpy, community tools
visualization.tar.gz Archive Spatial gene expression heatmaps, clustering plots, tissue registration overlays Quick visual review; sharing with non-bioinformatician collaborators
report.html HTML Interactive QC report with metrics, images, and pipeline logs QC review before biological analysis
run.log Text Full pipeline log with timing, warnings, and error messages Troubleshooting; parameter documentation

QC Metrics to Check Before Proceeding

Saturation and sequencing depth. The HTML report includes a saturation curve — the number of unique MID counts as a function of read depth. If the curve has not plateaued, sequencing deeper would recover additional unique transcripts. For a standard 1 × 1 cm chip, approximately 1–1.5 billion reads typically reach saturation. If your run is well below this and the saturation curve is still rising, consider requesting additional sequencing before proceeding to biological interpretation.

Read mapping rate. Expect >70% of reads to map uniquely to the reference genome. Mapping rates below 60% suggest either an incomplete reference (missing splice junctions, missing microbial genomes) or contamination. The SAW report breaks down mapping statistics by chromosome and, if configured, by species.

MID utilization. The fraction of reads retained after MID deduplication should be >50%. Lower values indicate either excessive PCR amplification (library preparation issue) or very shallow sequencing of a transcriptome with limited complexity (degraded RNA).

Spatial registration quality. As noted earlier, visually confirm the trackline overlay image. Accept no more than minor (<5 μm) registration shifts at tissue boundaries. Registration errors propagate through every downstream spatial analysis.

Tissue coverage and morphology. The TissueCut mask should cover the entire tissue section without including empty chip areas. Nuclear staining should appear punctate and well-distributed. Large dark zones in the DAPI channel with no detected nuclei suggest necrotic or folded regions — bins in these areas will produce zero-inflated expression data that can distort clustering.

Gene and transcript counts. For a 1 × 1 cm chip with good-quality mouse or human tissue, expect 20,000–30,000 detected genes and 30–80 million unique transcripts (after MID deduplication) at Bin50 resolution. Counts substantially below these ranges warrant investigation before proceeding.

In summary, before accepting a SAW data delivery, verify these six items:

  • Saturation curve has plateaued — if not, request deeper sequencing
  • Read mapping rate is above 70% — lower rates suggest reference or contamination issues
  • MID utilization is above 50% — lower values indicate PCR over-amplification
  • Registration overlay shows trackline alignment within ~5 μm — misregistration propagates to all spatial analyses
  • TissueCut mask correctly traces the tissue boundary — no background inclusion, no tissue clipping
  • Gene and transcript counts are within expected ranges for the chip size and tissue type

Sample quality issues identified at this stage often trace back to the tissue preparation variables covered in the Stereo-seq sample preparation and QC guide.

For researchers who prefer a fully managed analysis workflow — from raw FASTQ through annotated spatial maps and publication-ready figures — CD Genomics Spatial Transcriptomics Services include Stereo-seq data analysis as an integrated component, with QC review, clustering, cell-type annotation, and visualization delivered alongside the sequencing data.

Four-panel SAW QC dashboard showing registration check alignment overlay, sequencing saturation curve, mapping statistics bar chart, and tissue mask validation image.Figure 3. Key QC views from the SAW HTML report — registration check, saturation curve, mapping stats, and tissue mask validation for a completed Stereo-seq run.

FAQ

Q: Do I need to run SAW myself, or is it handled by the service provider?
For most service-provider workflows, SAW is run by the provider as part of the standard data delivery. You receive the GEF file, the H5AD export, the HTML QC report, and the visualization package — you do not need to install or run SAW. However, if you are generating Stereo-seq data independently (e.g., from a core facility that provides only FASTQ files), SAW is available as open-source software under CC BY 4.0 and runs on Linux with Docker or Singularity containerization. The SAW User Manual at the STOmics documentation site provides installation and usage instructions.

Q: How long does a SAW run take?
The 2024 SAW paper benchmarked the full pipeline at approximately 148 minutes for 1 billion reads from a 1 × 1 cm chip on a server with 48 CPU cores and 512 GB RAM. The mapping stage (STAR alignment) dominates runtime, accounting for roughly 60% of the total. CellBin adds approximately 30 minutes on a GPU-enabled instance; on CPU-only systems, CellBin is significantly slower and may take several hours for large chips.

Q: Can I use my own clustering or segmentation methods instead of SAW's defaults?
Yes. SAW exports data in standard formats (H5AD) at multiple stages, so you can take the aligned, deduplicated, coordinate-tagged expression matrix and apply any clustering, dimensionality reduction, or visualization method you prefer. For segmentation, you can supply externally generated cell masks to SAW instead of running CellBin, or skip CellBin entirely and perform segmentation in Stereopy or other tools after SAW completes.

Q: What if my tissue registration looks wrong in the SAW report?
Misregistration is usually fixable. If auto-registration failed (trackline detection confidence low), SAW allows manual registration — you identify corresponding landmarks in the bare-chip and tissue images, and SAW recomputes the transformation. In service-provider workflows, the analysis team should flag registration issues and offer manual correction before delivering data. Always review the registration overlay in the HTML report before accepting a data delivery.

Q: How does the SAW workflow differ between fresh frozen and FFPE Stereo-seq data?
The core SAW pipeline — mapping, counting, image processing, clustering — is identical for fresh frozen and FFPE data. The difference is upstream of SAW: the reference genome indexing step may differ for V2 random-primer data (FFPE), and the tissue image content differs (DAPI vs. ssDNA staining). Downstream, FFPE data typically show lower transcript counts per bin and a higher proportion of intronic reads due to the random-primer capture chemistry. SAW's count stage accounts for this by counting both exonic and intronic reads for FFPE samples, whereas fresh-frozen analysis typically restricts counts to exonic regions.

References

  1. Chen A, Liao S, Cheng M, et al. Spatiotemporal transcriptomic atlas of mouse organogenesis using DNA nanoball-patterned arrays. Cell. 2022;185(10):1777-1792.e21. doi:10.1016/j.cell.2022.04.003
  2. Gong C, Li S, Wang L, et al. SAW: an efficient and accurate data analysis workflow for Stereo-seq spatial transcriptomics. GigaByte. 2024;2024:gigabyte111. doi:10.46471/gigabyte.111
  3. You Y, Fu Y, Li L, et al. Systematic comparison of sequencing-based spatial transcriptomic methods. Nature Methods. 2024;21:1743-1754. doi:10.1038/s41592-024-02325-3
  4. Ren P, Zhang R, Luo C, et al. Systematic benchmarking of high-throughput subcellular spatial transcriptomics platforms across human tumors. Nature Communications. 2025;16:9232. doi:10.1038/s41467-025-64292-3
  5. Zhao Y, Li Y, He Y, et al. Stereo-seq V2: spatial mapping of total RNA on FFPE sections with high resolution. Cell. 2025;188(23):6554-6571.e21. doi:10.1016/j.cell.2025.08.008

The information provided in this article is for research use only and is not intended for use in diagnostic or therapeutic procedures. CD Genomics provides sequencing and bioinformatics services for research purposes. Researchers should consult the appropriate regulatory guidelines for their specific applications.

For research use only, not intended for any clinical use.

Online Inquiry

For research purposes only, not intended for clinical diagnosis, treatment, or individual health assessments.

Logo

CD Genomics is accelerating research in biology, medicine, and beyond at an unprecedented rate, solely due to our comprehensive spatial omics solutions.

Contact Us