A comprehensive spatial transcriptomics analysis workflow for 10x Genomics Visium data, covering data preprocessing, integration, cell type deconvolution, and cell-cell communication analysis.
βββ scripts/ # Analysis scripts
β βββ 1_ReadSpatialData.R # Spatial data loading
β βββ 2_SpatialDataQC.R # Spatial data quality control
β βββ 3_IntegrationAndClustering.R # Data integration and clustering
β βββ 4_scDataPreProcessing.R # Single-cell data preprocessing for SPOTlight
β βββ 5_SPOTlight_Deconv.R # SPOTlight cell type deconvolution
β βββ 6_SelectSpatialSpots.R # Spatial spot selection
β βββ 7_Unsupervised_Deconv.R # Unsupervised deconvolution
β βββ 8_Giotto_Communication.R # Cell-cell communication analysis
β βββ 99_blendFeaturePlot.R # Feature blending visualization
βββ data/ # Data directory
βββ results/ # Output results
βββ README.md
- R version 4.4.3 or higher
- macOS/Linux/Windows compatible
library(Seurat) # Single-cell and spatial analysis
library(SeuratObject) # Seurat object utilities
library(SPOTlight) # Cell type deconvolution
library(Giotto) # Spatial analysis and cell communication
library(STdeconvolve) # Unsupervised deconvolutionlibrary(ggplot2) # Visualization
library(patchwork) # Plot arrangement
library(dplyr) # Data manipulation
library(tidyverse) # Data science ecosystemlibrary(SingleCellExperiment) # Single-cell data container
library(scater) # Single-cell analysis tools
library(scran) # Single-cell analysis methods./data/
βββ GSE169749_RAW/ # Spatial transcriptomics data
β βββ sample_A1/
β β βββ filtered_feature_bc_matrix.h5
β β βββ spatial/
β β βββ tissue_positions_list.csv
β β βββ tissue_hires_image.png
β β βββ scalefactors_json.json
β βββ sample_B1/
β βββ filtered_feature_bc_matrix.h5
β βββ spatial/
β βββ tissue_positions_list.csv
β βββ tissue_hires_image.png
β βββ scalefactors_json.json
βββ GSE264408_RAW/ # Single-cell reference data
βββ controlExample/ # Single-cell count matrix
βββ GSE264408_metadata.csv # Single-cell metadata
- Load 10x Genomics Visium spatial data
- Process high-resolution tissue images
- Create and save Seurat objects
- Calculate QC metrics (nFeature, nCount, mitochondrial percentage)
- Spatial QC visualization
- Data filtering based on QC thresholds
- SCTransform normalization
- Multi-sample data integration
- PCA dimensionality reduction and UMAP visualization
- Cell clustering and differential expression analysis
- Spatially variable feature detection
- Single-cell RNA-seq quality control
- Cell type scoring using marker genes
- Reference dataset annotation
- Reference-based cell type deconvolution using single-cell data
- Cell type proportion visualization
- Spatial cell type distribution mapping
- Extract tissue coordinates
- Prepare spatial location data for downstream analysis
- Unsupervised cell type discovery using STdeconvolve
- Latent cell type identification
- Spatial network construction
- Ligand-receptor interaction analysis
- Cell-cell communication visualization
- Multi-gene co-expression analysis
- Spatial feature blending display
- Automated QC metric calculation
- Interactive QC plots
- Spatial distribution visualization
- Multi-sample data integration
- Batch effect correction
- Consensus clustering
- Supervised (SPOTlight) and unsupervised (STdeconvolve) methods
- Spatial localization of cell types
- Quantitative proportion analysis
- Spatially variable gene identification
- Cell spatial co-localization
- Ligand-receptor interaction networks
The pipeline generates the following main results:
- QC Reports: Data quality assessment plots
- Integration & Clustering: UMAP plots and spatial clustering maps
- Differential Expression: Gene expression heatmaps and volcano plots
- Cell Type Atlas: Deconvolution results and spatial distributions
- Communication Networks: Cell-cell interaction diagrams
- Prepare Data: Organize raw data according to the recommended structure
- Install Dependencies: Install required R packages
- Sequential Execution: Run scripts in numerical order
- Parameter Adjustment: Modify thresholds and parameters based on your data
# Run scripts sequentially
Rscript scripts/1_ReadSpatialData.R
Rscript scripts/2_SpatialDataQC.R
# ... continue with remaining scripts- QC thresholds (nFeature, nCount, mitochondrial percentage)
- Clustering resolution
- Differential expression parameters
- Number of cell types for deconvolution
- Data directory paths in each script
- Sample names and identifiers
- Image file paths and scaling factors
- Reference single-cell dataset
- Memory Requirements: Ensure sufficient memory for large spatial datasets
- Species Consistency: Single-cell reference data must match the species of spatial data
- File Paths: Verify correct configuration of image file paths
- Computational Resources: Recommended to run compute-intensive steps in HPC environments
- Package Versions: Maintain compatible package versions as specified in session info
This workflow was developed and tested with:
- R version 4.4.3
- Seurat 5.3.0
- Giotto 4.2.2
- SPOTlight 1.10.0
- STdeconvolve 1.3.2
For complete session info, see the R session information provided.
If you use this pipeline, please cite the relevant analysis methods and software packages used in this workflow.
Contributions and improvements to this pipeline are welcome. Please feel free to submit issues or pull requests.
