Inferensys

Glossary

Spatial Neighborhood Graph

A data structure where each spatial location is a node, and edges connect neighboring locations based on a distance threshold or k-nearest neighbors, enabling spatial-aware computation.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
COMPUTATIONAL SPATIAL BIOLOGY

What is Spatial Neighborhood Graph?

A spatial neighborhood graph is a data structure that models a tissue as a network where each spatial location is a node, and edges connect neighboring locations based on a distance threshold or k-nearest neighbors, enabling spatial-aware computation.

A spatial neighborhood graph is a computational representation that encodes the physical proximity relationships between measurement locations in a tissue. Each node corresponds to a spatial transcriptomics spot or a segmented cell, while edges are drawn between pairs that fall within a predefined Euclidean distance or represent the k-nearest neighbors. This graph structure is the foundational input for spatial graph neural networks and spatial autocorrelation statistics like Moran's I.

By converting a continuous tissue image into a discrete graph, algorithms can perform spatial domain detection and spatial niche analysis without losing the critical context of cellular adjacency. The graph enables message-passing operations where a node's representation is updated by aggregating information from its immediate neighbors, allowing models to learn context-aware gene expression patterns that define anatomical structures.

GRAPH THEORY IN TISSUE SPACE

Key Properties of Spatial Neighborhood Graphs

Spatial neighborhood graphs transform tissue architecture into a mathematical structure where proximity defines connectivity, enabling graph-based algorithms to learn from spatial context.

01

Distance-Based Edge Construction

Edges are formed between nodes (cells or spots) when their Euclidean distance falls below a defined radius threshold. This captures the local microenvironment by connecting entities within a physical interaction range.

  • Radius selection is critical: too small creates disconnected components; too large dilutes local signal
  • Commonly used in Visium and Slide-seq analysis where spots are arranged on a regular grid
  • Enables spatial autocorrelation metrics like Moran's I to quantify expression clustering
  • Distance can be measured in pixels, micrometers, or tissue-aware geodesic paths
50-200 μm
Typical Radius Range
02

K-Nearest Neighbors (KNN) Graph

Each node connects to its k closest neighbors regardless of absolute distance, creating an adaptive graph that accounts for variable cell density across tissue regions.

  • Maintains consistent node degree across dense and sparse tissue zones
  • Prevents over-connection in cell-dense regions and under-connection in sparse areas
  • Standard choice for single-cell spatial data where cell distribution is heterogeneous
  • Typical k values range from 5 to 30 depending on tissue complexity
k=15
Common Default
03

Delaunay Triangulation

A geometric graph construction that connects nodes to form a triangulation where no point lies inside the circumcircle of any triangle. This produces a planar graph that respects natural tissue boundaries.

  • Guarantees spatial coherence without arbitrary threshold selection
  • Naturally adapts to irregular cell positions in in situ sequencing data
  • Forms the basis for alpha shapes that can identify tissue cavities and boundaries
  • Computationally efficient with O(n log n) construction algorithms
04

Weighted Spatial Edges

Edges carry numerical weights encoding the strength of spatial relationship, often defined as the inverse distance or a Gaussian kernel of distance between nodes.

  • Weights decay with distance: w_ij = exp(-d_ij² / 2σ²)
  • Enables graph attention mechanisms where closer neighbors exert stronger influence
  • Critical for spatial graph neural networks that learn context-aware cell representations
  • Weights can incorporate additional modalities like tissue morphology similarity
05

Spatial Graph Convolution

A message-passing operation where each node aggregates feature information from its spatial neighbors, producing a smoothed representation that captures local tissue context.

  • Analogous to convolutional filters in image processing, but operating on irregular graph topology
  • Enables detection of spatial domains and tissue compartments through iterative neighborhood aggregation
  • Forms the backbone of architectures like GraphSAGE and GAT applied to spatial omics
  • Multi-hop convolutions expand the receptive field to capture larger tissue structures
06

Graph-Based Spatial Clustering

Community detection algorithms partition the spatial graph into coherent tissue domains by optimizing for dense intra-domain connections and sparse inter-domain edges.

  • Leiden and Louvain algorithms are standard for identifying spatial niches
  • Integrates gene expression similarity with spatial adjacency for biologically meaningful clusters
  • Enables spatial domain detection without prior anatomical annotation
  • Resolution parameters control the granularity of identified tissue compartments
SPATIAL NEIGHBORHOOD GRAPHS

Frequently Asked Questions

Clear, technical answers to the most common questions about the graph data structures that power spatial transcriptomics analysis.

A spatial neighborhood graph is a data structure where each spatial location (a cell, a spot, or a pixel) is represented as a node, and edges connect nodes that are considered neighbors based on a predefined spatial rule. This rule is typically a distance threshold (e.g., all spots within 50 microns) or a k-nearest neighbors (k-NN) criterion (e.g., the 6 closest spots). The graph encodes the tissue's architecture into a mathematical format that algorithms can process. Once constructed, the graph enables spatial-aware computation by allowing information to propagate only between physically adjacent locations, rather than globally across the entire tissue. This is the foundational step for spatial clustering, trajectory inference, and graph neural network analysis.

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.