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 Data Analysis: A Guide to Preprocessing, Integration, and Interpretation

Spatial transcriptomics data analysis is the computational process of converting spatially resolved gene expression measurements into biological interpretations about tissue architecture, cell states, and intercellular communication. This guide covers the complete analytical workflow from raw data preprocessing through normalization, spatial clustering, integration with single-cell RNA sequencing data, and downstream biological interpretation. The intended readers are students, researchers, analysts, and life-science professionals who need a practical framework for handling spatial transcriptomics datasets generated by platforms such as 10x Visium, Visium HD, Stereo-seq, Xenium, and CosMx. The workflow described here applies to both sequencing-based and imaging-based spatial transcriptomics technologies, with platform-specific considerations noted where they affect analytical decisions.

At a Glance

Spatial transcriptomics technologies generate measurements of gene expression that retain positional information within a tissue section. The analytical pipeline transforms these raw measurements into interpretable biological insights through a sequence of computational steps. The table below summarizes the primary workflow stages, the key decisions at each stage, and the commonly used tools.

Workflow Stage Primary Decisions Representative Tools
Quality control and preprocessing Spot or cell filtering thresholds, gene filtering, ambient RNA correction, spot-swapping correction Seurat, Scanpy, Giotto, SpaDiff
Normalization Choice of normalization method, scaling factors, handling of sparse counts Seurat, Scanpy, Giotto
Dimensionality reduction and spatial clustering Number of principal components, spatial smoothing parameters, clustering resolution Seurat, Scanpy, Giotto, spCLUE
Integration with single-cell data Deconvolution approach, reference mapping strategy, batch effect handling Seurat, Scanpy, Cell2location, SEU-TCA
Downstream analysis Cell-cell communication inference, co-expression network analysis, spatial domain identification CellChat, hdWGCNA, SecAct, BANYAN

The field has matured rapidly since spatial transcriptomics emerged as an extension of RNA sequencing technology. RNA sequencing methods now include approaches for studying single-cell gene expression and spatial transcriptomics, with innovations in long-read and direct RNA-seq technologies contributing to a fuller understanding of RNA biology from transcription timing to RNA function [6]. Spatial transcriptomics has emerged as a tool to contextualize single cells in multicellular neighborhoods and to identify spatially recurrent phenotypes called ecotypes [5]. These technologies generate vast datasets with targeted-transcriptome and whole-transcriptome profiles of hundreds to millions of cells [5].

Understanding Spatial Transcriptomics Data Structures

Spatial transcriptomics platforms fall into two broad categories with distinct data structures. Sequencing-based platforms such as 10x Visium, Visium HD, and Stereo-seq capture RNA from spatially barcoded spots or bins on a tissue section, then sequence the captured transcripts. Imaging-based platforms such as Xenium, CosMx, and MERFISH use fluorescence in situ hybridization or in situ sequencing to detect and localize individual RNA molecules within intact tissue.

The data structure differs fundamentally between these categories. Sequencing-based platforms produce count matrices where each row represents a spatial spot or bin and each column represents a gene. Each spot may contain multiple cells, creating a measurement that aggregates expression across the cells present in that spatial location. Imaging-based platforms produce single-cell resolution data where individual cells are segmented from the image and transcripts are assigned to cells, generating a cell-by-gene count matrix with spatial coordinates for each cell.

The analytical implications of these structural differences are substantial. Spot-based data require deconvolution or cell-type mapping approaches to infer cell-type composition within each spot. Imaging-based data require careful cell segmentation and transcript assignment, and the computational difficulty increases with optical crowding, tissue thickness, and panel bias [16]. The preprocessing pipeline for imaging-based spatial transcriptomics converts raw fluorescence signals into molecule-level, cell-level, and tissue-level representations through steps including registration, restoration, feature detection, barcode decoding, molecule calling, cell segmentation, and transcript assignment [16].

Quality Control and Preprocessing

