Zubair Khalid

Virologist/Molecular Biologist | Veterinarian | Bioinformatician

Conventional & Molecular Virology • Vaccine Development • Computational Biology

Dr. Zubair Khalid is a veterinarian and virologist specializing in conventional and molecular virology, vaccine development, and computational biology. Dedicated to advancing animal health through innovative research and multi-omics approaches.

Dr. Zubair Khalid - Veterinarian, Virologist, and Vaccine Development Researcher specializing in Computational Biology, Multi-omics, Animal Health, and Infectious Disease Research

Section: Infrastructure, Cloud & Policy

Spatial Transcriptomics Neighborhood Analysis: Tools and Best Practices

Spatial transcriptomics neighborhood analysis examines how cells organize into multicellular units within intact tissue and how those units communicate. For researchers working with platforms such as Xenium, MERFISH, Visium HD, or Slide-seq, neighborhood analysis answers questions that single-cell RNA sequencing cannot: which cell types sit next to each other, which signaling programs operate across short distances, and which spatial configurations correlate with disease states. This article provides a practical framework for defining neighborhoods, selecting computational tools, running a reproducible workflow, and interpreting results within their biological and technical limits.

What Neighborhood Analysis Adds to Spatial Transcriptomics

Single-cell transcriptomics has broadened understanding of cellular diversity and gene expression dynamics in healthy and diseased tissues, but it removes cells from their tissue context. Spatial transcriptomics emerged as a tool to place single cells back into multicellular neighborhoods and to identify spatially recurrent phenotypes, sometimes called ecotypes. These technologies generate targeted and whole-transcriptome profiles from hundreds to millions of cells, and they have produced new insights into developmental hierarchies, cellular plasticity, and diverse tissue microenvironments. The computational methods that interpret these data have expanded rapidly, including approaches for sample processing, data integration, identification of subtle cell states, trajectory modeling, deconvolution, and spatial analysis.

Neighborhood analysis sits at the intersection of several of these tasks. It asks how cell types and states are arranged relative to one another, whether those arrangements repeat across a tissue section or across patients, and what functional consequences follow from specific spatial configurations. In cancer research, for example, tumors are organized into cellular neighborhoods with distinct compositions of cell subtypes, expression programs, and local cellular interactions. These neighborhoods can correlate with malignancy and clinical outcome, which makes them relevant beyond basic descriptive biology.

Core Concepts in Defining Cellular Neighborhoods

What Counts as a Neighborhood

A neighborhood is a local collection of cells or spots that share spatial proximity and often functional coordination. The definition depends on the resolution of the platform and the biological question. High-resolution platforms such as Xenium, MERFISH, and Visium HD profile individual cells while preserving tissue architecture. Lower-resolution sequencing-based platforms capture transcripts from spatial bins that may contain multiple cells. The choice of neighborhood definition must match the platform resolution and the scale of the biological process under study.

Most computational methods for spatial analysis do not explicitly model local tissue context such as boundaries, neighborhoods, or gradients. Tools that do model this context, such as SpNeigh, provide functions for boundary detection, spatial neighborhood extraction, distance-based weighting, and gradient-based statistical testing. These functions allow researchers to define neighborhoods not as arbitrary circles but as biologically meaningful units bounded by tissue structures or defined by distance from a feature of interest.

Cell Types, States, and Ecotypes

Neighborhood analysis requires a cell type annotation layer. This layer can come from clustering the spatial data directly or from integrating with matched single-cell RNA sequencing data. Once cell types are assigned, neighborhoods can be characterized by their cell type composition. Some analyses go further and define ecotypes, which are spatially recurrent phenotypes that combine cell states and their local environment. Identifying ecotypes requires comparing neighborhoods across many regions and asking which configurations recur.

Spatial Domains versus Neighborhoods

