Spatial batch correction refers to algorithmic techniques that harmonize gene expression data from multiple spatial transcriptomic samples by identifying and removing non-biological technical variation, known as batch effects, while retaining genuine spatially variable gene patterns. These methods are essential for integrating data across different experimental runs, laboratories, or technology platforms.
Glossary
Spatial Batch Correction

What is Spatial Batch Correction?
Spatial batch correction is a computational method for removing technical variation between multiple spatial transcriptomic samples or experiments while preserving true biological spatial heterogeneity.
Unlike standard single-cell batch correction, spatial methods must account for the two-dimensional tissue architecture by incorporating spatial autocorrelation and neighborhood context into the alignment process. Common approaches include spatial extensions of canonical correlation analysis and mutual nearest neighbor matching that operate on spatial neighborhood graphs to ensure that local tissue structures remain intact after correction.
Key Features of Spatial Batch Correction
Computational strategies that remove technical variation between spatial transcriptomic samples while preserving the true biological heterogeneity encoded in tissue architecture.
Mutual Nearest Neighbors (MNN) Anchoring
Identifies cross-sample cell pairs that are mutual nearest neighbors in a shared feature space, using these as anchors to compute correction vectors. This approach assumes that technical variation shifts the population in a consistent direction, while biological variation is preserved by only correcting within matched cell states. The method is robust to differences in cell-type composition between samples and scales efficiently to large spatial datasets.
Canonical Correlation Analysis (CCA) Alignment
Projects datasets into a shared low-dimensional subspace that maximizes the correlation between corresponding features across batches. In spatial contexts, CCA identifies sources of shared biological variation while isolating batch-specific noise. The corrected embeddings can then be used for downstream spatial domain detection and trajectory inference without the confounding influence of technical artifacts.
Harmony Integration
An iterative clustering and correction algorithm that uses a soft k-means clustering approach to group cells into diverse clusters, then applies cluster-specific linear correction factors. Harmony is particularly effective for spatial data because it does not assume all cell types are shared across batches, making it resilient to tissue-specific cell populations that may be absent in some samples.
Scanorama Panoramic Stitching
Assembles a panoramic view of the cellular landscape by finding correspondences between datasets using a mutual nearest neighbors approach, then merging them with a technique analogous to image stitching. Scanorama corrects batch effects by matching overlapping cell types and applying a nonlinear transformation that smoothly blends the datasets while preserving unique biological structures present in only one sample.
Negative Binomial Regression Models
Employs generalized linear models that explicitly account for the count-based, overdispersed nature of spatial transcriptomics data. Batch identity is included as a covariate in the regression, allowing the model to estimate and remove its effect on gene expression. This parametric approach provides interpretable coefficients and naturally handles the zero-inflated distributions common in spatial data.
Spatial-Aware Correction Constraints
Extends standard batch correction by incorporating spatial neighborhood information as a regularization term. The algorithm penalizes corrections that disrupt known spatial autocorrelation patterns, ensuring that the corrected expression values maintain realistic spatial gradients. This prevents over-correction that could flatten genuine biological spatial heterogeneity, such as developmental gradients or tumor-immune boundaries.
Frequently Asked Questions
Addressing the most common technical questions about removing non-biological variation from multi-sample spatial transcriptomics experiments while preserving authentic tissue architecture and spatial heterogeneity.
Spatial batch correction is a computational method for removing technical variation between multiple spatial transcriptomic samples or experiments while preserving true biological spatial heterogeneity. When tissue sections are processed on different slides, at different times, or by different technicians, systematic non-biological differences—called batch effects—can obscure genuine biological signals. These effects arise from variations in tissue permeabilization time, sequencing depth, enzyme lot variability, and ambient temperature during library preparation. Without correction, downstream analyses like spatial domain detection, spatially variable gene identification, and cross-sample comparisons become unreliable. The core challenge distinguishing spatial batch correction from standard single-cell batch correction is the requirement to maintain spatial autocorrelation structures—the tendency for nearby locations to have similar expression profiles—which are themselves biologically meaningful and must not be erased during harmonization.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Spatial Batch Correction vs. Standard Batch Correction
Key differences between spatial-aware batch correction and conventional bulk or single-cell batch correction methods.
| Feature | Spatial Batch Correction | Standard Batch Correction |
|---|---|---|
Primary objective | Remove technical variation while preserving spatial autocorrelation and tissue architecture | Remove technical variation while preserving biological variation between cell types or conditions |
Spatial context awareness | ||
Preserves spatial autocorrelation (Moran's I) | ||
Preserves spatial domain boundaries | ||
Input data structure | Spatial expression matrix with spatial coordinates | Expression matrix only (no spatial coordinates) |
Handles within-tissue positional effects | ||
Risk of over-correction | Low (spatial constraints regularize correction) | Moderate to high (may remove subtle biological signals) |
Typical algorithms | SpatialHarmony, STACAS, SpatialMNN, GPSA | ComBat, Harmony, MNN Correct, limma::removeBatchEffect |
Related Terms
Mastering spatial batch correction requires fluency in the broader computational toolkit for spatially resolved transcriptomics. These concepts form the analytical foundation for harmonizing multi-sample spatial studies.
Spatial Data Integration
The process of combining multiple spatial transcriptomics datasets from different technologies, samples, or modalities into a unified analytical framework. Unlike non-spatial integration, these methods must preserve tissue architecture and spatial coordinates.
- Horizontal integration: Merging multiple slices from the same technology (e.g., multiple 10x Visium samples)
- Vertical integration: Aligning different data modalities (e.g., spatial transcriptomics + spatial proteomics)
- Anchor-based methods: Use shared features or cell types to learn a common latent space
Spatial Registration
The computational alignment of multiple tissue images or spatial datasets into a common coordinate system. This is a critical preprocessing step before batch correction, ensuring that the same anatomical region is compared across samples.
- Rigid registration: Translation and rotation only
- Affine registration: Adds scaling and shearing
- Non-linear/diffeomorphic registration: Warps tissue to match complex anatomical boundaries
- Tools like STUtility and PASTE perform probabilistic alignment of spatial transcriptomics spots
Spatial Autocorrelation
A statistical measure of the degree to which a variable's values at nearby locations are more similar than expected by random chance. Effective batch correction must preserve this signal while removing technical artifacts.
- Positive autocorrelation: Neighboring spots have similar expression (e.g., a tumor region)
- Negative autocorrelation: Neighboring spots are dissimilar (e.g., sharp boundaries)
- Moran's I quantifies this globally; Local Indicators of Spatial Association (LISA) identify specific clusters
Spatial Domain Detection
The unsupervised identification of tissue regions with coherent gene expression profiles and histology. After batch correction, domain detection validates that biological structures—not batch artifacts—drive clustering.
- BayesSpace: Uses a spatial hidden Markov model with a Potts prior to encourage spatial smoothness
- SpaGCN: A graph convolutional network that integrates histology images with gene expression
- stLearn: Incorporates spatial distance and morphological similarity into clustering
Spatial Permutation Test
A non-parametric statistical test that randomly shuffles spatial labels to generate a null distribution. This is the gold standard for validating that observed spatial patterns are not artifacts of batch effects or random chance.
- Procedure: Randomly permute spot coordinates, recalculate the statistic of interest, repeat 1,000+ times
- Application: Assess significance of spatially variable genes, cell-type colocalization, or ligand-receptor interactions
- Squidpy and Giotto provide built-in spatial permutation frameworks

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us