Quality control is the first critical step in spatial transcriptomics analysis. The goal is to identify and remove low-quality spots or cells, correct technical artifacts, and prepare the data for downstream analysis. Poor quality control decisions propagate through the entire analytical pipeline and can lead to spurious biological conclusions.

Spot and Cell Filtering

For sequencing-based platforms, the primary quality metrics are total unique molecular identifier counts per spot, total gene counts per spot, and the fraction of mitochondrial reads. Spots with very low UMI counts likely represent tissue gaps or poor capture efficiency. Spots with very high mitochondrial fractions may represent dying or damaged cells. The filtering thresholds should be determined from the data distribution instead of applied as fixed values across all datasets.

For imaging-based platforms, quality metrics include the number of transcripts detected per cell, the number of genes detected per cell, and the cell area or segmentation quality. Cells with very few transcripts may be segmentation artifacts or background noise. Cells with unusually large areas may represent segmentation errors where multiple cells were merged into one.

The choice of filtering thresholds requires examination of the data distribution for each sample. A common approach is to plot the distribution of UMI counts and gene counts across spots or cells, then set thresholds at the inflection points or at a percentile that removes clear outliers while retaining the biological signal. The filtering decisions should be recorded and reported because they affect all downstream analyses.

Ambient RNA and Background Correction

Ambient RNA contamination occurs when RNA from lysed cells adheres to the tissue section or the capture surface, creating background signal that is not specific to the spatial location. This is particularly problematic in sequencing-based platforms where the capture area includes gaps between cells. Ambient RNA correction methods estimate the background profile and subtract it from the measured counts.

Spot-swapping is a related artifact in sequencing-based spatial transcriptomics where RNA molecules are redistributed across neighboring spots, distorting spatial gene expression and biasing downstream analysis [13]. Denoising methods such as SpaDiff use a mass-conserving diffusion process to correct this artifact and improve the recovery of spatial gene-expression distributions [13]. In real tissues, SpaDiff relocalizes misplaced transcripts and improves spatial-domain recovery while preserving local tumor heterogeneity [13].

Platform-Specific Preprocessing Workflows

Some platforms have dedicated preprocessing workflows. Stereo-seq, for example, has an efficient and accurate data analysis workflow called SAW that handles the specific data structure and quality characteristics of Stereo-seq output [27]. When a platform-specific workflow is available, it should be used as the first preprocessing step before the general analytical pipeline.

Normalization Strategies

Normalization adjusts for technical variation in sequencing depth or capture efficiency across spots or cells. The goal is to make expression measurements comparable across spatial locations so that biological differences can be distinguished from technical differences.

Library Size Normalization

The most common normalization approach scales each spot or cell by its total UMI count, then applies a log transformation. This approach assumes that most genes are not differentially expressed across spatial locations, which is a reasonable assumption for many tissue types but may fail in tissues with strong regional differences in transcriptional activity.

Advanced Normalization Methods

More sophisticated normalization methods account for the sparse nature of spatial transcriptomics data. Count modeling approaches developed for single-cell RNA sequencing have been adapted for spatial data, including methods that model the count distribution explicitly instead of applying a simple scaling factor [10]. The choice of normalization method affects downstream clustering and differential expression results, so the method should be selected based on the data characteristics and the biological questions being addressed.

Spatial Smoothing and Denoising

Spatial smoothing exploits the observation that neighboring spots or cells tend to have similar expression profiles. Smoothing methods borrow information from spatial neighbors to reduce noise and improve the signal-to-noise ratio. However, excessive smoothing can blur genuine spatial boundaries and obscure fine-grained tissue structure. The degree of smoothing should be tuned carefully, and the results should be compared with and without smoothing to assess the impact on the biological conclusions.

Dimensionality Reduction and Spatial Clustering

After normalization, the data are typically reduced to a lower-dimensional representation before clustering. Principal component analysis is the most widely used approach, but other methods such as contrastive learning approaches have been developed specifically for spatial transcriptomics data [25].

Principal Component Selection

