📖 Documentation: https://zaoqu-liu.github.io/SpaGER/
Spatial Gene Enhancement via Domain Adaptation
SpaGER (Spatial Gene Expression in R) provides a high-performance R implementation of the SpaGE algorithm for predicting genome-wide expression profiles in spatial transcriptomics data through integration with single-cell RNA sequencing (scRNA-seq) reference datasets.
Spatial transcriptomics technologies, while providing invaluable spatial context, often measure only a limited panel of genes. SpaGER addresses this fundamental limitation by leveraging the comprehensive gene coverage of scRNA-seq data to impute unmeasured gene expression in spatial data, enabling more complete transcriptomic characterization of tissue architecture.
Theoretical Framework
SpaGER employs a domain adaptation approach based on Principal Vectors (PVs) to bridge the gap between spatial and single-cell transcriptomic domains:
Mathematical Foundation
The algorithm operates through the following steps:
Z-score Standardization: Both datasets are standardized using population standard deviation to ensure comparability
Principal Vector Computation: Identifies the optimal linear subspace that maximizes alignment between domains through SVD-based decomposition
Cosine Similarity Selection: Principal vectors are retained based on their cosine similarity, representing the alignment quality between domains
Weighted k-NN Imputation: Expression values are predicted using distance-weighted averaging of k nearest neighbors in the aligned subspace
Key Features
- High-Performance Computing: C++ acceleration via Rcpp/RcppArmadillo for computationally intensive operations
- Numerical Accuracy: Mathematically equivalent results to the original Python implementation (tolerance < 1e-6)
- Seurat Integration: Native support for Seurat v4 and v5 objects with automatic version detection
- Cross-Platform Compatibility: Validated on Windows, macOS (Intel/ARM), and Linux
- Flexible Dimensionality Reduction: Support for PCA, ICA, Factor Analysis, NMF, and PLS methods
- Comprehensive Validation: 60+ unit tests ensuring scientific accuracy
Installation
Recommended: R-Universe
# Install from R-Universe (recommended)
install.packages("SpaGER", repos = "https://zaoqu-liu.r-universe.dev")Alternative: GitHub
# Using remotes
remotes::install_github("Zaoqu-Liu/SpaGER")
# Or using devtools
devtools::install_github("Zaoqu-Liu/SpaGER")Optional Dependencies
For extended functionality:
install.packages(c("Seurat", "fastICA", "NMF", "pls", "psych"))Quick Start
library(SpaGER)
# Predict expression of unmeasured genes
predicted <- SpaGE(
spatial_data = spatial_expr, # Spatial transcriptomics data
rna_data = scrna_expr, # scRNA-seq reference
n_pv = 30, # Number of principal vectors
n_neighbors = 50 # k for KNN imputation
)
# With Seurat objects
library(Seurat)
spatial_obj <- SpaGE.Seurat(
spatial_seurat = visium_data,
rna_seurat = scrna_ref,
n_pv = 30
)See the documentation for comprehensive tutorials and examples.
Citation
If you use SpaGER in your research, please cite:
Original Algorithm
Abdelaal T, Mourragui S, Mahfouz A, Reinders MJT. (2020). SpaGE: Spatial Gene Enhancement using scRNA-seq. Nucleic Acids Research, 48(18):e107. DOI: 10.1093/nar/gkaa740
R Implementation
Liu Z. (2026). SpaGER: Spatial Gene Expression Prediction using scRNA-seq in R. GitHub: https://github.com/Zaoqu-Liu/SpaGER
Contact
- Author: Zaoqu Liu
- Email: liuzaoqu@163.com
- GitHub: @Zaoqu-Liu
- Documentation: https://zaoqu-liu.github.io/SpaGER/