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.
Glossary
Spatial Neighborhood Graph

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.
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.
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.
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
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
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
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
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
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
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.
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.
Related Terms
Core concepts for constructing and analyzing graph representations of spatial biology data, enabling neighborhood-aware computation and tissue architecture modeling.
Spatial Autocorrelation (Moran's I)
A statistical measure quantifying the degree to which a gene's expression is dependent on its spatial location. Moran's I ranges from -1 (dispersed) to +1 (highly clustered), with 0 indicating random distribution. A Spatial Neighborhood Graph provides the weight matrix defining which locations are considered neighbors. This analysis is critical for identifying Spatially Variable Genes (SVGs)—genes whose expression patterns are non-random and potentially biologically meaningful, such as those defining tissue boundaries or signaling gradients.
Spatial Domain Detection
The unsupervised task of partitioning a tissue into anatomically or functionally coherent regions. Algorithms like BayesSpace or SpaGCN use a Spatial Neighborhood Graph to encourage spatial smoothness in cluster assignments. Unlike standard clustering, these methods penalize fragmented assignments, ensuring that identified domains are contiguous. The graph structure allows the model to jointly consider gene expression similarity and physical adjacency, revealing structures like cortical layers in the brain or tumor-immune boundaries.
Ligand-Receptor Co-localization
A computational analysis that identifies spatially proximal cell-type pairs engaged in cell-cell communication. A Spatial Neighborhood Graph is constructed to define which cells are within signaling distance. The analysis then tests for significant co-expression where a ligand gene in a sender cell type and its cognate receptor gene in a neighboring receiver cell type are both highly expressed. Tools like CellChat and NicheNet use this graph-based approach to infer active signaling pathways in the tissue microenvironment.
Spatial Trajectory Inference
A computational method for ordering cells based on their spatial coordinates and transcriptomic profiles to reconstruct dynamic processes like differentiation or migration in situ. The Spatial Neighborhood Graph constrains the trajectory to follow physically connected paths, preventing biologically impossible jumps across tissue gaps. Algorithms such as SpaceFlow and stLearn use pseudo-time ordering on the graph to model how cells transition through states while respecting the underlying tissue architecture.
Delaunay Triangulation for Graph Construction
A geometric method for building a Spatial Neighborhood Graph from cell centroid coordinates. Unlike fixed-radius or k-nearest neighbor approaches, Delaunay triangulation connects points such that no point lies inside the circumcircle of any triangle. This creates a planar graph that naturally respects tissue topology, avoiding long-range edges across empty spaces. It is particularly useful for single-cell resolution data where cell density varies, providing an adaptive neighborhood definition without arbitrary distance thresholds.

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