The number of principal components retained for clustering is a key decision. Too few components lose biological signal, while too many components introduce noise. Methods for selecting the number of components include examining the elbow in the variance explained plot, using jackstraw or permutation-based approaches, or using heuristic rules based on the dataset size.

Spatial Clustering Methods

Spatial clustering identifies groups of spots or cells with similar expression profiles that are spatially coherent. Standard clustering methods applied to single-cell data can be adapted for spatial data by incorporating spatial information into the clustering objective. Spatial clustering methods typically add a spatial smoothness constraint that encourages neighboring spots or cells to be assigned to the same cluster.

The clustering resolution parameter controls the number of clusters identified. Higher resolution values produce more clusters, which may reveal finer tissue structures but also increase the risk of over-clustering. The resolution should be selected based on the biological question and validated using cluster stability metrics or comparison with known anatomical structures.

Spatial Domain Identification

Spatial domains are regions of the tissue with distinct transcriptional programs and cellular composition. Identifying spatial domains is a common goal in spatial transcriptomics analysis because domains often correspond to anatomical structures or pathological regions. Methods for spatial domain identification include graph-based approaches that model the spatial relationships between spots or cells, and deep learning approaches that learn spatial representations from the data [26].

Integration with Single-Cell RNA Sequencing Data

Integration of spatial transcriptomics with single-cell RNA sequencing data is one of the most powerful analytical strategies in the field. Single-cell RNA sequencing provides high-resolution cell-type identification, while spatial transcriptomics provides the spatial context that single-cell data lack [18]. The integration approach compensates for the lack of spatial information inherent in scRNA-seq data [18].

Deconvolution of Spot-Based Data

For sequencing-based spatial platforms where each spot contains multiple cells, deconvolution methods estimate the cell-type composition of each spot using a reference from single-cell RNA sequencing data. Deconvolution approaches vary in their assumptions about the reference data, the number of cell types, and the spatial relationships between cells.

Benchmarking studies have compared integration methods for transcript distribution prediction and cell type deconvolution, providing guidance on method selection [19]. The choice of deconvolution method can substantially affect the inferred cell-type composition, so results should be validated using independent approaches or known tissue anatomy.

Reference-Free Approaches

Recent methods have moved beyond reference-based deconvolution. SpatialCell AI achieves reference-free single-cell resolution from spot-based spatial transcriptomics through morphology-guided enhancement [14]. This approach combines training-free operation with reference-free expression integration and per-cell output granularity, transforming spot-level data into individual cell records with spatial coordinates and per-cell expression [14]. On matched samples, this approach achieved high expression correlation against single-cell ground truth data [14].

Single-Cell Mapping Approaches

An alternative integration strategy maps single cells from scRNA-seq data onto spatial coordinates. Methods such as SEU-TCA use transfer component analysis to improve single-cell spatial mapping accuracy [22]. These approaches assign each single cell a spatial location based on its expression similarity to spatial spots or cells, enabling the spatial context of cell states to be inferred.

Multi-Slide and Multi-Modal Integration

Integration becomes more complex when combining multiple spatial slides or integrating spatial data with other modalities. Foundation models pretrained on large spatial transcriptomics datasets can integrate spatial data across multi-slide and multi-modal settings [24]. These models support cell-type deconvolution and contextualized missing gene expression imputation [24].

Multi-modal integration can also combine spatial transcriptomics with other spatially resolved measurements. A workflow that integrates MALDI mass spectrometry imaging with spatial transcriptomics on the same tissue section achieves pixel-perfect modality coregistration, enabling per-cell MALDI spectra extraction aligned with gene expression [21]. Integrated clustering reveals enhanced cell-type resolution and identifies metabolic heterogeneity within transcriptionally defined populations [21].

Cell-Cell Communication Inference

Cell-cell communication inference uses spatial transcriptomics data to predict ligand-receptor interactions between cells or cell types. The spatial context provided by spatial transcriptomics is particularly valuable for communication inference because it provides information about which cells are physically close enough to interact.

Ligand-Receptor Analysis

