Generates various types of plots for enrichment (over-representation) analysis.
Usage
EnrichmentPlot(
object = NULL,
db = "GO_BP",
group.by = NULL,
test.use = "wilcox",
res = NULL,
plot_type = c("bar", "dot", "lollipop", "network", "enrichmap", "wordcloud",
"comparison"),
split_by = c("Database", "Groups"),
color_by = "Database",
group_use = NULL,
id_use = NULL,
pvalueCutoff = NULL,
padjustCutoff = 0.05,
score_col = NULL,
scoreCutoff = NULL,
score_label = "Score",
topTerm = ifelse(plot_type == "enrichmap", 100, 6),
compare_only_sig = FALSE,
topWord = 100,
word_type = c("term", "feature"),
word_size = c(2, 8),
words_excluded = NULL,
network_layout = "fr",
network_labelsize = 5,
network_blendmode = "blend",
network_layoutadjust = TRUE,
network_adjscale = 60,
network_adjiter = 100,
enrichmap_layout = "fr",
enrichmap_cluster = "fast_greedy",
enrichmap_label = c("term", "feature"),
enrichmap_labelsize = 5,
enrichmap_nlabel = 4,
enrlichmap_nlabel = NULL,
enrichmap_show_keyword = FALSE,
enrichmap_mark = c("ellipse", "hull"),
enrichmap_expand = c(0.5, 0.5),
character_width = 50,
lineheight = 0.7,
palette = "Spectral",
palcolor = NULL,
aspect.ratio = 1,
legend.position = "right",
legend.direction = "vertical",
theme_use = "theme_scop",
theme_args = list(),
combine = TRUE,
nrow = NULL,
ncol = NULL,
byrow = TRUE,
seed = 11,
verbose = TRUE,
srt = NULL
)Arguments
- object
A Seurat object containing the results of RunDEtest and RunEnrichment. If specified, enrichment results will be extracted from the
Seuratobject automatically. If not specified, theresarguments must be provided.- db
The database to use for enrichment plot.
- group.by
Grouping variable in the
Seuratobject. This argument is only used ifobjectis specified.NULL(the default) selects the results that RunEnrichment stored for custom gene sets or custom cell groups, which are keyed as"custom".- test.use
Test to be used in differential expression analysis. This argument is only used if
objectis specified.- res
Enrichment results generated by RunEnrichment function. If provided, 'object', 'test.use' and 'group.by' are ignored.
- plot_type
The type of plot to generate. Options are:
"bar","dot","lollipop","network","enrichmap","wordcloud","comparison".- split_by
The splitting variable(s) for the plot. Can be
"Database","Groups", or both. Default isc("Database", "Groups")for plots.- color_by
The variable used for coloring.
- group_use
The group(s) to be used for enrichment plot.
- id_use
List of IDs to be used to display specific terms in the enrichment plot. Default value is
NULL.- pvalueCutoff
The p-value cutoff. Only work when
padjustCutoffisNULL.- padjustCutoff
The p-adjusted cutoff.
- score_col
Optional numeric score column. When supplied, terms are ranked and weighted by the absolute score and no p-value semantics are used. This is intended for activity or importance results such as pathway scores.
- scoreCutoff
Optional minimum absolute score used with
score_col.- score_label
Legend label used with
score_col.- topTerm
The number of top terms to display. Default is
6, or100ifplot_typeis"enrichmap".- compare_only_sig
Whether to compare only significant terms.
- topWord
The number of top words to display for wordcloud.
- word_type
The type of words to display in wordcloud. Options are
"term"and"feature".- word_size
The size range for words in wordcloud.
- words_excluded
Words to be excluded from the wordcloud. Default is
NULL, which means that the built-in words (words_excluded) will be used.- network_layout
The layout algorithm to use for network plot. Options are
"fr","kk","random","circle","tree","grid", or other algorithm fromigraphpackage.- network_labelsize
The label size for network plot.
- network_blendmode
The blend mode for network plot.
- network_layoutadjust
Whether to adjust the layout of the network plot to avoid overlapping words.
- network_adjscale
The scale for adjusting network plot layout.
- network_adjiter
The number of iterations for adjusting network plot layout.
- enrichmap_layout
The layout algorithm to use for enrichmap plot. Options are
"fr","kk","random","circle","tree","grid", or other algorithm fromigraphpackage.- enrichmap_cluster
The clustering algorithm to use for enrichmap plot. Options are
"walktrap","fast_greedy", or other algorithm fromigraphpackage.- enrichmap_label
The label type for enrichmap plot. Options are
"term"and"feature".- enrichmap_labelsize
The label size for enrichmap plot.
- enrichmap_nlabel
The number of labels to display for each cluster in enrichmap plot.
- enrlichmap_nlabel
Deprecated. Please use
enrichmap_nlabelinstead.- enrichmap_show_keyword
Whether to show the keyword of terms or features in enrichmap plot.
- enrichmap_mark
The mark shape for enrichmap plot. Options are
"ellipse"and"hull".- enrichmap_expand
The expansion factor for enrichmap plot.
- character_width
The maximum width of character of descriptions.
- lineheight
The line height for y-axis labels.
- palette
Color palette name. Available palettes can be found in thisplot::show_palettes.
- palcolor
Custom colors used to create a color palette.
- aspect.ratio
Panel aspect ratio.
- legend.position
Legend placement (
"none","left","right","bottom","top"), direction, and title.legend.title = NULLuses the group name.- legend.direction
Legend direction:
"horizontal"or"vertical".- theme_use, theme_args
Theme name or function, plus extra theme arguments.
- combine, nrow, ncol, byrow
Combine plots with patchwork.
combine = FALSEreturns a list of ggplots.- seed
Random seed.
- verbose
Whether to print messages.
- srt
Deprecated alias for
object; supply exactly one of the two. It will be removed in scop 1.0.0.
Examples
data(pancreas_sub)
pancreas_sub <- RunStandardWorkflow(pancreas_sub)
#> ℹ [2026-10-11 22:47:40] Start standard processing workflow...
#> ℹ [2026-10-11 22:47:40] Checking a list of <Seurat>...
#> ! [2026-10-11 22:47:40] Data 1/1 of the `srt_list` is "unknown"
#> ℹ [2026-10-11 22:47:40] Perform `NormalizeData()` with `normalization.method = 'LogNormalize'` on 1/1 of `srt_list`...
#> ℹ [2026-10-11 22:47:41] Perform `FindVariableFeatures()` on 1/1 of `srt_list`...
#> ℹ [2026-10-11 22:47:41] Use the separate HVF from `srt_list`
#> ℹ [2026-10-11 22:47:41] Number of available HVF: 2000
#> ℹ [2026-10-11 22:47:41] Finished check
#> ℹ [2026-10-11 22:47:41] Perform `ScaleData()`
#> ℹ [2026-10-11 22:47:41] Perform pca linear dimension reduction
#> ℹ [2026-10-11 22:47:41] Use stored estimated dimensions 1:23 for Standardpca
#> ℹ [2026-10-11 22:47:42] Perform `Seurat::FindClusters()` with `cluster_algorithm = 'louvain'` and `cluster_resolution = 0.6`
#> ℹ [2026-10-11 22:47:42] Reorder clusters...
#> ℹ [2026-10-11 22:47:42] Skip `log1p()` because `layer = data` is not "counts"
#> ℹ [2026-10-11 22:47:42] Perform umap nonlinear dimension reduction
#> ✔ [2026-10-11 22:47:48] Standard processing workflow completed
pancreas_sub <- RunDEtest(
pancreas_sub,
group.by = "CellType"
)
#> ℹ [2026-10-11 22:47:48] Data type is log-normalized
#> ℹ [2026-10-11 22:47:48] Start differential expression test
#> ℹ [2026-10-11 22:47:48] Find all markers(wilcox) among [1] 5 groups...
#> ℹ [2026-10-11 22:47:48] Using 1 core
#> ⠙ [2026-10-11 22:47:48] Running for Ductal [1/5] ■■ 20% | ETA: 11s
#> ⠹ [2026-10-11 22:47:48] Running for Ngn3-high-EP [2/5] ■■■■ 40% | ETA: …
#> ⠸ [2026-10-11 22:47:48] Running for Endocrine [3/5] ■■■■■■ 60% | ETA: 4s
#> ✔ [2026-10-11 22:47:48] Completed 5 tasks in 10.7s
#>
#> ℹ [2026-10-11 22:47:48] Building results
#> ✔ [2026-10-11 22:47:59] Differential expression test completed
pancreas_sub <- RunEnrichment(
pancreas_sub,
db = c("GO_BP", "GO_CC"),
group.by = "CellType",
species = "Mus_musculus"
)
#> ℹ [2026-10-11 22:47:59] Start Enrichment analysis
#> ℹ [2026-10-11 22:47:59] Species: "Mus_musculus"
#> ℹ [2026-10-11 22:47:59] Loading cached: GO_BP version: 3.23.0 nterm:14957 created: 2026-10-11 22:40:14
#> ℹ [2026-10-11 22:48:29] Preparing database: GO_BP
#> ℹ [2026-10-11 22:48:39] Preparing database: GO_CC
#> ℹ [2026-10-11 22:48:44] Convert ID types for the GO_BP database
#> ℹ [2026-10-11 22:48:44] Converted ID types using local annotation package org.Mm.eg.db
#> ℹ [2026-10-11 22:48:45] Convert ID types for the GO_CC database
#> ℹ [2026-10-11 22:48:46] Converted ID types using local annotation package org.Mm.eg.db
#> ℹ [2026-10-11 22:48:46] Permform enrichment...
#> ✔ [2026-10-11 22:48:51] Enrichment analysis done
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
group_use = "Ductal",
plot_type = "bar"
)
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
plot_type = "bar",
color_by = "Groups",
ncol = 2
)
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
plot_type = "bar",
id_use = list(
"Ductal" = c(
"GO:0002181", "GO:0045787",
"GO:0006260", "GO:0050679"
),
"Ngn3-low-EP" = c(
"GO:0050678", "GO:0051101",
"GO:0072091", "GO:0006631"
),
"Ngn3-high-EP" = c(
"GO:0035270", "GO:0030325",
"GO:0008637", "GO:0030856"
),
"Pre-endocrine" = c(
"GO:0090276", "GO:0031018",
"GO:0030073", "GO:1903532"
)
)
)
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
topTerm = 3,
plot_type = "comparison"
)
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
topTerm = 3,
plot_type = "comparison",
compare_only_sig = TRUE
)
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
group_use = c("Ductal", "Endocrine"),
plot_type = "comparison"
)
EnrichmentPlot(
pancreas_sub,
db = c("GO_BP", "GO_CC"),
group.by = "CellType",
group_use = c("Ductal", "Endocrine"),
plot_type = "bar",
split_by = "Groups"
)
EnrichmentPlot(
pancreas_sub,
db = c("GO_BP", "GO_CC"),
group.by = "CellType",
group_use = c("Ductal", "Endocrine"),
plot_type = "bar",
split_by = "Database",
color_by = "Groups"
)
EnrichmentPlot(
pancreas_sub,
db = c("GO_BP", "GO_CC"),
group.by = "CellType",
group_use = c("Ductal", "Endocrine"),
plot_type = "bar",
split_by = c("Database", "Groups")
)
EnrichmentPlot(
pancreas_sub,
db = c("GO_BP", "GO_CC"),
group.by = "CellType",
plot_type = "bar",
split_by = "Database",
color_by = "Groups",
palette = "Set1"
)
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
group_use = "Ductal",
plot_type = "dot",
palette = "GdRd"
)
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
group_use = "Ductal",
plot_type = "lollipop",
palette = "GdRd"
)
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
group_use = "Ductal",
plot_type = "wordcloud"
)
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
group_use = "Ductal",
plot_type = "wordcloud",
word_type = "feature"
)
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
group_use = "Ductal",
plot_type = "network"
)
#> Found more than one class "dist" in cache; using the first, from namespace 'BiocGenerics'
#> Also defined by ‘spam’
#> Found more than one class "dist" in cache; using the first, from namespace 'BiocGenerics'
#> Also defined by ‘spam’
#> ◌ [2026-10-11 22:49:11] Installing 1 R packages...
#>
#> → Package library at /tmp/RtmpZZsmTm/temp_libpath8d3438b020a.
#> → Will install 6 packages.
#> → All 6 packages (0 B) are cached.
#> + fontBitstreamVera 0.1.1
#> + fontLiberation 0.1.0
#> + fontquiver 0.2.1
#> + gdtools 0.5.1 + ✔ libcairo2-dev, ✔ libfontconfig1-dev, ✔ libfreetype6-dev
#> + ggiraph 0.9.6 + ✔ libpng-dev
#> + shadowtext 0.1.6
#> ✔ All system requirements are already installed.
#>
#> ℹ No downloads are needed, 6 pkgs are cached
#> ✔ Got shadowtext 0.1.6 (x86_64-pc-linux-gnu-ubuntu-24.04) (243.63 kB)
#> ℹ Installing system requirements
#> ℹ Executing `sudo sh -c apt-get -y update`
#> Get:1 file:/etc/apt/apt-mirrors.txt Mirrorlist [144 B]
#> Hit:6 https://packages.microsoft.com/ubuntu/24.04/prod noble InRelease
#> Hit:2 http://azure.archive.ubuntu.com/ubuntu noble InRelease
#> Hit:3 http://azure.archive.ubuntu.com/ubuntu noble-updates InRelease
#> Hit:4 http://azure.archive.ubuntu.com/ubuntu noble-backports InRelease
#> Hit:5 http://azure.archive.ubuntu.com/ubuntu noble-security InRelease
#> Reading package lists...
#> ℹ Executing `sudo sh -c apt-get -y install libcairo2-dev libfontconfig1-dev libfreetype6-dev libpng-dev cmake make libuv1-dev pandoc`
#> Reading package lists...
#> Building dependency tree...
#> Reading state information...
#> libcairo2-dev is already the newest version (1.18.0-3build1).
#> libfontconfig1-dev is already the newest version (2.15.0-1.1ubuntu2).
#> libfreetype-dev is already the newest version (2.13.2+dfsg-1ubuntu0.2).
#> libpng-dev is already the newest version (1.6.43-5ubuntu0.7).
#> cmake is already the newest version (3.28.3-1build7).
#> make is already the newest version (4.3-4.1build2).
#> libuv1-dev is already the newest version (1.48.0-1.1build1).
#> pandoc is already the newest version (3.1.3+ds-2).
#> 0 upgraded, 0 newly installed, 0 to remove and 19 not upgraded.
#> ✔ Installed fontBitstreamVera 0.1.1 (68ms)
#> ✔ Installed fontLiberation 0.1.0 (99ms)
#> ✔ Installed fontquiver 0.2.1 (128ms)
#> ✔ Installed gdtools 0.5.1 (178ms)
#> ✔ Installed ggiraph 0.9.6 (178ms)
#> ✔ Installed shadowtext 0.1.6 (51ms)
#> ✔ 1 pkg + 55 deps: kept 49, added 6, dld 1 (243.63 kB) [4.5s]
#> ✔ [2026-10-11 22:49:16] shadowtext installed successfully
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
group_use = "Ductal",
plot_type = "network",
id_use = c(
"GO:0050678",
"GO:0035270",
"GO:0090276",
"GO:0030073"
)
)
#> ✔ [2026-10-11 22:49:17] shadowtext installed successfully
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
group_use = "Ductal",
plot_type = "network",
network_layoutadjust = FALSE
)
#> ✔ [2026-10-11 22:49:18] shadowtext installed successfully
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
group_use = "Ductal",
plot_type = "network",
topTerm = 4,
network_blendmode = "average",
theme_use = "theme_blank",
theme_args = list(add_coord = FALSE)
) |> thisplot::panel_fix(height = 5)
#> ✔ [2026-10-11 22:49:19] shadowtext installed successfully
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
group_use = "Ductal",
plot_type = "enrichmap"
)
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
group_use = "Ductal",
plot_type = "enrichmap",
enrichmap_expand = c(2, 1)
)
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
group_use = "Ductal",
plot_type = "enrichmap",
enrichmap_show_keyword = TRUE,
character_width = 10
)
EnrichmentPlot(
pancreas_sub,
db = "GO_BP",
group.by = "CellType",
group_use = "Ductal",
plot_type = "enrichmap",
topTerm = 200,
enrichmap_mark = "hull",
enrichmap_label = "feature",
enrichmap_nlabel = 3,
character_width = 10,
theme_use = "theme_blank",
theme_args = list(add_coord = FALSE)
) |> thisplot::panel_fix(height = 4)
pancreas_sub <- RunEnrichment(
pancreas_sub,
db = c("MP", "DO"),
group.by = "CellType",
convert_species = TRUE,
species = "Mus_musculus"
)
#> ℹ [2026-10-11 22:49:23] Start Enrichment analysis
#> ℹ [2026-10-11 22:49:23] Species: "Mus_musculus"
#> ℹ [2026-10-11 22:49:23] Preparing MP database
#> ℹ [2026-10-11 22:49:39] Species: "Mus_musculus"
#> ℹ [2026-10-11 22:49:39] Preparing DO database
#> ℹ [2026-10-11 22:49:44] Permform enrichment...
#> ✔ [2026-10-11 22:49:45] Enrichment analysis done
EnrichmentPlot(
pancreas_sub,
db = c("MP", "DO"),
group.by = "CellType",
group_use = "Ductal",
ncol = 1
)