Back to Blog
Spatial OmicsTranscriptomics

Spatial Transcriptomics Explained: Visium, Xenium, and Analyzing Tissue in Situ

How Visium, Xenium, and other platforms map gene expression onto intact tissue, and the Squidpy/Seurat workflow for QC, segmentation, and spatial genes.

SSSudipta SardarJuly 20, 20269 min read
Spatial Transcriptomics Explained: Visium, Xenium, and Analyzing Tissue in Situ

Single-cell RNA-seq tells you which cell types exist in a tissue and what genes they express, but only after the tissue has been dissociated into a loose suspension of cells — every positional relationship is destroyed in the process. Spatial transcriptomics keeps that map intact: every transcript, or every captured spot of transcripts, is tagged with a physical coordinate on the tissue section, so the resulting expression matrix comes with an x,y position attached. This post covers the two major families of spatial platforms and the Squidpy/Seurat workflow used to QC, segment, and mine that data for genes that vary meaningfully across space.

From Dissociated Cells to Coordinates: Why Spatial Matters

A standard scRNA-seq pipeline — the one covered in our single-cell RNA-seq primer — answers "which cell types are present and in what proportion." It cannot answer "which cells are touching," "how far is this immune cell from the tumor boundary," or "does this gene's expression change from the tissue core to its edge." Those questions matter in cancer biology (immune infiltration at a tumor margin), neuroscience (layer-specific expression in cortex), and development (morphogen gradients), and all of them require position.

Spatial transcriptomics is best understood as a natural extension of scRNA-seq, not a replacement for it. The underlying chemistry — barcoding, reverse transcription, sequencing, or targeted probe hybridization — is recognizably descended from single-cell methods. What changes is that the barcode, or the imaging coordinate, now encodes a physical location on the tissue section as well as a cell of origin.

Two Families of Spatial Platforms

Every current commercial platform falls into one of two broad strategies, and the choice between them shapes everything downstream.

PlatformStrategyResolutionGene coverageVendor
VisiumSequencing-based~55 µm spots (multiple cells/spot)Whole transcriptome10x Genomics
Visium HDSequencing-basedContinuous 2 µm binsWhole transcriptome10x Genomics
Stereo-seqSequencing-basedSub-cellular (~500 nm)Whole transcriptomeBGI / STOmics
XeniumImaging-basedSub-cellular, single-moleculeTargeted panel (up to a few thousand genes)10x Genomics
CosMxImaging-basedSub-cellular, single-moleculeTargeted panelBruker / NanoString

Sequencing-based platforms capture mRNA onto a barcoded surface beneath the tissue and sequence everything together, exactly like a bulk or single-cell RNA-seq library — so they keep the whole-transcriptome, discovery-friendly nature of standard RNA-seq. Imaging-based platforms instead hybridize fluorescent probes directly to RNA inside intact tissue and read out identity by imaging, closer in spirit to single-molecule FISH. That trade-off — whole transcriptome at coarser resolution versus a curated panel at true single-molecule resolution — is the main decision point when choosing a platform.

Sequencing-Based Spatial: Visium and Visium HD

A Visium slide has thousands of barcoded spots printed onto its surface, each spot carrying millions of copies of a unique spatial barcode plus a poly-dT capture sequence. A tissue section is placed on top, permeabilized, and mRNA from the overlying cells diffuses down and hybridizes to the spot's capture oligos. Reverse transcription and library prep proceed as usual, and every read that comes off the sequencer carries its spot's barcode, which is later matched back to an (x, y) position on the accompanying histology image.

The catch is that a standard Visium spot is roughly 55 µm across, large enough to sit under several cells rather than one, so each spot's expression profile is really a mixture of whatever cells happened to sit on it. Visium HD replaces the discrete spot grid with a continuous lawn of 2 µm by 2 µm barcoded squares, computationally binned (commonly to 8 µm or 16 µm) to trade resolution for signal-to-noise — closer to single-cell, though not a guarantee of exactly one cell per bin. Stereo-seq uses a similar chip-based capture with DNA nanoball technology at sub-cellular spacing, aimed at very large fields of view such as whole organ sections.

Because Visium spots (and, to a lesser extent, Visium HD bins) still mix multiple cells, a common downstream step is deconvolution: estimating each spot's cell-type composition using a matched scRNA-seq reference and tools such as cell2location or RCTD, rather than assuming each spot is a single cell.

Imaging-Based Spatial: Xenium and CosMx

Instead of lysing tissue and sequencing bulk RNA from a spot, imaging-based platforms hybridize targeted fluorescent probes directly onto RNA in intact, fixed tissue, then decode each transcript's identity through rounds of imaging. The output is a table of individual detected transcripts, each with its own gene identity and precise x, y (and often z) coordinate — resolution fine enough to distinguish nuclear from cytoplasmic transcripts within a single cell.