Spatial domains are contiguous regions with similar transcriptional profiles, often identified by clustering spots or cells based on expression and spatial location. Neighborhoods are related but not identical. A neighborhood can be centered on a cell or spot of interest and include its local environment, regardless of whether that environment falls within a single domain. Domain identification methods, including graph attention autoencoders and multi-scale contrastive learning approaches, can provide useful inputs for neighborhood analysis, but they do not replace explicit neighborhood definition.

At a Glance: Tool Selection for Neighborhood Analysis

Analysis Task Representative Tool Input Requirements Output Type Best Used When
Boundary detection and neighborhood extraction SpNeigh High-resolution spatial transcriptomics data with cell or spot coordinates Boundaries, neighborhoods, distance-weighted features You need to define tissue interfaces or gradients explicitly
Spatial relationship modeling MISTy Any spatial omics data with marker or gene expression and spatial coordinates Explainable view-specific relationship scores You want to dissect contributions from different spatial contexts
Cell-cell communication inference CellChat or CellPhoneDB Annotated cell types plus expression data Ligand-receptor interaction tables and signaling networks You need to test specific signaling hypotheses between cell types
Secreted protein signaling activity SecAct Spatial, single-cell, or bulk transcriptomic data Activity scores for secreted proteins You study secreted factors and their non-cell-autonomous effects
Domain identification Graph attention autoencoders or contrastive learning methods Spatial transcriptomics expression matrices with coordinates Spatial domain labels You need contiguous regions for downstream neighborhood comparison

Practical Workflow for Neighborhood Analysis

Step 1: Define the Biological Question and Platform Constraints

Before running any tool, specify what kind of neighborhood question you are asking. Are you looking for tissue boundaries and interface populations? Are you testing whether specific ligand-receptor pairs are active across adjacent cell types? Are you searching for recurrent multicellular units that correlate with outcome? Each question points to different tools and different neighborhood definitions.

Platform choice constrains what is possible. High-resolution platforms resolve individual cells and support cell-centric neighborhood definitions. Lower-resolution platforms require spot-based or deconvolution-based approaches. If you have matched histopathological images, you can integrate image features with transcriptomic data to improve cluster identification and smooth expression patterns, as demonstrated by methods that use Markov random field feature extraction from images.

Step 2: Preprocess and Annotate

Quality control, normalization, and cell type annotation are prerequisites for neighborhood analysis. If you have matched single-cell RNA sequencing data from the same tissue type, integration can improve annotation accuracy. For spatial data without matched single-cell data, use marker-based annotation or reference-based deconvolution.

Document every preprocessing decision. The choice of normalization method, the minimum gene or transcript count thresholds, and the annotation reference all affect downstream neighborhood results. These decisions should be recorded in a reproducible analysis script or notebook.

Step 3: Define Neighborhoods Explicitly

Choose a neighborhood definition that matches your platform and question. Options include:

  • Fixed-radius neighborhoods around each cell or spot
  • k-nearest neighbor graphs based on spatial coordinates
  • Boundary-delimited regions identified by tools such as SpNeigh
  • Spatial domains identified by clustering methods

For high-resolution data, cell-centric neighborhoods with distance-based weighting preserve local context. For lower-resolution data, neighborhood definitions must account for the fact that each spot may contain multiple cells.

Step 4: Run Neighborhood Composition and Gradient Analysis

Once neighborhoods are defined, compute their cell type composition. Ask whether specific cell types are enriched or depleted in particular neighborhoods. Test for gradients of gene expression across tissue features such as tumor margins, fibrotic zones, or vascular structures. Tools such as SpNeigh support region-based differential expression and smooth spatial modeling using spline-based regression, along with a spatial enrichment index that identifies genes enriched near defined spatial features.

Step 5: Infer Cell-Cell Communication

Cell-cell communication analysis uses annotated cell types and expression data to infer ligand-receptor interactions. Tools such as CellChat and CellPhoneDB are commonly used for this purpose. These tools generate interaction tables, signaling pathway activity scores, and network visualizations. They can reveal dominant signaling axes, such as the MIF signaling pathway with its receptor complexes, or metastasis-specific remodeling such as diversified VEGF signaling and enhanced SPP1-integrin interactions.