Ligand-receptor analysis methods use curated databases of known ligand-receptor pairs to identify potential communication events. The expression of a ligand in one cell type and its receptor in another cell type suggests a potential interaction. Spatial information can refine these predictions by requiring that the interacting cells are in close proximity.

Secreted Protein Signaling Inference

Secreted proteins mediate many intercellular communication events, but they do not act cell-autonomously, which limits systematic approaches to characterize their functions [15]. Computational frameworks such as SecAct infer the signaling activities of secreted proteins from spatial, single-cell, and bulk transcriptomic data [15]. These methods harness precomputed intercellular signaling signatures trained on large collections of spatial transcriptomics samples [15].

Community Connectivity Analysis

Beyond pairwise ligand-receptor interactions, community connectivity analysis characterizes the relative similarity of cells within and between spatial communities [12]. This analysis can elucidate cellular dynamics in important settings such as the tumor microenvironment [12]. Bayesian multi-layer network models integrate spatial and gene expression information to achieve community connectivity analysis [12].

Co-Expression Network Analysis

Co-expression network analysis identifies groups of genes that are coordinately expressed across spatial locations. These gene modules often represent functional units or regulatory programs active in specific tissue regions.

High-Dimensional WGCNA

Weighted gene co-expression network analysis has been adapted for high-dimensional transcriptomics data including spatial transcriptomics. The hdWGCNA framework provides functions for network inference, gene module identification, gene enrichment analysis, statistical tests, and data visualization [8]. It is directly compatible with Seurat and can analyze datasets containing nearly one million cells [8].

Module Interpretation

Gene modules identified through co-expression analysis should be interpreted in the context of the cell types present in the tissue and the spatial domains where they are active. Enrichment analysis can identify biological processes, pathways, or functions associated with each module. The spatial distribution of module activity can reveal regional differences in biological programs.

Trajectory and Developmental Analysis

Spatial transcriptomics data can be used to infer cellular trajectories and developmental processes. The spatial context provides additional information that can constrain trajectory inference and reveal the spatial organization of developmental intermediates.

Spatial Trajectory Inference

Trajectory inference methods order cells or spots along a continuous biological process such as differentiation or activation. Spatial information can be incorporated into trajectory inference to identify the spatial organization of trajectory states. For example, trajectory analysis of fibroblast subtypes in hepatocellular carcinoma revealed that VEGFA-positive cancer-associated fibroblasts are at the terminal stage of differentiation and are tumor-specific [20].

RNA Velocity and Pseudotime

RNA velocity analysis uses the ratio of unspliced to spliced transcripts to infer the direction of transcriptional change. Pseudotime analysis orders cells along a trajectory based on their expression similarity. Both approaches can be applied to spatial transcriptomics data, with spatial information providing additional constraints on the inferred trajectories.

Practical Implementation Workflow

The following workflow provides a structured approach to spatial transcriptomics data analysis. Each step includes the key decisions and the records that should be maintained.

Step 1: Data Acquisition and Organization

Obtain the raw data from the sequencing facility or public repository. Public data repositories such as the NCBI Data Resources provide access to spatial transcriptomics datasets [2]. Organize the data with clear file naming conventions and metadata that records the platform, tissue type, sample identifier, and experimental conditions.

Step 2: Quality Control Assessment

Generate quality control plots for each sample, including UMI counts per spot or cell, gene counts per spot or cell, and mitochondrial fraction. Examine the spatial distribution of these metrics to identify tissue artifacts or capture failures. Record the filtering thresholds and the number of spots or cells removed.

Step 3: Preprocessing and Normalization

Apply platform-specific preprocessing if available. Correct for ambient RNA and spot-swapping artifacts. Normalize the data using a method appropriate for the data characteristics. Record the normalization method and parameters.

Step 4: Dimensionality Reduction and Clustering

Select the number of principal components or equivalent dimensions. Apply spatial clustering with a resolution appropriate for the biological question. Evaluate cluster stability and compare with known anatomical structures if available.

Step 5: Cell-Type Annotation or Deconvolution