The trade is coverage: both platforms run a predefined, targeted gene panel — typically a few hundred to a few thousand genes chosen ahead of time — rather than capturing the whole transcriptome. That makes them poor tools for open-ended discovery but excellent for validating hypotheses from scRNA-seq or Visium data at true single-cell precision. CosMx additionally supports multiplexed protein panels on the same run, layering proteomic readout onto the transcript data.

Cell Segmentation: Turning Pixels into Cells

Imaging platforms don't hand you a cell-by-gene matrix directly — they hand you millions of individual transcript detections scattered across an image. Before per-cell analysis is possible, you need cell segmentation: drawing a boundary around each nucleus and cell so every detected transcript is assigned to the right cell.

Segmentation typically starts from a DAPI nuclear stain, often combined with a membrane marker, and uses either the vendor's built-in algorithm or general-purpose tools like Cellpose. Poor segmentation is a real, underappreciated failure mode: in densely packed tissue, transcripts from a neighboring cell can bleed across an imprecise boundary and contaminate a cell's profile. Methods like Baysor improve on pure image-based segmentation by using the spatial pattern of the transcripts themselves — not just the image — to refine boundaries. This step has no equivalent in Visium data (outside of Visium HD's fine bins), because a standard spot is deliberately treated as a mixed unit rather than segmented into individual cells.

QC, Normalization, and the Squidpy/Seurat Workflow

Once you have a cell-by-gene (or spot-by-gene) matrix with coordinates attached, analysis converges with standard scRNA-seq, run through one of two ecosystems: Squidpy in Python, built on scanpy and AnnData (the same stack covered in our Scanpy install guide), or Seurat's spatial functions in R.

QC metrics differ by platform. For spot-based Visium data, check total counts per spot, genes detected per spot, mitochondrial read percentage, and whether a spot sits on tissue at all (validated against the histology image). For imaging-based data, check transcripts per cell, segmented cell area, and the rate of signal from negative-control or "blank" probes, which these platforms include specifically to estimate each gene's background false-positive rate.

python
import squidpy as sq
import scanpy as sc

# Visium: read the 10x Space Ranger output directory
adata = sq.read.visium("visium_output/")
sc.pp.filter_cells(adata, min_counts=500)
sc.pp.normalize_total(adata, inplace=True)
sc.pp.log1p(adata)
r
library(Seurat)

brain <- Load10X_Spatial(data.dir = "visium_output/")
brain <- SCTransform(brain, assay = "Spatial")
brain <- RunPCA(brain) |> FindNeighbors() |> FindClusters()

After normalization, clustering follows the familiar PCA to neighbor graph to Leiden/Louvain to UMAP path — but because you now also have spatial coordinates, results are plotted directly back onto the tissue image (sq.pl.spatial_scatter in Squidpy, SpatialFeaturePlot in Seurat) rather than only onto an abstract UMAP embedding.

Finding Spatially Variable Genes

The whole point of adding coordinates is to ask a new kind of question: does this gene's expression form a coherent spatial pattern, or is it just randomly scattered across the tissue? Genes with real spatial structure — a gradient across a tissue layer, a hotspot at a tumor boundary — are called spatially variable genes (SVGs), and they are the spatial-data analog of highly variable genes in scRNA-seq.

The standard statistic is Moran's I, a measure of spatial autocorrelation: it asks whether a spot's (or cell's) expression tends to resemble its neighbors' more than chance would predict. A high Moran's I means the gene is spatially clustered; a value near zero means its expression is effectively random with respect to position. Geary's C is a related statistic, and dedicated methods such as SPARK and SpatialDE offer alternative models for the same question.

In Squidpy, this is a two-step call: build a spatial neighbor graph, then run the autocorrelation test.

python
sq.gr.spatial_neighbors(adata)
sq.gr.spatial_autocorr(adata, mode="moran")

top_svgs = adata.uns["moranI"].sort_values("I", ascending=False).head(20)

Seurat exposes the equivalent as FindSpatiallyVariableGenes(object, method = "moransi"). Once you have a ranked list of SVGs, the natural next step is grouping the tissue into spatial domains — clusters that account for both expression similarity and physical proximity — rather than treating every spot or cell as spatially independent, which is what conventional clustering silently assumes.

Practical Takeaways

  • Spatial transcriptomics is scRNA-seq plus position, not a separate discipline — the same normalization, clustering, and marker-gene logic applies, layered under a coordinate system.
  • Choose sequencing-based platforms (Visium, Visium HD, Stereo-seq) for whole-transcriptome discovery; choose imaging-based platforms (Xenium, CosMx) when you already have a gene panel and need true single-cell, single-molecule resolution.
  • Standard Visium spots mix multiple cells — budget for deconvolution against an scRNA-seq reference rather than treating a spot as a single cell.
  • Segmentation quality is the hidden bottleneck of imaging platforms; a boundary error silently mixes two cells' transcripts before analysis begins.
  • Use Moran's I (via Squidpy's spatial_autocorr or Seurat's FindSpatiallyVariableGenes) as your entry point for spatially variable genes — the direct spatial analog of highly-variable-gene selection in scRNA-seq.