Spatial transcriptomics data analysis: a step-by-step workflow for every platform

How to analyze spatial transcriptomics data from Visium HD, Xenium, CosMx, MERSCOPE or GeoMx: QC, segmentation, cell typing, domains, niches and statistics.

Key takeaways

  • Every spatial transcriptomics analysis follows the same seven steps: platform QC, cells, annotation, domains, niches, communication and statistics.
  • Segmentation (or bin-to-cell assignment) is the step that most often creates false biology, so measure its error before using the cells.
  • Replicates are donors, not cells or spots. One section per condition supports description, not a statistical comparison.
  • Store everything in one framework (SpatialData, Seurat or Giotto) so images, transcripts, cells and regions stay aligned.

Spatial transcriptomics measures gene expression without losing where cells sit in tissue. The platforms differ, from sequencing-based grids such as Visium HD and Stereo-seq to imaging-based single-molecule methods such as Xenium[3], CosMx[4] and MERSCOPE, and region-based profiling with GeoMx[6]. The analysis questions are the same on all of them: which cells are where, who their neighbors are, and what changes between conditions.

This guide sets out the workflow our duo teams use on every platform, and the decisions at each step that decide whether results hold up in review.

Step 0: Put everything in one coordinate system

A spatial dataset is not just a count matrix. It includes images (H&E, DAPI, membrane or protein stains), transcript or bin coordinates, cell or region shapes, and sample metadata. Keep them together and aligned from the start.

  • SpatialData[2] (Python) stores images, points, shapes and tables in one object with shared coordinate systems, and reads outputs from Visium HD, Xenium, CosMx, MERSCOPE and others.
  • Seurat and Giotto (R) provide equivalent containers.
  • Record which section came from which donor, condition, slide and run. Every later statistic depends on it.

Step 1: Platform-specific quality control

Each technology fails differently, so QC must match the platform.

Platform What to check first
Visium HD Tissue mask, UMIs and genes per 2/8/16 µm bin, off-tissue signal, folds and edges
Xenium Transcript Q-scores, negative-control probes and codewords, detection per region
CosMx Counts and background per field of view (FOV), negative probes and false codes
MERSCOPE Blank-barcode rate, detection across the section and across z-planes
GeoMx Reads and saturation per segment, nuclei and area, probe outliers, limit of quantification

Two rules apply everywhere. First, quantify background from negative probes, blank or false codewords, or off-tissue bins, and report it per region. Second, mask artifacts (folds, bubbles, detached tissue, FOV borders) before clustering, or they become clusters of their own.

Step 2: Define the cells

Most downstream biology assumes you know which transcripts belong to which cell. This is the most error-prone step in spatial analysis.

Imaging platforms (Xenium, CosMx, MERSCOPE). Default segmentation usually starts from nuclei and expands outward. In dense tissue, the expanded boundaries overlap, and transcripts from one cell are assigned to its neighbor.

  1. Measure the error. Choose mutually exclusive marker pairs (for example EPCAM with PTPRC, or CD3E with LYZ) and compute how often both appear in one cell above background.
  2. Re-segment when the error is high. Transcript-based methods (Baysor[7], Proseg) and stain-based methods (Cellpose[8] with membrane signal) often reduce spillover substantially.
  3. Choose the segmentation that minimizes leakage without fragmenting cells, and keep the metric in your methods section.

Sequencing platforms (Visium HD, Stereo-seq). A 2 µm bin contains part of a cell and a handful of UMIs. Either analyze at 8 µm bins, which are robust for domains and gradients, or aggregate 2 µm bins into cells using nucleus segmentation on the H&E or IF image (bin2cell-style). Many projects need both resolutions for different questions.

Region-based platforms (GeoMx). There are no single cells. Each area of interest is a mixture, so cell composition comes from deconvolution (Step 3).

What our experts avoid: reporting contact-dependent signaling, "hybrid" cell states or autocrine loops before measuring segmentation leakage. In one Xenium case study, an apparent ligand-receptor interaction disappeared after re-segmentation.