For spot-based data, apply deconvolution methods using a single-cell reference. For imaging-based data, annotate cell types using marker genes or reference-based classification. Validate the annotations using known tissue anatomy and marker gene expression.

Step 6: Integration and Downstream Analysis

Integrate with single-cell data if available. Perform cell-cell communication inference, co-expression network analysis, or trajectory analysis as appropriate for the biological question. Generate visualizations that show the spatial distribution of key findings.

Step 7: Reporting and Reproducibility

Document all analysis steps, parameters, and software versions. Provide the code and data in a reproducible format. Report the quality control metrics and filtering decisions. Deposit the processed data and code in a public repository following data sharing policies [3].

Records and Measurements

Maintaining detailed records is essential for reproducible spatial transcriptomics analysis. The following records should be maintained for each dataset.

Analysis Log

The analysis log records every step performed on the data, including the software and version used, the parameters applied, and the rationale for each decision. This log enables the analysis to be reproduced and audited.

Quality Control Metrics

Quality control metrics should be recorded for each sample, including the number of spots or cells before and after filtering, the distribution of UMI counts and gene counts, and the fraction of spots or cells removed at each filtering step. These metrics provide context for interpreting the downstream results.

Parameter Settings

All parameter settings should be recorded, including normalization parameters, clustering resolution, number of principal components, and integration parameters. Parameter choices can substantially affect the results, so they must be documented and justified.

Version Control

Software versions should be recorded for all tools used in the analysis. Spatial transcriptomics analysis tools are under active development, and version differences can lead to different results. The analysis should be reproducible with the recorded software versions.

Common Failure Patterns

Several recurring problems appear in spatial transcriptomics analyses. Recognizing these failure patterns helps analysts avoid common pitfalls.

Over-Filtering or Under-Filtering

Aggressive filtering removes genuine biological signal, particularly for rare cell types or lowly expressed genes. Insufficient filtering retains technical artifacts that distort downstream analyses. The filtering thresholds should be validated by examining the spatial distribution of retained spots or cells and the expression of known marker genes.

Batch Effects Between Samples

Spatial transcriptomics datasets often include multiple samples processed in different batches. Batch effects can be mistaken for biological variation if not properly addressed. Integration methods should be applied to remove batch effects while preserving biological differences.

Misinterpretation of Spot-Level Data

Spot-based spatial transcriptomics measures the aggregate expression of multiple cells within each spot. Interpreting spot-level data as if it represented single cells leads to incorrect conclusions about cell-type-specific expression. Deconvolution or reference-based mapping should be used to infer cell-type composition.

Over-Smoothing of Spatial Patterns

Excessive spatial smoothing obscures fine-grained tissue structure and can merge distinct spatial domains. The degree of smoothing should be validated by comparing the results with and without smoothing and by examining whether known anatomical boundaries are preserved.

Circular Analysis

Using the same data to identify cell types and then to test hypotheses about those cell types creates circularity that inflates confidence in the results. Validation using independent datasets or experimental approaches is essential.

Limitations and Interpretation Boundaries

Spatial transcriptomics analysis has inherent limitations that should be acknowledged when interpreting results.

Resolution Limitations

Sequencing-based spatial platforms have limited resolution, with each spot containing multiple cells. The inability to resolve individual cells limits the granularity of cell-type identification and communication inference. Imaging-based platforms provide single-cell resolution but are typically limited to a targeted gene panel.

Gene Detection Sensitivity

Spatial transcriptomics platforms have lower gene detection sensitivity than single-cell RNA sequencing, particularly for sequencing-based platforms. Lowly expressed genes may not be detected, and the dropout rate is high. This limitation affects the reliability of differential expression analysis and the detection of rare transcripts.

Technical Artifacts

Spatial transcriptomics data contain technical artifacts including ambient RNA, spot-swapping, and tissue distortion. These artifacts can bias the results if not properly corrected. The effectiveness of correction methods varies across platforms and tissue types.

Computational Complexity

Spatial transcriptomics datasets are large, and some analysis methods are computationally intensive. The computational requirements should be considered when selecting methods and designing the analysis workflow.

