Inferensys

Glossary

Spatial Batch Correction

A computational method for removing technical variation between multiple spatial transcriptomic samples or experiments while preserving true biological spatial heterogeneity.
MLOps engineer reviewing model serving infrastructure on laptop, container orchestration visible, technical workspace.
COMPUTATIONAL BIOLOGY

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.

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.

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.

HARMONIZING MULTI-SAMPLE SPATIAL DATA

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.

01

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.

High-dimensional
Correction Space
02

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.

03

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.

04

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.

05

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.

06

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.

SPATIAL BATCH CORRECTION

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.

METHODOLOGICAL COMPARISON

Spatial Batch Correction vs. Standard Batch Correction

Key differences between spatial-aware batch correction and conventional bulk or single-cell batch correction methods.

FeatureSpatial Batch CorrectionStandard 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

Prasad Kumkar

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.