Inferensys

Glossary

Moran's I

A spatial autocorrelation statistic that measures the overall clustering of a gene expression pattern across a tissue, ranging from dispersed to highly clustered.
ML engineer managing model training cluster on laptop, GPU utilization visible, technical deep learning setup.
SPATIAL AUTOCORRELATION METRIC

What is Moran's I?

Moran's I is a foundational statistical measure that quantifies the degree of spatial autocorrelation in a dataset, determining whether the observed pattern of a variable across a tissue is clustered, dispersed, or random.

Moran's I is a spatial autocorrelation statistic that measures the overall clustering of a gene expression pattern across a tissue, producing a single value ranging from -1 (perfectly dispersed) to +1 (perfectly clustered), with 0 indicating a random spatial distribution. It evaluates whether the expression values at neighboring locations are more similar than expected by chance, making it a critical first-pass tool for identifying spatially variable genes (SVGs) in spatial transcriptomics.

The statistic is calculated by comparing the covariance of expression values between spatial neighbors against the global variance of the entire tissue sample. A statistically significant positive Moran's I confirms that a gene exhibits a spatially cohesive expression domain, while a negative value suggests a repulsive, checkerboard-like pattern. The significance is typically assessed via a spatial permutation test, which randomly shuffles expression values across locations to generate a null distribution.

SPATIAL AUTOCORRELATION METRIC

Key Properties of Moran's I

Moran's I is the foundational statistic for quantifying spatial autocorrelation in transcriptomics. It measures whether the expression of a gene is randomly distributed, clustered, or dispersed across a tissue section.

01

The Mathematical Definition

Moran's I is defined as a weighted cross-product of deviations from the mean, normalized by the variance. The formula is:

I = (N / W) * (Σᵢ Σⱼ wᵢⱼ (xᵢ - x̄)(xⱼ - x̄)) / (Σᵢ (xᵢ - x̄)²)

  • N: Number of spatial units (spots or cells)
  • W: Sum of all spatial weights
  • wᵢⱼ: Spatial weight between locations i and j
  • xᵢ: Gene expression value at location i
  • : Mean expression across all locations

The statistic produces a value typically ranging from -1 (perfect dispersion) to +1 (perfect clustering), with 0 indicating random spatial distribution.

02

Interpreting the Values

The output of Moran's I provides immediate insight into tissue organization:

  • I > 0 (Positive Autocorrelation): Nearby locations have similar expression levels. This indicates spatial clustering—common for cell-type-specific marker genes confined to anatomical regions.
  • I ≈ 0 (No Autocorrelation): Expression is randomly distributed across the tissue. Typical for housekeeping genes with uniform expression.
  • I < 0 (Negative Autocorrelation): Nearby locations have dissimilar expression. This indicates spatial dispersion or a chessboard-like pattern, often seen in genes with mutually exclusive expression domains.

The magnitude indicates the strength of the pattern, while the sign indicates the direction.

03

Spatial Weights Matrix

The spatial weights matrix (W) defines what 'nearby' means and is the most critical user-defined parameter:

  • Distance-based weights: wᵢⱼ = 1 if distance ≤ threshold, else 0. Requires choosing a biologically meaningful radius.
  • K-Nearest Neighbors (KNN): wᵢⱼ = 1 if j is one of the k nearest neighbors of i. Adapts to local spot density.
  • Inverse distance weights: wᵢⱼ = 1 / dᵢⱼᵖ. Nearby points have stronger influence; distant points have weaker influence.
  • Binary contiguity: wᵢⱼ = 1 if spots share a border. Common for grid-based spatial transcriptomics platforms like Visium.

The choice of weights matrix directly impacts the Moran's I value and must be reported for reproducibility.

04

Statistical Significance Testing

A raw Moran's I value alone is insufficient; its statistical significance must be assessed against a null hypothesis of spatial randomness:

  • Permutation test: Randomly shuffle gene expression values across spatial locations and recalculate Moran's I. Repeat 999+ times to generate a null distribution.
  • Z-score: z = (I_observed - E[I]) / √Var[I]. Measures how many standard deviations the observed value is from the expected value under randomness.
  • P-value: The proportion of permuted I values as extreme or more extreme than the observed I.
  • Multiple testing correction: When testing thousands of genes, apply Benjamini-Hochberg or Bonferroni correction to control false discovery rate.

