📚 Documentation: https://zaoqu-liu.github.io/scaper/
scaper implements the SCAPE (Single-Cell transcriptomics-level Cytokine Activity Prediction and Estimation) framework for quantifying cytokine signaling activity at single-cell resolution. The package integrates curated gene sets from the CytoSig and Reactome databases with the Variance-Adjusted Mahalanobis (VAM) scoring methodology, specifically adapted for single-cell RNA-sequencing (scRNA-seq) data analysis.
Cytokines are secreted proteins that mediate intercellular communication and regulate diverse biological processes including immune responses, cell differentiation, and tissue homeostasis. Accurate quantification of cytokine signaling activity in individual cells is crucial for understanding cellular heterogeneity and microenvironmental regulation in complex biological systems.
The SCAPE framework addresses this challenge through:
For cytokines with bidirectional regulation (CytoSig database):
$$ \text{Activity}{cytokine} = \frac{\text{CDF}{positive} + (1 - \text{CDF}_{negative})}{2} $$
where:
For pathway-based scoring (Reactome database):
$$ \text{Activity}{cytokine} = \text{CDF}{pathway} $$
install.packages("scaper", repos = "https://zaoqu-liu.r-universe.dev")
# Install remotes if needed
install.packages("remotes")
# Install scaper
remotes::install_github("Zaoqu-Liu/scaper")
install.packages("scaper_0.2.1.tar.gz", repos = NULL, type = "source")
library(scaper)
library(Seurat)
library(SeuratObject)
# Load example dataset
data(pbmc_small)
# Compute cytokine activity scores
result <- scapeForSeurat(
seurat.object = pbmc_small,
database = "cytosig",
cytokine = "all",
normalize = TRUE
)
# Extract scores
cytokine_scores <- GetAssayData(result, assay = "scape", layer = "data")
# CytoSig database (n = 41)
supportedCytokines(database = "cytosig")
# Reactome database (n = 30)
supportedCytokines(database = "reactome")
CytoSig Cytokines (41):
ActivinA, BDNF, BMP2, BMP4, BMP6, CD40LG, CXCL12, EGF, FGF2, GCSF, GDF11, GMCSF, HGF, IFNG, IFNL, IL10, IL12, IL13, IL15, IL17A, IL1A, IL1B, IL2, IL21, IL22, IL27, IL3, IL4, IL6, LIF, LTA, MCSF, NO, OSM, TGFB1, TGFB3, TNFA, TNFSF12, TRAIL, VEGFA, WNT3A
Reactome Cytokines (30):
BDNF, BMP2, BMP4, BMP6, CD40LG, CXCL12, EGF, FGF2, HGF, IFNG, IL10, IL13, IL15, IL17A, IL1A, IL1B, IL2, IL21, IL22, IL27, IL3, IL4, IL6, LIF, OSM, TGFB1, TGFB3, TNFSF12, VEGFA, WNT3A
library(scaper)
library(Seurat)
library(SeuratObject)
# Load and prepare data
data(pbmc_small)
pbmc_small <- NormalizeData(pbmc_small)
# Compute cytokine activity for all supported cytokines
cytokine_activity <- scapeForSeurat(
seurat.object = pbmc_small,
database = "cytosig",
cytokine = "all",
normalize = FALSE # Already normalized
)
# Access results (stored in "scape" assay)
activity_matrix <- GetAssayData(cytokine_activity, assay = "scape", layer = "data")
dim(activity_matrix) # 41 cytokines × n cells
# Focus on specific cytokines of interest
target_cytokines <- c("IL6", "IL4", "IL13", "IFNG", "TNFA")
result <- scapeForSeurat(
seurat.object = pbmc_small,
database = "cytosig",
cytokine = target_cytokines,
normalize = TRUE
)
# Extract and examine scores
scores <- as.data.frame(t(as.matrix(GetAssayData(result, assay = "scape", layer = "data"))))
head(scores)
# Prepare normalized expression matrix (cells × genes)
expression_data <- as.data.frame(t(as.matrix(GetAssayData(pbmc_small, layer = "data"))))
# Compute cytokine activity scores
activity_scores <- scape(
counts.matrix = expression_data,
database = "cytosig",
cytokine = "all"
)
# Result: matrix of dimension (n_cells × n_cytokines)
dim(activity_scores)
# Use Reactome pathway database instead of CytoSig
result_reactome <- scapeForSeurat(
seurat.object = pbmc_small,
database = "reactome",
cytokine = "all",
normalize = TRUE
)
# Scores stored in "VAMcdf" assay for Reactome
pathway_scores <- GetAssayData(result_reactome, assay = "VAMcdf", layer = "data")
# Reconstruct CytoSig gene set for IL6
file_cytosig <- system.file("extdata", "IL6_output.csv", package = "scaper")
il6_geneset <- genesetCytoSig(cytokine.eval = "IL6", file.name = file_cytosig)
# Examine gene weights
head(il6_geneset[order(-abs(il6_geneset$weight)), ], 10)
# Reconstruct Reactome gene set for IL6
file_reactome <- system.file("extdata", "IL6_Interleukin6_signaling.xml", package = "scaper")
il6_pathway <- genesetReactome(cytokine.eval = "IL6", file.name = file_reactome)
# Examine pathway genes
head(il6_pathway, 10)
library(pheatmap)
# Prepare data for visualization
activity_matrix <- as.data.frame(t(as.matrix(
GetAssayData(cytokine_activity, assay = "scape", layer = "data")
)))
# Create unclustered heatmap
pheatmap(
activity_matrix,
fontsize_row = 6,
fontsize_col = 7,
cluster_rows = FALSE,
cluster_cols = FALSE,
main = "Cytokine Activity Landscape"
)
# Create hierarchically clustered heatmap
pheatmap(
activity_matrix,
fontsize_row = 6,
fontsize_col = 7,
main = "Hierarchical Clustering of Cytokine Activities"
)
library(ggplot2)
# Add top cytokines to metadata
top_cytokines <- c("IL6", "IFNG", "IL4")
for (cyt in top_cytokines) {
pbmc_small <- AddMetaData(
pbmc_small,
metadata = activity_matrix[, cyt],
col.name = paste0(cyt, "_activity")
)
}
# Visualize on UMAP/tSNE
FeaturePlot(pbmc_small, features = paste0(top_cytokines, "_activity"))
| Function | Input | Output | Description |
|---|---|---|---|
scape() |
Normalized matrix (cells × genes) | Matrix (cells × cytokines) | Cytokine activity scores for expression matrix |
scapeForSeurat() |
Seurat object | Seurat object | Cytokine activity scores integrated into Seurat workflow |
| Function | Input | Output | Description |
|---|---|---|---|
genesetCytoSig() |
CSV file(s) | data.frame | Weighted gene sets from CytoSig database |
genesetReactome() |
XML file(s) | data.frame | Pathway gene sets from Reactome database |
supportedCytokines() |
Database name | character vector | List of available cytokines |
scape(counts.matrix, database, cytokine)scapeForSeurat(seurat.object, database, cytokine, normalize)The package has been optimized for computational efficiency:
Test System: macOS, R 4.4.0, 80 cells × 230 genes
| Analysis | Time | Performance |
|---|---|---|
| 5 cytokines | 15 ms | Excellent |
| 41 cytokines | 150 ms | Excellent |
| Single cell | 0.19 ms | Optimized |
Scalability: Tested on datasets ranging from 80 to 10,000+ cells.
Score Range: [0, 1] (cumulative distribution function values)
Biological Meaning:
High score (>0.7): Strong evidence of cytokine pathway activation
Medium score (0.3-0.7): Moderate or basal signaling activity
Low score (<0.3): Minimal cytokine pathway activity
Different cell types exhibit distinct cytokine responsiveness profiles:
Required Packages:
Seurat (≥ 3.0.0) - Single-cell analysis frameworkSeuratObject (≥ 4.0.0) - Seurat data structuresVAM - Variance-adjusted Mahalanobis scoringdplyr - Data manipulationxml2 - XML parsing (Reactome)stringr - String processingmagrittr - Pipe operatorSuggested Packages:
pheatmap - Heatmap visualizationggplot2 - Advanced plottingknitr, rmarkdown - Vignette buildingUsers can construct custom gene sets for novel cytokines:
# For CytoSig format (requires perturbation-derived CSV)
custom_geneset <- genesetCytoSig(
cytokine.eval = "CustomCytokine",
file.name = "path/to/custom_output.csv"
)
# For Reactome format (requires pathway XML)
custom_pathway <- genesetReactome(
cytokine.eval = "CustomCytokine",
file.name = "path/to/custom_pathway.xml"
)
# Integrate with Seurat clustering
pbmc_small <- FindNeighbors(pbmc_small)
pbmc_small <- FindClusters(pbmc_small)
# Compare cytokine activities across clusters
library(dplyr)
activity_by_cluster <- activity_matrix %>%
mutate(cluster = Idents(pbmc_small)) %>%
group_by(cluster) %>%
summarise(across(everything(), mean))
# Statistical testing
library(rstatix)
wilcox_results <- activity_matrix %>%
wilcox_test(IL6 ~ cluster)
# Process multiple samples efficiently
sample_list <- list(sample1, sample2, sample3)
results <- lapply(sample_list, function(sample) {
scapeForSeurat(
seurat.object = sample,
database = "cytosig",
cytokine = c("IL6", "IFNG", "TNFA"),
normalize = TRUE
)
})
The package has undergone extensive validation:
If you use scaper in your research, please cite:
@software{scaper2026,
title = {scaper: Single-Cell Transcriptomics-Level Cytokine Activity Prediction and Estimation},
author = {Liu, Zaoqu and Frost, H. Robert and Javaid, Azka},
year = {2026},
version = {0.2.1},
url = {https://github.com/Zaoqu-Liu/scaper},
note = {R package version 0.2.1}
}
And the underlying methodologies:
Critical Fixes:
scape() function: corrected negative weight gene handling with proper complement transformation $(1 - \text{CDF})$Performance Improvements:
Compatibility Enhancements:
Code Quality:
See IMPROVEMENTS.md for detailed technical changes.
We welcome contributions! Please:
git checkout -b feature/NewFeature)git commit -m 'Add NewFeature')git push origin feature/NewFeature)Zaoqu Liu (Maintainer, Primary Author)
Email: liuzaoqu@163.com
GitHub: @Zaoqu-Liu
H. Robert Frost (Original Author)
Affiliation: Dartmouth College
Azka Javaid (Original Author)
Affiliation: Dartmouth College
We thank the developers of:
This package is licensed under the GNU General Public License (GPL) version 2 or later.
See the LICENSE file for details.
Jiang, P., Zhang, Y., Ru, B., et al. (2021). CytoSig: A database of cytokine-regulated gene expression signatures in mammalian cells. Nature Methods, 18(10), 1181-1186. doi:10.1038/s41592-021-01274-5
Gillespie, M., Jassal, B., Stephan, R., et al. (2022). The reactome pathway knowledgebase 2022. Nucleic Acids Research, 50(D1), D687-D692. doi:10.1093/nar/gkab1028
Frost, H. R. (2020). Variance-adjusted Mahalanobis (VAM): a fast and accurate method for cell-specific gene set scoring. Nucleic Acids Research, 48(16), e94. doi:10.1093/nar/gkaa582
Hao, Y., Stuart, T., Kowalski, M. H., et al. (2024). Dictionary learning for integrative, multimodal and scalable single-cell analysis. Nature Biotechnology, 42, 293-304. doi:10.1038/s41587-023-01767-y
Ramilowski, J. A., Goldberg, T., Harshbarger, J., et al. (2015). A draft network of ligand-receptor-mediated multicellular signalling in human. Nature Communications, 6, 7866. doi:10.1038/ncomms8866
Package: scaper
Version: 0.2.1
License: GPL (≥ 2)
URL: https://github.com/Zaoqu-Liu/scaper
BugReports: https://github.com/Zaoqu-Liu/scaper/issues
Last Updated: 2026-01-25