| Title: | Easy single cell analysis platform for enrichment |
|---|---|
| Description: | A bridging R package to facilitate gene set enrichment analysis (GSEA) in the context of single-cell RNA sequencing. Using raw count information, Seurat objects, or SingleCellExperiment format, users can perform and visualize ssGSEA, GSVA, AUCell, and UCell-based enrichment calculations across individual cells. Alternatively, escape supports use of rank-based GSEA, such as the use of differential gene expression via fgsea. |
| Authors: | Nick Borcherding [aut, cre], Jared Andrews [aut], Tobias Hoch [ctb], Alexei Martsinkovskiy [ctb] |
| Maintainer: | Nick Borcherding <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 2.9.0 |
| Built: | 2026-05-30 08:32:58 UTC |
| Source: | https://github.com/bioc/escape |
This function allows the user to examine the mean ranking within groups across the gene set. The visualization uses the density function to display the relative position and distribution of rank.
densityEnrichment( input.data, gene.set.use, gene.sets, group.by = NULL, rug.height = 0.02, palette = "inferno" )densityEnrichment( input.data, gene.set.use, gene.sets, group.by = NULL, rug.height = 0.02, palette = "inferno" )
input.data |
A Seurat object or a SingleCellExperiment. |
gene.set.use |
Character. Name of the gene set to display. |
gene.sets |
A named list of character vectors, the result of
|
group.by |
Character. Metadata column used for grouping. Defaults to
the Seurat/SCE |
rug.height |
Numeric. Vertical spacing of the hit rug as a fraction of
the y-axis. Default is |
palette |
Character. Color palette name from
|
A 'patchwork'/'ggplot2' object.
gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc_small <- SeuratObject::pbmc_small densityEnrichment(pbmc_small, gene.set.use = "Tcells", gene.sets = gs)gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc_small <- SeuratObject::pbmc_small densityEnrichment(pbmc_small, gene.set.use = "Tcells", gene.sets = gs)
A convenience front-end to fgsea that lets you point at the
avg_log2FC and p_val_adj columns coming out of Seurat / DESeq2
/ edgeR etc. It converts them to a signed -log10(p) ranking, filters on
significance / effect size, and then runs fgsea.
enrichIt( input.data, gene.sets, gene_col = NULL, logFC_col = "avg_log2FC", pval_col = c("p_val_adj", "p_val"), ranking_fun = c("signed_log10_p", "logFC"), pval_cutoff = 1, logFC_cutoff = 0, minSize = 5, maxSize = 500, padjust_method = "BH", nproc = 0 )enrichIt( input.data, gene.sets, gene_col = NULL, logFC_col = "avg_log2FC", pval_col = c("p_val_adj", "p_val"), ranking_fun = c("signed_log10_p", "logFC"), pval_cutoff = 1, logFC_cutoff = 0, minSize = 5, maxSize = 500, padjust_method = "BH", nproc = 0 )
input.data |
Either:
|
gene.sets |
A named list of character vectors, the result of
|
gene_col |
Character or |
logFC_col |
Character. Column name for log-fold-change values. Default
is |
pval_col |
Character. Column name for p-values (or adjusted p-values).
Default is |
ranking_fun |
Character. How to build the ranking:
|
pval_cutoff |
Numeric. Filter genes with p-value above this threshold
before ranking. Default is |
logFC_cutoff |
Numeric. Filter genes with absolute log-fold-change
below this threshold before ranking. Default is |
minSize |
Integer. Minimum pathway size passed to fgsea. Default
is |
maxSize |
Integer. Maximum pathway size passed to fgsea. Default
is |
padjust_method |
Character. Multiple-testing correction method; any
method accepted by |
nproc |
Integer. Passed to fgsea. Use |
'data.frame' with the usual fgsea columns plus a convenient 'leadingEdge' character column collapsed with \";\".
fgsea, getGeneSets,
gseaEnrichment
pbmc_small <- SeuratObject::pbmc_small Seurat::Idents(pbmc_small) <- "groups" markers <- Seurat::FindMarkers(pbmc_small, ident.1 = "g1", ident.2 = "g2") gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) gsea <- enrichIt(markers, gene.sets = gs)pbmc_small <- SeuratObject::pbmc_small Seurat::Idents(pbmc_small) <- "groups" markers <- Seurat::FindMarkers(pbmc_small, ident.1 = "g1", ident.2 = "g2") gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) gsea <- enrichIt(markers, gene.sets = gs)
Create bar, dot, or network plots from enrichIt results.
enrichItPlot( res, plot.type = c("bar", "dot", "cnet"), top = 20, x.measure = "-log10(padj)", color.measure = x.measure, show.counts = TRUE, palette = "inferno", ... )enrichItPlot( res, plot.type = c("bar", "dot", "cnet"), top = 20, x.measure = "-log10(padj)", color.measure = x.measure, show.counts = TRUE, palette = "inferno", ... )
res |
Data frame. Output from |
plot.type |
Character. Visualization type. Options:
|
top |
Integer. Keep the top n terms per database
(ranked by adjusted p-value). Set to |
x.measure |
Character. Column in |
color.measure |
Character. Column mapped to color (dot plot only).
Default is same as |
show.counts |
Logical. If |
palette |
Character. Color palette name from
|
... |
Further arguments passed to ggplot2 geoms (e.g.,
|
A ggplot2 object (bar/dot) or ggraph object (cnet).
## Not run: ranks <- setNames(markers$avg_log2FC, rownames(markers)) gs <- getGeneSets("Homo sapiens", library = c("H", "C2")) res <- enrichIt(ranks, gs) enrichItPlot(res) enrichItPlot(res, "dot", top=10) enrichItPlot(res, "cnet", top=5) ## End(Not run)## Not run: ranks <- setNames(markers$avg_log2FC, rownames(markers)) gs <- getGeneSets("Homo sapiens", library = c("H", "C2")) res <- enrichIt(ranks, gs) enrichItPlot(res) enrichItPlot(res, "dot", top=10) enrichItPlot(res, "cnet", top=5) ## End(Not run)
'escape.gene.sets' ships with **escape** and provides a convenient set of cell-type and pathway signatures from the scRNA-seq tumor micro-environment study by Azizi *et al.* (2018, Cell doi:10.1016/j.cell.2018.06.021). These signatures capture major immune and stromal populations observed across breast-cancer samples and serve as a lightweight default for quick testing or exploratory analyses.
data("escape.gene.sets")data("escape.gene.sets")
The original paper defined cell-type signatures as the top differentially expressed genes per cluster (Azizi *et al.*, Supplementary Table S3).
Supplementary Table S3 in Azizi *et al.* (2018) <https://pubmed.ncbi.nlm.nih.gov/29961579/>
Azizi E, *et al.* **Single-cell map of diverse immune phenotypes in the breast tumor microenvironment.** *Cell* 173(5):1293-1308 (2018).
[runEscape()], [escape.matrix()], [getGeneSets()]
escape.matrix() computes per-cell enrichment for arbitrary gene-set
collections using one of four scoring back-ends and returns a dense numeric
matrix (cells x gene-sets). The expression matrix is processed in
user-defined chunks (groups) so that memory use remains predictable;
each chunk is dispatched in parallel via a BiocParallel BPPARAM
backend. Heavy engines (GSVA, UCell, AUCell) are loaded
lazily, keeping them in the package's Suggests field.
escape.matrix( input.data, gene.sets = NULL, method = "ssGSEA", groups = 1000, min.size = 5, normalize = FALSE, make.positive = FALSE, min.expr.cells = 0, min.filter.by = NULL, BPPARAM = NULL, ... )escape.matrix( input.data, gene.sets = NULL, method = "ssGSEA", groups = 1000, min.size = 5, normalize = FALSE, make.positive = FALSE, min.expr.cells = 0, min.filter.by = NULL, BPPARAM = NULL, ... )
input.data |
A raw-counts matrix (genes x cells), a
Seurat object, or a
SingleCellExperiment. Gene identifiers must
match those in |
gene.sets |
A named list of character vectors, the result of
|
method |
Character. Scoring algorithm (case-insensitive). One of
|
groups |
Integer. Number of cells per processing chunk. Larger values
reduce overhead but increase memory usage. Default is |
min.size |
Integer or |
normalize |
Logical. If |
make.positive |
Logical. If |
min.expr.cells |
Numeric. Gene-expression filter threshold. Default is
|
min.filter.by |
Character or |
BPPARAM |
A BiocParallel parameter object describing the
parallel backend. Default is |
... |
Extra arguments passed verbatim to the chosen back-end scoring
function ( |
A numeric matrix with one row per cell and one column per gene set,
ordered as in gene.sets.
"GSVA"Gene-set variation analysis (Poisson kernel).
"ssGSEA"Single-sample GSEA.
"UCell"Rank-based UCell scoring.
"AUCell"Area-under-the-curve ranking score.
Nick Borcherding, Jared Andrews
runEscape to attach scores to a single-cell object;
getGeneSets for MSigDB retrieval;
performNormalization for the optional normalization workflow.
gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc <- SeuratObject::pbmc_small es <- escape.matrix(pbmc, gene.sets = gs, method = "ssGSEA", groups = 500, min.size = 3)gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc <- SeuratObject::pbmc_small es <- escape.matrix(pbmc, gene.sets = gs, method = "ssGSEA", groups = 500, min.size = 3)
This function retrieves gene sets from MSigDB and caches the downloaded
object for future calls. It allows subsetting by main collection (library),
subcollection, or specific gene sets, and only supports human
("Homo sapiens") and mouse ("Mus musculus").
getGeneSets( species = c("Homo sapiens", "Mus musculus"), library = NULL, subcategory = NULL, gene.sets = NULL, version = "7.4", id = "SYM" )getGeneSets( species = c("Homo sapiens", "Mus musculus"), library = NULL, subcategory = NULL, gene.sets = NULL, version = "7.4", id = "SYM" )
species |
Character. Species name. Either |
library |
Character or |
subcategory |
Character or |
gene.sets |
Character or |
version |
Character. MSigDB version. Default is |
id |
Character. Identifier type. Default is |
A named list of character vectors (gene IDs).
## Not run: # Get all hallmark gene sets from human. gs <- getGeneSets(species = "Homo sapiens", library = "H") # Get a subset based on main collection and subcollection. gs <- getGeneSets(species = "Homo sapiens", library = c("C2", "C5"), subcategory = "GO:BP") ## End(Not run)## Not run: # Get all hallmark gene sets from human. gs <- getGeneSets(species = "Homo sapiens", library = "H") # Get a subset based on main collection and subcollection. gs <- getGeneSets(species = "Homo sapiens", library = c("C2", "C5"), subcategory = "GO:BP") ## End(Not run)
This function allows the user to examine the distribution of enrichment across groups by generating a geyser plot.
geyserEnrichment( input.data, assay = NULL, group.by = NULL, gene.set.use, color.by = "group", order.by = NULL, scale = FALSE, facet.by = NULL, summarise.by = NULL, summary.stat = "mean", palette = "inferno" )geyserEnrichment( input.data, assay = NULL, group.by = NULL, gene.set.use, color.by = "group", order.by = NULL, scale = FALSE, facet.by = NULL, summarise.by = NULL, summary.stat = "mean", palette = "inferno" )
input.data |
Output of |
assay |
Character. Name of the assay holding enrichment scores when
|
group.by |
Character. Metadata column plotted on the x-axis. Defaults
to the Seurat/SCE |
gene.set.use |
Character. Name of the gene set to display. |
color.by |
Character. Aesthetic mapped to point color. Options:
|
order.by |
Character or
|
scale |
Logical. If |
facet.by |
Character or |
summarise.by |
Character or |
summary.stat |
Character. Method used to summarize expression within
each group defined by |
palette |
Character. Color palette name from
|
A ggplot2 object.
gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc <- SeuratObject::pbmc_small |> runEscape(gene.sets = gs, min.size = NULL) geyserEnrichment(pbmc, assay = "escape", gene.set.use = "Tcells")gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc <- SeuratObject::pbmc_small |> runEscape(gene.sets = gs, min.size = NULL) geyserEnrichment(pbmc, assay = "escape", gene.set.use = "Tcells")
Produces the familiar two-panel GSEA graphic: running enrichment score (RES) plus a "hit" rug for a single gene-set evaluated across multiple biological groups (clusters, conditions, samples, etc.).
gseaEnrichment( input.data, gene.set.use, gene.sets, group.by = NULL, summary.fun = "mean", p = 1, nperm = 1000, rug.height = 0.02, digits = 2, BPPARAM = NULL, palette = "inferno" )gseaEnrichment( input.data, gene.set.use, gene.sets, group.by = NULL, summary.fun = "mean", p = 1, nperm = 1000, rug.height = 0.02, digits = 2, BPPARAM = NULL, palette = "inferno" )
input.data |
A Seurat object or a SingleCellExperiment. |
gene.set.use |
Character. Name of the gene set to display. |
gene.sets |
A named list of character vectors, the result of
|
group.by |
Character. Metadata column used for grouping. Defaults to
the Seurat/SCE |
summary.fun |
Character. Method used to collapse expression within
each group before ranking. One of: |
p |
Numeric. Weighting exponent in the KS statistic. Classical GSEA
uses |
nperm |
Integer. Number of gene-label permutations per group.
Default is |
rug.height |
Numeric. Vertical spacing of the hit rug as a fraction
of the y-axis. Default is |
digits |
Integer. Number of decimal places displayed for ES in the
legend. Default is |
BPPARAM |
A BiocParallel parameter object describing the
parallel backend. Default is |
palette |
Character. Color palette name from
|
A single 'patchwork'/'ggplot2' object
Based on Subramanian et al., PNAS 2005:
Within every group, library-size-normalize counts to CPM.
Collapse gene expression with summary.fun (mean/median/etc.).
Rank genes (descending) to obtain one ordered list per group.
Compute the weighted Kolmogorov-Smirnov running score (weight = |stat|^p).
ES = maximum signed deviation of the curve.
escape.matrix, densityEnrichment
pbmc_small <- SeuratObject::pbmc_small gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) gseaEnrichment(pbmc_small, gene.set.use = "Bcells", gene.sets = gs, group.by = "groups", summary.fun = "mean", digits = 3)pbmc_small <- SeuratObject::pbmc_small gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) gseaEnrichment(pbmc_small, gene.set.use = "Bcells", gene.sets = gs, group.by = "groups", summary.fun = "mean", digits = 3)
This function allows the user to examine a heatmap with the mean enrichment values by group. The heatmap displays gene sets as rows and the grouping variable as columns.
heatmapEnrichment( input.data, assay = NULL, group.by = NULL, gene.set.use = "all", cluster.rows = FALSE, cluster.columns = FALSE, facet.by = NULL, scale = FALSE, summary.stat = "mean", palette = "inferno" )heatmapEnrichment( input.data, assay = NULL, group.by = NULL, gene.set.use = "all", cluster.rows = FALSE, cluster.columns = FALSE, facet.by = NULL, scale = FALSE, summary.stat = "mean", palette = "inferno" )
input.data |
Output of |
assay |
Character. Name of the assay holding enrichment scores when
|
group.by |
Character. Metadata column plotted on the x-axis. Defaults
to the Seurat/SCE |
gene.set.use |
Character vector or |
cluster.rows |
Logical. If |
cluster.columns |
Logical. If |
facet.by |
Character or |
scale |
Logical. If |
summary.stat |
Character. Method used to summarize expression within
each group. One of: |
palette |
Character. Color palette name from
|
A ggplot2 object.
gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc <- SeuratObject::pbmc_small |> runEscape(gene.sets = gs, min.size = NULL) heatmapEnrichment(pbmc, assay = "escape", palette = "viridis")gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc <- SeuratObject::pbmc_small |> runEscape(gene.sets = gs, min.size = NULL) heatmapEnrichment(pbmc, assay = "escape", palette = "viridis")
This function allows the user to examine the distribution of principal components computed on the enrichment values.
pcaEnrichment( input.data, dimRed = NULL, x.axis = "PC1", y.axis = "PC2", facet.by = NULL, style = c("point", "hex"), add.percent.contribution = TRUE, display.factors = FALSE, number.of.factors = 10, palette = "inferno" )pcaEnrichment( input.data, dimRed = NULL, x.axis = "PC1", y.axis = "PC2", facet.by = NULL, style = c("point", "hex"), add.percent.contribution = TRUE, display.factors = FALSE, number.of.factors = 10, palette = "inferno" )
input.data |
Single-cell object (Seurat / SCE) or the raw list
returned by |
dimRed |
Character. Name of the dimensional-reduction slot to pull from
a single-cell object. Ignored when |
x.axis |
Character. Name of the principal component to display on the
x-axis (e.g., |
y.axis |
Character. Name of the principal component to display on the
y-axis (e.g., |
facet.by |
Character or |
style |
Character. Plot style. Options:
|
add.percent.contribution |
Logical. If |
display.factors |
Logical. If |
number.of.factors |
Integer. Number of loadings to display when
|
palette |
Character. Color palette name from
|
A **ggplot2** object.
GS <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc_small <- SeuratObject::pbmc_small pbmc_small <- runEscape(pbmc_small, gene.sets = GS, min.size = NULL) pbmc_small <- performPCA(pbmc_small, assay = "escape") pcaEnrichment(pbmc_small, x.axis = "PC1", y.axis = "PC2", dimRed = "escape.PCA")GS <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc_small <- SeuratObject::pbmc_small pbmc_small <- runEscape(pbmc_small, gene.sets = GS, min.size = NULL) pbmc_small <- performPCA(pbmc_small, assay = "escape") pcaEnrichment(pbmc_small, x.axis = "PC1", y.axis = "PC2", dimRed = "escape.PCA")
Scales each enrichment value by the number of genes from the set that are expressed in that cell (non-zero counts). Optionally shifts results into a positive range and/or applies a natural-log transform for compatibility with log-based differential tests.
performNormalization( input.data, enrichment.data = NULL, assay = "escape", gene.sets = NULL, make.positive = FALSE, scale.factor = NULL, groups = NULL )performNormalization( input.data, enrichment.data = NULL, assay = "escape", gene.sets = NULL, make.positive = FALSE, scale.factor = NULL, groups = NULL )
input.data |
A raw-counts matrix (genes x cells), a
Seurat object, or a
SingleCellExperiment. Gene identifiers must
match those in |
enrichment.data |
Matrix. Output of |
assay |
Character. Name of the assay holding enrichment scores when
|
gene.sets |
A named list of character vectors, the result of
|
make.positive |
Logical. If |
scale.factor |
Numeric vector or |
groups |
Integer or |
If 'input.data' is an object, the same object with a new assay "<assay>_normalized". Otherwise a matrix of normalized scores.
gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc <- SeuratObject::pbmc_small |> runEscape(gene.sets = gs, min.size = NULL) pbmc <- performNormalization(pbmc, assay = "escape", gene.sets = gs)gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc <- SeuratObject::pbmc_small |> runEscape(gene.sets = gs, min.size = NULL) pbmc <- performNormalization(pbmc, assay = "escape", gene.sets = gs)
This function allows users to calculate the principal components for the
gene set enrichment values. For single-cell data, the PCA will be stored
with the dimensional reductions. If a matrix is used as input, the output
is a list for further plotting. Alternatively, users can use functions for
PCA calculations based on their desired workflow in lieu of using
performPCA, but will not be compatible with downstream
pcaEnrichment visualization.
performPCA( input.data, assay = "escape", scale = TRUE, n.dim = 10, reduction.name = "escape.PCA", reduction.key = "escPC_" )performPCA( input.data, assay = "escape", scale = TRUE, n.dim = 10, reduction.name = "escape.PCA", reduction.key = "escPC_" )
input.data |
Output of |
assay |
Character. Name of the assay holding enrichment scores when
|
scale |
Logical. If |
n.dim |
Integer. The number of principal components to compute and
keep. Default is |
reduction.name |
Character. Name used for the dimensional reduction
slot when writing back to a Seurat/SCE object. Default is
|
reduction.key |
Character. Key prefix for the dimensional reduction
when writing back to a Seurat/SCE object. Default is |
*If* 'input.data' is a single-cell object, the same object with a new dimensional-reduction slot. *Otherwise* a list with 'PCA', 'eigen_values', 'contribution', and 'rotation'.
gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc <- SeuratObject::pbmc_small |> runEscape(gene.sets = gs, min.size = NULL) pbmc <- performPCA(pbmc, assay = "escape")gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc <- SeuratObject::pbmc_small |> runEscape(gene.sets = gs, min.size = NULL) pbmc <- performPCA(pbmc, assay = "escape")
This function allows the user to examine the distribution of enrichment across groups by generating a ridge plot.
ridgeEnrichment( input.data, gene.set.use, assay = NULL, group.by = NULL, color.by = "group", order.by = NULL, scale = FALSE, facet.by = NULL, add.rug = FALSE, palette = "inferno" )ridgeEnrichment( input.data, gene.set.use, assay = NULL, group.by = NULL, color.by = "group", order.by = NULL, scale = FALSE, facet.by = NULL, add.rug = FALSE, palette = "inferno" )
input.data |
Output of |
gene.set.use |
Character. Name of the gene set to display. |
assay |
Character. Name of the assay holding enrichment scores when
|
group.by |
Character. Metadata column plotted on the y-axis. Defaults
to the Seurat/SCE |
color.by |
Character. Aesthetic mapped to fill color. Options:
|
order.by |
Character or
|
scale |
Logical. If |
facet.by |
Character or |
add.rug |
Logical. If |
palette |
Character. Color palette name from
|
A [ggplot2] object.
gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc <- SeuratObject::pbmc_small |> runEscape(gene.sets = gs, min.size = NULL) ridgeEnrichment(pbmc, assay = "escape", gene.set.use = "Tcells", group.by = "groups")gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc <- SeuratObject::pbmc_small |> runEscape(gene.sets = gs, min.size = NULL) ridgeEnrichment(pbmc, assay = "escape", gene.set.use = "Tcells", group.by = "groups")
runEscape() is a convenience wrapper around escape.matrix
that computes enrichment scores and inserts them as a new assay (default
"escape") in a Seurat or SingleCellExperiment object. All
arguments (except new.assay.name) map directly to their counterparts
in escape.matrix().
runEscape( input.data, gene.sets, method = c("ssGSEA", "GSVA", "UCell", "AUCell"), groups = 1000, min.size = 5, normalize = FALSE, make.positive = FALSE, new.assay.name = "escape", min.expr.cells = 0, min.filter.by = NULL, BPPARAM = NULL, ... )runEscape( input.data, gene.sets, method = c("ssGSEA", "GSVA", "UCell", "AUCell"), groups = 1000, min.size = 5, normalize = FALSE, make.positive = FALSE, new.assay.name = "escape", min.expr.cells = 0, min.filter.by = NULL, BPPARAM = NULL, ... )
input.data |
A raw-counts matrix (genes x cells), a
Seurat object, or a
SingleCellExperiment. Gene identifiers must
match those in |
gene.sets |
A named list of character vectors, the result of
|
method |
Character. Scoring algorithm (case-insensitive). One of
|
groups |
Integer. Number of cells per processing chunk. Larger values
reduce overhead but increase memory usage. Default is |
min.size |
Integer or |
normalize |
Logical. If |
make.positive |
Logical. If |
new.assay.name |
Character. Name for the assay that will store the
enrichment matrix in the returned object. Default is |
min.expr.cells |
Numeric. Gene-expression filter threshold. Default is
|
min.filter.by |
Character or |
BPPARAM |
A BiocParallel parameter object describing the
parallel backend. Default is |
... |
Extra arguments passed verbatim to the chosen back-end scoring
function ( |
The input single-cell object with an additional assay containing the enrichment scores (cells x gene-sets). Matrix orientation follows standard single-cell conventions (gene-sets as rows inside the assay).
Nick Borcherding, Jared Andrews
escape.matrix for the underlying computation;
performNormalization to add normalized scores;
heatmapEnrichment, ridgeEnrichment, and
related plotting helpers for visualization.
gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) sce <- SeuratObject::pbmc_small sce <- runEscape(sce, gene.sets = gs, method = "GSVA", groups = 1000, min.size = 3, new.assay.name = "escape")gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) sce <- SeuratObject::pbmc_small sce <- runEscape(sce, gene.sets = gs, method = "GSVA", groups = 1000, min.size = 3, new.assay.name = "escape")
Visualize the relationship between two enrichment scores at single-cell
resolution. By default, points are shaded by local 2-D density
(color.by = "density"), but users can instead color by a metadata
column (discrete) or by the raw gene-set scores themselves (continuous).
scatterEnrichment( input.data, assay = NULL, x.axis, y.axis, facet.by = NULL, group.by = NULL, color.by = c("density", "group", "x", "y"), style = c("point", "hex"), scale = FALSE, bins = 40, point.size = 1.2, alpha = 0.8, palette = "inferno", add.corr = FALSE )scatterEnrichment( input.data, assay = NULL, x.axis, y.axis, facet.by = NULL, group.by = NULL, color.by = c("density", "group", "x", "y"), style = c("point", "hex"), scale = FALSE, bins = 40, point.size = 1.2, alpha = 0.8, palette = "inferno", add.corr = FALSE )
input.data |
Output of |
assay |
Character. Name of the assay holding enrichment scores when
|
x.axis |
Character. Gene-set name to plot on the x-axis. |
y.axis |
Character. Gene-set name to plot on the y-axis. |
facet.by |
Character or |
group.by |
Character. Metadata column used when |
color.by |
Character. Aesthetic mapped to point color. Options:
|
style |
Character. Plot style. Options:
|
scale |
Logical. If |
bins |
Integer. Number of hex bins along each axis when
|
point.size |
Numeric. Point size for |
alpha |
Numeric. Transparency for points or hexbins.
Default is |
palette |
Character. Color palette name from
|
add.corr |
Logical. If |
A ggplot2 object.
gs <- list( Bcells = c("MS4A1","CD79B","CD79A","IGH1","IGH2"), Tcells = c("CD3E","CD3D","CD3G","CD7","CD8A") ) pbmc <- SeuratObject::pbmc_small |> runEscape(gene.sets = gs, min.size = NULL) scatterEnrichment( pbmc, assay = "escape", x.axis = "Tcells", y.axis = "Bcells", color.by = "group", group.by = "groups", add.corr = TRUE, point.size = 1 )gs <- list( Bcells = c("MS4A1","CD79B","CD79A","IGH1","IGH2"), Tcells = c("CD3E","CD3D","CD3G","CD7","CD8A") ) pbmc <- SeuratObject::pbmc_small |> runEscape(gene.sets = gs, min.size = NULL) scatterEnrichment( pbmc, assay = "escape", x.axis = "Tcells", y.axis = "Bcells", color.by = "group", group.by = "groups", add.corr = TRUE, point.size = 1 )
Visualize the distribution of gene set enrichment scores across groups using
violin plots. When split.by contains exactly two levels, the function
draws split violins for easy group comparison within each group.by
category. If split.by has more than two levels, standard dodged
violins are drawn instead.
splitEnrichment( input.data, assay = NULL, split.by = NULL, group.by = NULL, gene.set.use = NULL, order.by = NULL, facet.by = NULL, scale = TRUE, palette = "inferno" )splitEnrichment( input.data, assay = NULL, split.by = NULL, group.by = NULL, gene.set.use = NULL, order.by = NULL, facet.by = NULL, scale = TRUE, palette = "inferno" )
input.data |
Output of |
assay |
Character. Name of the assay holding enrichment scores when
|
split.by |
Character. Metadata column used to split or color violins. Must contain at least two levels. If more than two levels are present, dodged violins are used instead of split violins. |
group.by |
Character. Metadata column plotted on the x-axis. Defaults
to the Seurat/SCE |
gene.set.use |
Character. Name of the gene set to display. |
order.by |
Character or
|
facet.by |
Character or |
scale |
Logical. If |
palette |
Character. Color palette name from
|
A [ggplot2] object.
gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc <- SeuratObject::pbmc_small |> runEscape(gene.sets = gs, min.size = NULL) splitEnrichment(input.data = pbmc, assay = "escape", split.by = "groups", gene.set.use = "Tcells")gs <- list(Bcells = c("MS4A1", "CD79B", "CD79A", "IGH1", "IGH2"), Tcells = c("CD3E", "CD3D", "CD3G", "CD7","CD8A")) pbmc <- SeuratObject::pbmc_small |> runEscape(gene.sets = gs, min.size = NULL) splitEnrichment(input.data = pbmc, assay = "escape", split.by = "groups", gene.set.use = "Tcells")