Only genes with an adjusted p-value < 0.05 are considered spatially variable genes (SVGs).

05

Global vs. Local Moran's I

Moran's I exists in two complementary forms for spatial transcriptomics analysis:

  • Global Moran's I: A single summary statistic for the entire tissue. Answers: 'Is this gene spatially autocorrelated anywhere in the tissue?' Best for initial screening of spatially variable genes.
  • Local Indicators of Spatial Association (LISA): Decomposes the global statistic into a value for each spatial location. Answers: 'Where exactly are the clusters and outliers?' Identifies:
    • High-High clusters: Hot spots of high expression
    • Low-Low clusters: Cold spots of low expression
    • High-Low outliers: A high-value spot surrounded by low values
    • Low-High outliers: A low-value spot surrounded by high values

LISA is essential for identifying anatomical boundaries and transition zones.

06

Limitations and Assumptions

Moran's I has important limitations that must be considered in spatial transcriptomics:

  • Stationarity assumption: Assumes the spatial process is constant across the tissue. Violated in complex tissues with multiple distinct regions.
  • Sensitivity to scale: Results depend heavily on the chosen distance threshold or number of neighbors. Always test multiple scales.
  • Global summary masking: A global Moran's I near zero can occur when a gene has both clustered and dispersed regions that cancel each other out.
  • Spot-based data: For Visium data (55μm spots), each spot contains multiple cells. Moran's I measures spot-level, not single-cell, autocorrelation.
  • Not a causal measure: High Moran's I does not imply that spatial proximity causes the expression pattern—only that a pattern exists.

Complement with Ripley's K function or SPARK for multi-scale or model-based alternatives.

SPATIAL STATISTICS

Frequently Asked Questions

Clear, technical answers to the most common questions about Moran's I and its application in spatial transcriptomics analysis.

Moran's I is a spatial autocorrelation statistic that measures the degree to which a variable's values at nearby locations are similar to each other compared to a random spatial distribution. It produces a single summary value ranging from -1 (perfect dispersion) to +1 (perfect clustering), with 0 indicating complete spatial randomness. The statistic works by calculating the covariance between each location's value and the weighted average of its neighbors' values, then normalizing this by the overall variance of the dataset. A spatial weights matrix defines the neighborhood structure—typically using distance thresholds, k-nearest neighbors, or contiguity. The resulting I value is tested for statistical significance against a null hypothesis of spatial randomness using a Z-score and p-value derived from either a normal approximation or a spatial permutation test.

SPATIAL AUTOCORRELATION COMPARISON

Moran's I vs. Other Spatial Statistics

A technical comparison of Moran's I with other core spatial statistics used to quantify gene expression patterns in tissue architecture.

FeatureMoran's IGeary's CRipley's K FunctionGetis-Ord Gi*

Primary Measurement

Global spatial autocorrelation

Global spatial autocorrelation

Spatial point pattern clustering across distances

Local hot spot and cold spot detection

Value Range

-1 to +1

0 to 2

Positive continuous values

Z-score (positive or negative)

Null Hypothesis Interpretation

0 = random distribution

1 = random distribution

Observed K(r) = theoretical Poisson K(r)

0 = no local clustering

Sensitivity to Distance Scale

Single global statistic

Single global statistic

Function evaluated across multiple radii (r)

Local statistic with neighborhood definition

Identifies Local Clusters

Handles Point Pattern Data

Typical Spatial Transcriptomics Use Case

Quantifying overall gene expression clustering in tissue

Assessing global spatial heterogeneity of a marker

Analyzing cell-type dispersion at varying distances

Identifying tumor microenvironment hot spots

Computational Complexity

O(n²) naive; O(n log n) optimized

O(n²) naive; O(n log n) optimized

O(n²) for edge correction

O(n²) for local neighborhood computation

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.