Step 3: Annotate cell types

  • Reference mapping from matched or atlas single-cell RNA-seq is the most reliable approach for targeted panels. Restrict the reference to panel genes, and keep confidence scores.
  • Deconvolution (RCTD[9], cell2location[10], SpatialDecon[11]) estimates cell-type mixtures in bins, spots or regions.
  • Panel-aware clustering works better on large panels (5,000 genes or whole transcriptome) than on 300-500 gene panels, which over-split the cell types they were designed for.
  • Check labels against morphology. A cell biologist looking at the H&E or IF image catches impossible assignments that marker plots miss.
  • Report what the panel cannot resolve. A cell type missing from your results may simply be missing from the panel.

Step 4: Find tissue domains and spatially variable genes

Spatial domains group cells or bins by the expression of their neighborhood, recovering structures such as tumor cores, invasive margins, germinal centers or cortical layers.

  • Methods include BANKSY[12], CellCharter, GraphST and SpaGCN. Compare their output with pathology annotation; a domain map nobody can relate to the tissue is a warning sign.
  • Spatially variable genes (Moran's I, nnSVG, SpatialDE) and distance-to-structure gradients (expression as a function of distance to a border or vessel) often answer the biological question more directly than clusters.

Step 5: Neighborhoods and cellular niches

  • Neighborhood enrichment tests whether two cell types sit together more often than chance, using permutations within each sample.
  • Cellular niches[14] cluster cells by the composition of their spatial neighbors, describing recurring microenvironments such as an immune-excluded tumor edge or a fibroblast-rich stroma.
  • Compute these per sample first, then summarize across samples. A niche seen in one section is an observation; a niche whose abundance differs consistently across donors is a result.

Step 6: Spatial cell-cell communication

Ligand-receptor analysis gains power in spatial data because you can restrict it to cells that are actually neighbors. Tools such as LIANA+, COMMOT and NicheNet support spatially constrained inference.

Run it only after segmentation review (Step 2), because spillover between touching cells can produce exactly the co-expression pattern a ligand-receptor test looks for. Treat the output as a list of hypotheses to validate.

Step 7: Compare conditions with the right statistics

The statistical unit is the donor or animal, not the cell, bin or region.

  • Summarize per sample: cell-type proportions, niche abundance, and pseudobulk expression by cell type or domain.
  • Test across samples with methods designed for replicates (pseudobulk with edgeR or limma; compositional tests for proportions).
  • For GeoMx and other designs with many regions per patient, use mixed models with patient as a random effect.
  • One section per condition supports a descriptive case study, not a p-value.

Step 8: Figures and methods that survive review

Reviewers increasingly ask for segmentation QC, background rates and replicate structure. Report them. Deliver figures with image overlays at full resolution, scale bars, consistent color maps across samples, and the code and software versions to reproduce every panel.

A realistic timeline

Stage Typical time for 4-8 sections
Data transfer and QC report about 1 week
Segmentation review and annotation 1-2 weeks
Domains, niches, communication and statistics 1-2 weeks
Figures, revisions and methods text ongoing, unlimited revisions

Doing it yourself or getting help

The open-source ecosystem is strong, and a computational lab can follow this workflow with the tools named here. Projects tend to stall at Step 2 and Step 7: segmentation that looks fine but leaks, and comparisons with too few replicates. Our spatial omics analysis service covers every platform, with platform pages for Visium HD, Xenium, CosMx, MERSCOPE, GeoMx and spatial proteomics. Still choosing a platform? Read Visium HD vs Xenium vs CosMx vs MERSCOPE.

Frequently asked questions

What are the main steps in spatial transcriptomics data analysis?

Platform-specific quality control, defining cells (segmentation or bin aggregation), cell-type annotation, spatial domain detection, neighborhood and niche analysis, spatially resolved cell-cell communication, and replicate-aware statistical comparison between conditions. Visualization and methods reporting run alongside every step.

Which software is used to analyze spatial transcriptomics data?

Common open-source tools include SpatialData and Squidpy in Python, Seurat and Giotto in R, Cellpose, Baysor and Proseg for segmentation, RCTD and cell2location for deconvolution, BANKSY and CellCharter for domains and niches, and LIANA+ or COMMOT for spatial cell-cell communication. Vendor tools such as Space Ranger, Xenium Ranger, AtoMx and the Vizgen Post-processing Tool produce the starting files.

How long does spatial transcriptomics analysis take?

For an experienced team, QC takes about a week and a full analysis of 4-8 sections takes 3-6 weeks. Most of the time goes into segmentation review, annotation and checking results against tissue morphology, not into running pipelines.

How many samples do I need for spatial transcriptomics?

For any comparison between conditions you need independent biological replicates, ideally three or more donors or animals per group. Many cells or spots from one section count as one replicate.

References

  1. Moses L, Pachter L. Museum of spatial transcriptomics. Nat Methods. 2022;19:534-546.
  2. Marconato L, Palla G, Yamauchi KA, et al. SpatialData: an open and universal data framework for spatial omics. Nat Methods. 2025;22:58-62.
  3. Janesick A, Shelansky R, Gottscho AD, et al. High resolution mapping of the tumor microenvironment using integrated single-cell, spatial and in situ analysis. Nat Commun. 2023;14:8353.
  4. He S, Bhatt R, Brown C, et al. High-plex imaging of RNA and proteins at subcellular resolution in fixed tissue by spatial molecular imaging. Nat Biotechnol. 2022;40:1794-1806.
  5. Chen KH, Boettiger AN, Moffitt JR, Wang S, Zhuang X. Spatially resolved, highly multiplexed RNA profiling in single cells. Science. 2015;348:aaa6090.
  6. Merritt CR, Ong GT, Church SE, et al. Multiplex digital spatial profiling of proteins and RNA in fixed tissue. Nat Biotechnol. 2020;38:586-599.
  7. Petukhov V, Xu RJ, Soldatov RA, et al. Cell segmentation in imaging-based spatial transcriptomics. Nat Biotechnol. 2022;40:345-354.
  8. Stringer C, Wang T, Michaelos M, Pachitariu M. Cellpose: a generalist algorithm for cellular segmentation. Nat Methods. 2021;18:100-106.
  9. Cable DM, Murray E, Zou LS, et al. Robust decomposition of cell type mixtures in spatial transcriptomics. Nat Biotechnol. 2022;40:517-526.
  10. Kleshchevnikov V, Shmatko A, Dann E, et al. Cell2location maps fine-grained cell types in spatial transcriptomics. Nat Biotechnol. 2022;40:661-671.
  11. Danaher P, Kim Y, Nelson B, et al. Advances in mixed cell deconvolution enable quantification of cell types in spatial transcriptomic data. Nat Commun. 2022;13:385.
  12. Singhal V, Chou N, Lee J, et al. BANKSY unifies cell typing and tissue domain segmentation for scalable spatial omics data analysis. Nat Genet. 2024;56:431-441.
  13. Palla G, Spitzer H, Klein M, et al. Squidpy: a scalable framework for spatial omics analysis. Nat Methods. 2022;19:171-178.
  14. Schürch CM, Bhate SS, Barlow GL, et al. Coordinated cellular neighborhoods orchestrate antitumoral immunity at the colorectal cancer invasive front. Cell. 2020;182:1341-1359.

Tell us about your data.

Send a few lines about your experiment. A bioinformatician and a biologist will review it and reply with questions or a capped estimate. Analysis starts at $79/hour, and figure customization is unlimited.

  • Free 30-minute scoping call
  • Capped estimate before any billable work
  • You own all data, code, figures and IP

Prefer email? contact@omicsquest.com

Fields marked required must be filled in.

We reply within one business day with questions or a capped estimate. Mutual NDA available before any data is shared.

Book a free callPricing