scaper: Single-Cell Transcriptomics-Level Cytokine Activity Prediction and Estimation

📚 Documentation: https://zaoqu-liu.github.io/scaper/

R-universe R License: GPL (>= 2) GitHub

Abstract

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.


Scientific Background

Methodological Framework

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:

  1. Bidirectional Gene Set Scoring: Incorporates both up-regulated (positive weights) and down-regulated (negative weights) target genes from cytokine perturbation experiments
  2. Variance-Adjusted Mahalanobis Distance: Accounts for gene-gene correlation structure in high-dimensional transcriptomic space
  3. Database Integration: Leverages experimentally validated cytokine-response signatures and pathway topology information

Mathematical Formulation

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} $$

Database Resources

CytoSig Database

Reactome Database

VAM Methodology


Installation

From R-universe (Recommended)

install.packages("scaper", repos = "https://zaoqu-liu.r-universe.dev")

From GitHub

# Install remotes if needed
install.packages("remotes")

# Install scaper
remotes::install_github("Zaoqu-Liu/scaper")

From Source

install.packages("scaper_0.2.1.tar.gz", repos = NULL, type = "source")

Usage

Quick Start

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")

Supported Cytokines

# 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


Detailed Examples

Example 1: Seurat Object Analysis with CytoSig

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

Example 2: Targeted Cytokine Analysis

# 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)

Example 3: Matrix-Based Analysis

# 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)

Example 4: Reactome Pathway-Based Scoring

# 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")

Example 5: Gene Set Construction

# 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)

Visualization

Heatmap Visualization

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"
)

Integration with Seurat Visualization

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 Reference

Primary Analysis Functions

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

Gene Set Construction Functions

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

Parameters

scape(counts.matrix, database, cytokine)

scapeForSeurat(seurat.object, database, cytokine, normalize)


Performance Characteristics

Computational Efficiency

The package has been optimized for computational efficiency:

Benchmark Results

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.


Biological Interpretation

Activity Score Interpretation

Score Range: [0, 1] (cumulative distribution function values)

Biological Meaning:

Cell Type Considerations

Different cell types exhibit distinct cytokine responsiveness profiles:


Technical Specifications

System Requirements

Dependencies

Required Packages:

Suggested Packages:

Compatibility


Advanced Usage

Custom Gene Set Analysis

Users 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"
)

Integration with Downstream Analysis

# 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)

Batch Processing

# 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
  )
})

Quality Assurance

Validation Metrics

The package has undergone extensive validation:

Known Limitations

  1. Small Datasets: Reactome analysis may fail for datasets with insufficient gene coverage (<100 genes)
  2. Normalization: Requires log-normalized data (not raw counts)
  3. Missing Genes: Activity scores computed using available genes only; limited overlap may affect accuracy

Citation

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:


Version History

Version 0.2.1 (2026-01-25)

Critical Fixes:

Performance Improvements:

Compatibility Enhancements:

Code Quality:

See IMPROVEMENTS.md for detailed technical changes.

Version 0.2.0 (2025-04-16)


Contributing

We welcome contributions! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/NewFeature)
  3. Commit your changes (git commit -m 'Add NewFeature')
  4. Push to the branch (git push origin feature/NewFeature)
  5. Open a Pull Request

Support and Bug Reports


Authors and Acknowledgments

Authors

Acknowledgments

We thank the developers of:


License

This package is licensed under the GNU General Public License (GPL) version 2 or later.

See the LICENSE file for details.


References

Primary Literature

  1. 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

  2. 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

  3. 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

Related Methodology

  1. 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

  2. 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


📦 R Package Information

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