Data Sharing and Reproducibility

Spatial transcriptomics data should be shared following established data sharing policies. The NIH Genomic Data Sharing Policy provides a framework for sharing genomic data generated with NIH funding [3]. Data sharing enables validation of results and secondary analysis by other researchers.

The FAIR Guiding Principles provide a framework for making data findable, accessible, interoperable, and reusable [4]. Applying these principles to spatial transcriptomics data involves using standard file formats, providing comprehensive metadata, and depositing data in public repositories.

Public data repositories such as the NCBI Data Resources provide access to spatial transcriptomics datasets [2]. Training resources for data analysis are available through organizations such as the EMBL-EBI Training program [1].

Frequently Asked Questions

What is the difference between sequencing-based and imaging-based spatial transcriptomics?

Sequencing-based platforms such as 10x Visium and Stereo-seq capture RNA from spatially barcoded spots on a tissue section and sequence the captured transcripts. Each spot contains multiple cells, so the measurement aggregates expression across cells. Imaging-based platforms such as Xenium and CosMx use fluorescence in situ hybridization or in situ sequencing to detect individual RNA molecules within intact tissue, providing single-cell resolution but typically limited to a targeted gene panel. The data structure and preprocessing requirements differ substantially between these platform types.

How do I choose the right spatial clustering resolution?

The clustering resolution controls the number of clusters identified. Higher resolution values produce more clusters, which may reveal finer tissue structures but also increase the risk of over-clustering. The resolution should be selected based on the biological question and validated using cluster stability metrics or comparison with known anatomical structures. A common approach is to test a range of resolutions and select the one that produces clusters consistent with known tissue anatomy or marker gene expression.

What is deconvolution and when is it needed?

Deconvolution estimates the cell-type composition of each spot in sequencing-based spatial transcriptomics data where each spot contains multiple cells. Deconvolution methods use a reference from single-cell RNA sequencing data to infer which cell types are present in each spot and in what proportions. Deconvolution is needed when the biological question requires cell-type-specific information that cannot be obtained directly from spot-level measurements.

How do I integrate spatial transcriptomics with single-cell RNA sequencing data?

Integration approaches fall into two main categories. Deconvolution methods estimate the cell-type composition of each spatial spot using a single-cell reference. Single-cell mapping approaches assign each single cell a spatial location based on its expression similarity to spatial spots or cells. The choice of approach depends on the data characteristics and the biological question. Benchmarking studies provide guidance on method selection [19].

What is ambient RNA and how do I correct for it?

Ambient RNA contamination occurs when RNA from lysed cells adheres to the tissue section or capture surface, creating background signal that is not specific to the spatial location. Ambient RNA correction methods estimate the background profile and subtract it from the measured counts. Spot-swapping is a related artifact where RNA molecules are redistributed across neighboring spots, and denoising methods such as SpaDiff correct this artifact [13].

What are spatial domains and how do I identify them?

Spatial domains are regions of the tissue with distinct transcriptional programs and cellular composition. Identifying spatial domains is a common goal because domains often correspond to anatomical structures or pathological regions. Methods for spatial domain identification include graph-based approaches that model spatial relationships and deep learning approaches that learn spatial representations from the data [26].

How do I infer cell-cell communication from spatial transcriptomics data?

Cell-cell communication inference uses ligand-receptor interactions to predict communication events between cells or cell types. The spatial context provided by spatial transcriptomics is valuable because it provides information about which cells are physically close enough to interact. Methods range from ligand-receptor analysis using curated databases to advanced frameworks that infer secreted protein signaling activities [15].

What are the main limitations of spatial transcriptomics analysis?

The main limitations include resolution constraints in sequencing-based platforms where each spot contains multiple cells, lower gene detection sensitivity compared to single-cell RNA sequencing, technical artifacts such as ambient RNA and spot-swapping, and computational complexity for large datasets. These limitations should be acknowledged when interpreting results, and validation using independent approaches is essential.

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.