Inferensys

Glossary

Optimal Transport

A mathematical framework for comparing probability distributions that finds a minimal-cost mapping between cells from different batches, aligning their distributions in a principled manner for batch effect correction.
Developer reviewing LLM cost optimization spreadsheet on laptop, calculator and coffee on desk, casual finance-technical moment.
BATCH CORRECTION MATHEMATICS

What is Optimal Transport?

Optimal Transport is a mathematical framework for comparing probability distributions that is used in batch correction to find a minimal-cost mapping or coupling between cells from different batches, aligning their distributions in a principled manner.

Optimal Transport (OT) defines a rigorous geometry for comparing probability distributions by calculating the minimal total work required to transform one distribution into another. In single-cell genomics, this framework treats each batch as a discrete empirical distribution of cells in a high-dimensional gene expression space, and it computes a transport plan—a coupling matrix—that specifies how to map cells from a query batch onto a reference batch while minimizing the sum of squared Euclidean distances between matched cells.

Unlike methods that rely solely on Mutual Nearest Neighbors (MNN) or linear corrections, OT-based batch correction solves a convex optimization problem, often regularized with entropic constraints via the Sinkhorn algorithm, to find a globally optimal, probabilistic alignment. This principled approach preserves the underlying biological manifold structure and avoids overcorrection by ensuring that the mapping is a true mathematical coupling, making it highly effective for complex, non-linear batch effects in multi-center studies.

PRINCIPLED DISTRIBUTION ALIGNMENT

Key Features of Optimal Transport for Batch Correction

Optimal transport provides a rigorous mathematical framework for aligning probability distributions in single-cell data, finding the minimal-cost mapping between cells from different batches to correct technical variation while preserving biological structure.

01

The Kantorovich Relaxation

Unlike the original Monge formulation requiring a deterministic one-to-one mapping, the Kantorovich relaxation allows probabilistic couplings where mass from a single source cell can be split across multiple target cells. This is critical for batch correction because cell populations often have different sizes across batches. The solution is a transport plan—a joint probability matrix—that specifies how much mass flows between each pair of cells, minimizing the total cost while respecting marginal constraints.

02

Earth Mover's Distance as a Cost Metric

The Earth Mover's Distance (EMD), also known as the Wasserstein distance, quantifies the minimal cost to transform one distribution into another. In batch correction:

  • Cost matrix: Pairwise distances between cells in gene expression space
  • Interpretation: EMD captures both the magnitude and geometry of distributional shift
  • Advantage over KL divergence: EMD respects the underlying metric space and remains well-defined even when distributions have non-overlapping supports
03

Entropic Regularization for Computational Tractability

Exact optimal transport computation scales as O(n³ log n), making it prohibitive for large single-cell datasets. Entropic regularization, introduced by Cuturi (2013), adds an entropy penalty to the objective:

  • Smooths the transport plan, making the problem strictly convex
  • Enables the Sinkhorn algorithm, reducing complexity to O(n²)
  • The regularization parameter λ controls the trade-off between precision and speed
  • Small λ yields sparse, precise couplings; large λ produces diffuse, faster solutions
04

Gromov-Wasserstein for Cross-Modality Alignment

When batches are measured in different feature spaces—such as integrating scRNA-seq with scATAC-seq—standard optimal transport fails because cells don't share a common coordinate system. Gromov-Wasserstein (GW) optimal transport compares distributions using intra-domain distances:

  • Aligns cells by preserving pairwise similarity structures within each modality
  • Matches cells that have analogous relational profiles to their respective neighbors
  • Enables translation between fundamentally different molecular measurement technologies
05

Unbalanced Optimal Transport for Variable Cell Proportions

Standard optimal transport assumes exact mass preservation—every cell must be matched. Unbalanced optimal transport relaxes this constraint using divergence penalties on marginal violations:

  • Accounts for cell types present in one batch but absent in another
  • Uses Kullback-Leibler divergence or total variation penalties to allow mass creation/destruction
  • Critical for realistic scenarios where biological conditions genuinely alter cell-type proportions, not just their distributions
06

Fused Gromov-Wasserstein for Structured Features

Fused Gromov-Wasserstein (FGW) combines the strengths of both classical and GW optimal transport by optimizing a weighted sum of:

  • Feature-level cost: Direct comparison of shared features (like Wasserstein)
  • Structure-level cost: Comparison of intra-domain geometries (like GW)
  • The trade-off parameter α balances feature fidelity against topological preservation
  • Particularly effective when batches share some features but have distinct relational structures, such as integrating spatial transcriptomics with dissociated scRNA-seq
OPTIMAL TRANSPORT FOR BATCH CORRECTION

Frequently Asked Questions

Clear, technically precise answers to the most common questions about using optimal transport theory to align probability distributions and correct batch effects in high-dimensional biological data.

Optimal transport (OT) is a mathematical framework for comparing and aligning probability distributions by finding a minimal-cost mapping that transforms one distribution into another. In batch effect correction, OT treats each batch of high-dimensional single-cell data as a discrete probability distribution in gene expression space. The algorithm computes a transport plan—a coupling matrix—that specifies how to move the mass (cells) from a source batch to match the distribution of a target batch, minimizing a cost function typically based on Euclidean distance or geodesic distance in a latent space. This principled alignment preserves the underlying biological structure while removing technical variation, making it particularly effective for integrating heterogeneous single-cell RNA sequencing datasets where non-linear distortions exist between batches.

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.