Communication inference is hypothesis-generating, not confirmatory. The inferred interactions should be validated with orthogonal methods such as immunohistochemistry, in situ hybridization, or functional assays.

Step 6: Integrate Spatial Context with Machine Learning Frameworks

Frameworks such as MISTy build multiple views that focus on different spatial or functional contexts. Each view captures a different scale or type of influence, and the framework quantifies how much each view contributes to explaining expression of a target gene or cell state. This approach is scalable from dozens to thousands of measured markers and produces explainable results that can be related to clinical features.

MISTy is particularly useful when you want to separate local cell-cell effects from broader tissue-level effects or from functional effects that are not spatially defined. The output is a set of relationship scores that indicate which contexts matter for which genes.

Step 7: Validate and Interpret

Neighborhood findings should be validated across biological replicates and, when possible, across independent cohorts. Spatial configurations that recur across patients are more likely to be biologically meaningful than configurations observed in a single section. If you have matched clinical outcome data, test whether specific neighborhoods or communication patterns correlate with response or survival.

Tools and Their Tradeoffs

SpNeigh for Boundary and Gradient Analysis

SpNeigh is an R package designed for spatial neighborhood analysis and spatially aware differential expression modeling. It includes tools for boundary detection, spatial neighborhood extraction, distance-based weighting, and gradient-based statistical testing. It supports both region-based differential expression and smooth spatial modeling using spline-based regression. The package has been demonstrated across multiple platforms and tissues, including mouse brain, human breast cancer, and human liver, revealing intermediate populations at tissue interfaces, immune microenvironment differences, and spatially zonated gene expression patterns.

Use SpNeigh when your question involves tissue boundaries, interfaces, or gradients. Its explicit modeling of local tissue context distinguishes it from methods that treat all spatial locations as equivalent.

MISTy for Explainable Spatial Relationship Modeling

MISTy is a flexible, scalable, and explainable machine learning framework for extracting relationships from spatial omics data. It builds multiple views focusing on different spatial or functional contexts and quantifies the contribution of each view. The framework has been evaluated on in silico and breast cancer datasets measured by imaging mass cytometry and spatial transcriptomics.

Use MISTy when you need to dissect which spatial contexts drive expression of specific genes or cell states. Its explainability makes it suitable for generating testable hypotheses about spatial regulation.

CellChat and CellPhoneDB for Communication Inference

CellChat and CellPhoneDB are widely used for inferring cell-cell communication from annotated cell type data. They identify ligand-receptor pairs that are expressed in interacting cell populations and score the strength of those interactions. These tools have been applied across many tissue types and disease contexts, including colorectal cancer, pancreatic cancer, and diabetic kidney disease.

Communication inference requires careful interpretation. Expression of a ligand and receptor does not guarantee functional signaling. The inferred interactions should be prioritized based on biological plausibility and validated experimentally.

SecAct for Secreted Protein Signaling Activity

SecAct is a computational framework that infers the signaling activities of 1,170 human secreted proteins from spatial, single-cell, and bulk transcriptomic data. The inference model uses precomputed intercellular signaling signatures trained on 1,258 spatial transcriptomics samples spanning 37 cancer types. For spatial and single-cell data, SecAct provides interactive modules for analyzing secreted protein-mediated cell-cell communication.

Use SecAct when your question centers on secreted proteins and their non-cell-autonomous effects. The framework has been validated using transcriptomics data from antisecreted protein therapies and applied to large immunotherapy cohorts.

Domain Identification Methods

Several methods identify spatial domains using graph-based or contrastive learning approaches. These include graph attention autoencoders and multi-scale contrastive learning algorithms. These methods produce contiguous spatial domains that can serve as inputs for neighborhood analysis. They are most useful when you need an unbiased segmentation of the tissue into transcriptionally distinct regions.

Records and Measurements for Reproducible Analysis

What to Record

