Skip to contents

Generate a volcano plot based on differential expression analysis results.

Usage

VolcanoPlot(
  srt,
  group.by = NULL,
  test.use = "wilcox",
  res = NULL,
  group_use = NULL,
  DE_threshold = "avg_log2FC > 0 & p_val_adj < 0.05",
  x_metric = NULL,
  y_metric = NULL,
  palette = "RdBu",
  palcolor = NULL,
  pt.size = 1,
  pt.alpha = 1,
  cols.background = "grey80",
  cols.highlight = "black",
  sizes.highlight = 1,
  alpha.highlight = 1,
  stroke.highlight = 0.5,
  nlabel = 5,
  features_label = NULL,
  only.pos = FALSE,
  label.by = c("p_val_adj", "p_val", "diff_pct", "avg_log2FC"),
  label.fg = "black",
  label.bg = "white",
  label.bg.r = 0.1,
  label.size = 4,
  aspect.ratio = NULL,
  xlab = NULL,
  ylab = NULL,
  theme_use = "theme_scop",
  theme_args = list(),
  combine = TRUE,
  nrow = NULL,
  ncol = NULL,
  byrow = TRUE,
  threshold_method = c("rectangular", "hyperbolic"),
  hyperbola_c = 6,
  annotate_enrichment = FALSE,
  enrich_from = c("Enrichment", "GSEA", "GSVA"),
  enrich_db = NULL,
  enrich_terms = NULL,
  enrich_top_terms = 3,
  enrich_padj_cutoff = 0.05,
  enrich_gsva_score_cutoff = NULL,
  gsva_method = NULL,
  enrich_nlabel = 15,
  verbose = TRUE
)

Arguments

srt

A Seurat object or SummarizedExperiment object containing the results of differential expression analysis.

group.by

Metadata column(s) used to color cells.

test.use

Type of statistical test to use.

res

A data.frame or data.table with differential expression results. When res is provided, srt will be ignored. The data.frame must contain columns: gene, group1 (factor or character), avg_log2FC, p_val_adj, and optionally pct.1 and pct.2 for calculating diff_pct.

group_use

Groups to plot. Default is NULL (all groups).

DE_threshold

Threshold for differential expression (used to highlight significant genes in all plot types). Default is "p_val < 0.05" for sample-level methods ("edgeR" and "limma"). For cell-level volcano plots, it is "abs(avg_log2FC) > 0 & p_val_adj < 0.05" when only.pos = FALSE, and "avg_log2FC > 0 & p_val_adj < 0.05" otherwise.

x_metric

Metric to use for the x-axis (only for volcano plot). Default is NULL, which uses "avg_log2FC" for sample-level methods ("edgeR" and "limma") and "diff_pct" otherwise.

y_metric

Metric to use for the y-axis. Options: "p_val" or "p_val_adj". Default is "p_val" for sample-level methods ("edgeR" and "limma") and "p_val_adj" otherwise.

palette

Color palette name. Available palettes can be found in thisplot::show_palettes.

palcolor

Custom colors used to create a color palette.

pt.size

The size of the points.

pt.alpha

Point size and transparency. pt.size = NULL scales with sqrt(n) (minimum 0.3). Rasterized points keep at least a two-pixel radius at raster.dpi = c(512, 512) and scale with raster.dpi.

cols.background

Color for non-DE background points in volcano plots.

cols.highlight

Color for highlighted points.

sizes.highlight

The size of the highlighted points.

alpha.highlight

The transparency of the highlighted points.

stroke.highlight

The stroke width for the highlighted points.

nlabel

An integer value specifying the number of labeled points per group.

features_label

Feature labels to plot.

only.pos

Whether to show only positive log2 fold-change results in differential expression visualizations.

label.by

Metric used to select automatic labels when features_label = NULL. Options are "p_val_adj", "p_val", "diff_pct", and "avg_log2FC". Smaller p-values are ranked first; diff_pct and avg_log2FC use the strongest positive and negative effects within each group.

label.fg

Color for the labels' foreground.

label.bg

Color for the labels' background.

label.bg.r

The radius of the rounding of the labels' background.

label.size

The size of the labels.

aspect.ratio

Aspect ratio of the panel.

xlab

X-axis label.

ylab

Y-axis label.

theme_use, theme_args

Theme name or function, plus extra theme arguments.

combine, nrow, ncol, byrow

Combine plots with patchwork. combine = FALSE returns a list of ggplots.

threshold_method

Volcano significance threshold method. Options are "rectangular" (legacy DE_threshold) or "hyperbolic" (|log2FC * -log10(padj)| > c).

hyperbola_c

Numeric cutoff c for hyperbolic volcano threshold.

annotate_enrichment

Whether to annotate enrichment-hit genes on volcano plots. Enrichment results are read from existing results in srt@tools only.

enrich_from

Character vector specifying enrichment result source(s) to annotate. Options are "Enrichment", "GSEA", "GSVA".

enrich_db

Optional database filter for enrichment annotation, e.g. "GO_BP" or "KEGG".

enrich_terms

Optional whitelist of enrichment term IDs or names for annotation.

enrich_top_terms

Number of top enriched terms selected per source/group/database.

enrich_padj_cutoff

Adjusted p-value cutoff for "Enrichment" and "GSEA" annotation.

