Draws a volcano plot for a set of coefficients and p-values. Uses ggplot for plotting and ggrepel package for labels. By default, plot labeling assumes FDR-corrected p-values. Can plot both unadjusted and FDR-adjusted p-values with different colors.
volcanoPlot(
coefs,
p_vals,
target_labels,
title = NULL,
xlabel = expression("log"[2] * "(fold change)"),
ylabel = expression("-log"[10] * "(FDR-adjusted p-value)"),
xlimits = NULL,
ylimits = NULL,
sig_threshold = 0.05,
sig_label = "FDR = 5%",
label_all_targets = FALSE,
upper_log2FC_threshold = NULL,
lower_log2FC_threshold = NULL,
target_labels_off = FALSE,
target_label_colors = NULL,
target_point_colors = NULL,
target_label_size = 2,
target_label_segment_color = "grey",
max.overlaps = Inf,
force = 1,
force_pull = 1,
plot_title_font_size = 14,
axis_label_font_size = 12,
tick_label_font_size = 12,
plot_aspect_ratio = 1,
log_y = TRUE,
output_dir = NULL,
plot_name = NULL,
plot_width = 7,
plot_height = 7
)Vector of coefficients.
Vector of p-values OR a named list with 'unadj' and 'fdr' p-values. If a list, the y-axis will plot unadjusted p-values with light colors for unadjusted significant targets and darker colors for FDR significant targets.
Vector of target names.
Plot title.
X axis label.
Y axis label; defaults to expression('-log'[10]*'(FDR-adjusted p-value)').
Automatically overridden to show unadjusted p-value when in dual mode.
X axis limits
Y axis limits
P-value significance threshold OR a named list with 'unadj' and 'fdr' thresholds. Must match the structure of p_vals.
Label to mark significance threshold on plot; defaults to "FDR = 5%".
Automatically overridden to "Unadj = X%" when in dual mode (where X is the unadj threshold percentage).
Always a single string.
Logical TRUE or FALSE. Should all targets be labelled? Default is FALSE and will only label significant targets.
Coefficients/fold change upper threshold cutoff for
labeling insignificant targets. Insignificant targets above the upper threshold will be labelled.
Default is NULL
Coefficients/fold change lower threshold cutoff for
labeling insignificant targets. Insignificant targets below the lower threshold will be labelled.
Default is NULL.
Logical TRUE or FALSE. Should no targets be labelled?
Default is FALSE.
A vector of the same length as number of targets and same order as targets with colors for the target labels. Default is to color upregulated target labels red and downregulated target labels blue.
A vector of the same length as number of targets and same order as targets with colors for the points. Default is to make significant upregulated target points red, significant downregulated target points blue, and nonsignificant target points grey.
Font size of target labels.
Color of line segments for target labels. Can be a single value or a vector same length as number of targets.
Passed to ggrepel::geom_text_repel. Integer which determines how many targets
will have labels. "Inf" (default) labels all targets.
Passed to ggrepel::geom_text_repel. Force of repulsion between overlapping text labels. Defaults to 1.
Passed to ggrepel::geom_text_repel. Force of attraction between a text label and its corresponding data point. Defaults to 1.
Font size of plot title.
Font size of axis title.
Font size of axis tick marks.
Aspect ratio for plot. Default is 1 (square plot).
Logical TRUE (default) or FALSE. Should y-axis be
-log10 transformed? (TRUE recommended for plotting p-values.)
Directory path where plot should be saved; defaults to NULL
(plot not saved to file).
File name for saved plot including extension (.pdf, .png, .jpg, .svg);
defaults to NULL. If output_dir is specified but plot_name is NULL,
the plot will be saved as "volcano_plot_YYYYMMDD.pdf" with current date.
Numeric value for the width of the saved plot in inches; defaults to 7.
Numeric value for the height of the saved plot in inches; defaults to 7.
Outputs a ggplot object. If output_dir is specified, also saves the plot
in the specified format (PDF, PNG, JPG, or SVG based on file extension in plot_name).