Reproducibility in spatial transcriptomics analysis requires detailed records of every processing and analysis step. Maintain a version-controlled analysis script or notebook that documents:

  • Platform and protocol used for data generation
  • Quality control thresholds and the number of cells or spots retained
  • Normalization method and parameters
  • Cell type annotation approach and reference data
  • Neighborhood definition parameters, including radius or neighbor count
  • Tool versions and parameter settings for each analysis step
  • Random seeds for any stochastic methods

Quality Metrics to Track

Track quality metrics at each stage. Before neighborhood analysis, record the number of cells or spots, the median transcripts per cell or spot, and the number of detected genes. After annotation, record the proportion of cells assigned to each cell type and the fraction of unassigned cells. After neighborhood definition, record the distribution of neighborhood sizes and the number of neighborhoods per tissue section.

Reproducibility Controls

Use containerized environments or package managers to lock tool versions. Record the computational environment, including operating system and package versions. For methods that involve stochastic steps, set and record random seeds. When possible, run the analysis on a subset of data first to confirm the pipeline runs end to end before scaling to the full dataset.

Common Failure Patterns and How to Avoid Them

Mismatch Between Neighborhood Definition and Platform Resolution

A frequent failure is defining neighborhoods at a scale that does not match the platform. For low-resolution platforms, cell-centric neighborhoods may be meaningless because each spot contains multiple cells. Conversely, for high-resolution platforms, overly large neighborhoods may blur biologically distinct compartments. Match the neighborhood scale to the platform resolution and the biological process.

Ignoring Technical Noise

Sequencing-based spatial transcriptomics data are complicated by high technical noise and limited resolution. Methods that integrate matched histopathological images can mitigate some of this noise. If image data are available, consider using integrative approaches instead of analyzing transcriptomic data alone.

Overinterpreting Communication Inferences

Cell-cell communication tools infer potential interactions from expression data. These inferences are not measurements of actual signaling. Overinterpreting ligand-receptor tables without validation leads to false conclusions. Treat communication inference as hypothesis generation and validate priority interactions experimentally.

Failure to Account for Batch Effects

Spatial transcriptomics datasets often come from multiple batches, sections, or patients. Batch effects can create spurious neighborhoods or obscure real ones. Apply batch correction methods appropriate for spatial data and validate that neighborhoods replicate across batches.

Neglecting Spatial Autocorrelation

Standard statistical tests assume independence of observations. Spatial data violate this assumption because nearby cells are more similar than distant cells. Use spatially aware statistical methods, such as those implemented in SpNeigh, to avoid inflated significance.

Limitations of Neighborhood Analysis

Resolution Constraints

Spatial transcriptomics platforms vary widely in resolution. Some resolve individual molecules at subcellular levels, while others capture transcripts from spatial bins containing multiple cells. Neighborhood analysis is constrained by this resolution. Subcellular resolution enables different questions than spot-based resolution, and the analytical approach must adapt accordingly.

Computational Demands

Spatial transcriptomics datasets are large and computationally demanding. High-resolution datasets can contain hundreds of thousands to millions of cells. Neighborhood analysis, communication inference, and machine learning frameworks require substantial memory and compute resources. Plan computational infrastructure before starting large-scale analyses.

Interpretation Limits

Neighborhood analysis reveals spatial associations, not causal relationships. A neighborhood with a specific composition may arise from many biological processes, including migration, proliferation, or tissue architecture. Spatial correlation does not demonstrate functional interaction. Interpretation requires integrating spatial findings with orthogonal evidence.

Data Complexity

Spatial multi-omics studies generate multiple data modalities, including transcriptome, epigenome, proteome, and metabolome. Integrating these modalities is computationally challenging and requires specialized pipelines. The field still needs standardization of experimental setups and data analysis approaches.

Welfare and Safety Context for Data Handling

Spatial transcriptomics data often derive from human tissue samples. Handling these data requires attention to privacy and data sharing policies. The National Institutes of Health Genomic Data Sharing Policy governs the sharing of genomic data generated with NIH funding. Researchers should review this policy before depositing or sharing spatial transcriptomics data.

