Generates a customizable volcano plot visualizing differential expression results, highlighting significant genes based on both fold change and statistical significance. The plot supports various customization options including color schemes, point sizes, and gene labeling.
plot_volcano(
devil.res,
lfc_cut = 1,
pval_cut = 0.05,
labels = TRUE,
colors = c("gray", "forestgreen", "steelblue", "indianred"),
color_alpha = 0.7,
point_size = 1,
center = TRUE,
title = "Volcano plot"
)
A tibble from test_de() containing columns:
name: Gene identifiers
adj_pval: Adjusted p-values
lfc: Log2 fold changes
Numeric. Absolute log2 fold change threshold for significance. Default: 1
Numeric. Adjusted p-value threshold for significance. Default: 0.05
Logical. Whether to label genes meeting both significance criteria. Default: TRUE
Character vector of length 4 specifying colors for:
Non-significant genes
Fold-change significant only
P-value significant only
Both significant Default: c("gray", "forestgreen", "steelblue", "indianred")
Numeric between 0 and 1. Transparency level for points. Default: 0.7
Numeric. Size of plotting points. Default: 1
Logical. Whether to center the x-axis at zero. Default: TRUE
Character. Plot title. Default: "Volcano plot"
A ggplot2 object containing the volcano plot.
The function creates a scatter plot with:
X-axis: Log2 fold change
Y-axis: -Log10 adjusted p-value Points are colored based on significance categories:
Non-significant: Neither p-value nor fold change threshold met
LFC significant: Only fold change threshold met
P-value significant: Only p-value threshold met
Both significant: Both thresholds met
The plot includes dashed lines indicating significance thresholds and optionally labels genes meeting both significance criteria.
Genes with adj_pval = 0 are assigned the smallest non-zero p-value in the dataset
NA values are removed with a warning
Gene labels are placed with overlap prevention
if (FALSE) { # \dontrun{
# Basic volcano plot
plot_volcano(de_results)
# Custom thresholds and colors
plot_volcano(de_results,
lfc_cut = 2,
pval_cut = 0.01,
colors = c("grey80", "blue", "green", "red"))
# Without gene labels
plot_volcano(de_results, labels = FALSE)
} # }