enrich_gsva_score_cutoff

Optional absolute GSVA score cutoff for "GSVA" annotation.

gsva_method

Optional GSVA method filter (e.g. "gsva" or "ssgsea") when multiple GSVA tool slots exist.

enrich_nlabel

Maximum number of enrichment-derived labels added per group. Labels from features_label are always retained.

verbose

Whether to print the message. Default is TRUE.

Examples

data(pancreas_sub)
pancreas_sub <- RunStandardWorkflow(pancreas_sub)
#>  [2026-08-30 05:57:13] Start standard processing workflow...
#>  [2026-08-30 05:57:13] Checking a list of <Seurat>...
#> ! [2026-08-30 05:57:14] Data 1/1 of the `srt_list` is "unknown"
#> Warning: Data 1/1 of the `srt_list` is "unknown"
#>  [2026-08-30 05:57:14] Perform `NormalizeData()` with `normalization.method = 'LogNormalize'` on 1/1 of `srt_list`...
#>  [2026-08-30 05:57:14] Perform `FindVariableFeatures()` on 1/1 of `srt_list`...
#>  [2026-08-30 05:57:14] Use the separate HVF from `srt_list`
#>  [2026-08-30 05:57:14] Number of available HVF: 2000
#>  [2026-08-30 05:57:14] Finished check
#>  [2026-08-30 05:57:14] Perform `ScaleData()`
#>  [2026-08-30 05:57:14] Perform pca linear dimension reduction
#>  [2026-08-30 05:57:15] Use stored estimated dimensions 1:23 for Standardpca
#>  [2026-08-30 05:57:15] Perform `Seurat::FindClusters()` with `cluster_algorithm = 'louvain'` and `cluster_resolution = 0.6`
#>  [2026-08-30 05:57:15] Reorder clusters...
#>  [2026-08-30 05:57:15] Skip `log1p()` because `layer = data` is not "counts"
#>  [2026-08-30 05:57:15] Perform umap nonlinear dimension reduction
#>  [2026-08-30 05:57:24] Standard processing workflow completed
pancreas_sub <- RunDEtest(
  pancreas_sub,
  group.by = "CellType"
)
#>  [2026-08-30 05:57:25] Data type is log-normalized
#>  [2026-08-30 05:57:25] Start differential expression test
#>  [2026-08-30 05:57:25] Find all markers(wilcox) among [1] 5 groups...
#>  [2026-08-30 05:57:25] Differential expression test completed
VolcanoPlot(
  pancreas_sub,
  group.by = "CellType",
  ncol = 2
)


VolcanoPlot(
  pancreas_sub,
  group.by = "CellType",
  group_use = c("Ductal", "Endocrine"),
  ncol = 2
)


VolcanoPlot(
  pancreas_sub,
  group.by = "CellType",
  DE_threshold = "abs(diff_pct) > 0.3 & p_val_adj < 0.05",
  ncol = 2
)


VolcanoPlot(
  pancreas_sub,
  group.by = "CellType",
  x_metric = "avg_log2FC",
  y_metric = "p_val",
  DE_threshold = "abs(avg_log2FC) > log2(1.5) & p_val < 0.05",
  ncol = 2
)


VolcanoPlot(
  pancreas_sub,
  group.by = "CellType",
  threshold_method = "hyperbolic",
  hyperbola_c = 6,
  ncol = 2
)
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_line()`).
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_line()`).
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_line()`).
#> Warning: Removed 11 rows containing missing values or values outside the scale range
#> (`geom_line()`).
#> Warning: Removed 5 rows containing missing values or values outside the scale range
#> (`geom_line()`).


pancreas_sub <- RunEnrichment(
  pancreas_sub,
  group.by = "CellType",
  db = "GO_BP",
  species = "Mus_musculus"
)
#>  [2026-08-30 05:57:32] Start Enrichment analysis
#>  [2026-08-30 05:57:32] Species: "Mus_musculus"
#>  [2026-08-30 05:57:32] Loading cached: GO_BP version: 3.23.0 nterm:14957 created: 2026-08-30 04:25:22
#>  [2026-08-30 05:57:33] Permform enrichment...
#>  [2026-08-30 05:57:34] Using 1 core
#>  [2026-08-30 05:57:34] Running for 1 [1/5] ■■          20% | ETA:  6s
#>  [2026-08-30 05:57:34] Running for 2 [2/5] ■■■■        40% | ETA:  4s
#>  [2026-08-30 05:57:34] Running for 4 [4/5] ■■■■■■■■    80% | ETA:  1s
#>  [2026-08-30 05:57:34] Completed 5 tasks in 7.2s
#> 
#>  [2026-08-30 05:57:34] Building results
#>  [2026-08-30 05:57:41] Enrichment analysis done
VolcanoPlot(
  pancreas_sub,
  group.by = "CellType",
  threshold_method = "hyperbolic",
  hyperbola_c = 6,
  annotate_enrichment = TRUE,
  enrich_from = "Enrichment",
  enrich_db = "GO_BP",
  ncol = 2
)
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_line()`).
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_line()`).
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_line()`).
#> Warning: Removed 11 rows containing missing values or values outside the scale range
#> (`geom_line()`).
#> Warning: Removed 5 rows containing missing values or values outside the scale range
#> (`geom_line()`).