The FAIR Guiding Principles provide a framework for making data findable, accessible, interoperable, and reusable. Applying these principles to spatial transcriptomics data improves reproducibility and enables secondary analysis. Data repositories such as those maintained by the National Center for Biotechnology Information and the European Bioinformatics Institute provide infrastructure for depositing and accessing spatial transcriptomics datasets.

When working with human tissue, ensure that sample collection followed appropriate ethical approvals and that data sharing complies with consent terms. Document data provenance and any restrictions on data use.

Professional Escalation Criteria

Some analysis situations warrant escalation to a specialist. Escalate when:

  • You cannot resolve batch effects that obscure biological signal across sections or cohorts
  • Cell type annotation is unreliable and you need expert review of marker choices
  • Communication inference produces results that contradict established biology and you need to determine whether the inference or the biology is wrong
  • Computational resources are insufficient for the dataset size and you need guidance on subsampling or infrastructure
  • You plan to use neighborhood findings for clinical or regulatory decisions and need additional validation
  • You encounter data sharing or privacy questions that require institutional review or legal review

Frequently Asked Questions

What is the difference between a spatial domain and a cellular neighborhood?

A spatial domain is a contiguous region with a similar transcriptional profile, often identified by clustering cells or spots based on expression and location. A cellular neighborhood is a local collection of cells or spots defined by proximity to a cell or feature of interest. Domains are regions, while neighborhoods are local contexts that can cross domain boundaries.

Which spatial transcriptomics platforms support neighborhood analysis?

High-resolution platforms such as Xenium, MERFISH, and Visium HD profile individual cells and support cell-centric neighborhood definitions. Lower-resolution sequencing-based platforms require spot-based or deconvolution-based approaches. The choice of neighborhood definition must match the platform resolution.

How do I choose between CellChat and CellPhoneDB for communication analysis?

Both tools infer ligand-receptor interactions from annotated cell type data. The choice depends on your specific question and data format. CellChat provides pathway-level analysis and visualization, while CellPhoneDB emphasizes a curated database of ligand-receptor complexes. Many studies use both tools and compare results to increase confidence.

What is MISTy and when should I use it?

MISTy is a machine learning framework that builds multiple views focusing on different spatial or functional contexts. It quantifies how much each view contributes to explaining expression of target genes. Use MISTy when you need to dissect which spatial contexts drive expression and when you want explainable results that can be related to clinical features.

How do I validate cell-cell communication findings from spatial data?

Validation requires orthogonal methods. Immunohistochemistry can confirm protein expression of ligands and receptors in the predicted cell types. In situ hybridization can confirm spatial colocalization. Functional assays, such as coculture experiments or signaling pathway inhibition, can test whether the inferred interaction has functional consequences.

What are ecotypes in spatial transcriptomics?

Ecotypes are spatially recurrent phenotypes that combine cell states and their local environment. They represent repeated multicellular configurations across a tissue or across patients. Identifying ecotypes requires comparing neighborhoods across many regions and asking which configurations recur and whether they correlate with biological or clinical features.

How should I handle batch effects in spatial transcriptomics neighborhood analysis?

Apply batch correction methods appropriate for spatial data and validate that neighborhoods replicate across batches. Record batch information for every sample and test whether neighborhood findings are consistent across batches before drawing biological conclusions.

What data sharing policies apply to spatial transcriptomics data?

The NIH Genomic Data Sharing Policy governs genomic data generated with NIH funding. The FAIR Guiding Principles provide a framework for making data findable, accessible, interoperable, and reusable. Data repositories such as NCBI and EMBL-EBI provide infrastructure for depositing and accessing datasets. Review consent terms and institutional policies before sharing data.

Related Bioinformatics Guides

References and Further Reading

This article is educational and does not replace validated analysis plans, institutional policy, clinical interpretation, or specialist review.