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
)

Arguments

coefs

Vector of coefficients.

p_vals

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.

target_labels

Vector of target names.

title

Plot title.

xlabel

X axis label.

ylabel

Y axis label; defaults to expression('-log'[10]*'(FDR-adjusted p-value)'). Automatically overridden to show unadjusted p-value when in dual mode.

xlimits

X axis limits

ylimits

Y axis limits

sig_threshold

P-value significance threshold OR a named list with 'unadj' and 'fdr' thresholds. Must match the structure of p_vals.

sig_label

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.

label_all_targets

Logical TRUE or FALSE. Should all targets be labelled? Default is FALSE and will only label significant targets.

upper_log2FC_threshold

Coefficients/fold change upper threshold cutoff for labeling insignificant targets. Insignificant targets above the upper threshold will be labelled. Default is NULL

lower_log2FC_threshold

Coefficients/fold change lower threshold cutoff for labeling insignificant targets. Insignificant targets below the lower threshold will be labelled. Default is NULL.

target_labels_off

Logical TRUE or FALSE. Should no targets be labelled? Default is FALSE.

target_label_colors

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.

target_point_colors

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.

target_label_size

Font size of target labels.

target_label_segment_color

Color of line segments for target labels. Can be a single value or a vector same length as number of targets.

max.overlaps

Passed to ggrepel::geom_text_repel. Integer which determines how many targets will have labels. "Inf" (default) labels all targets.

force

Passed to ggrepel::geom_text_repel. Force of repulsion between overlapping text labels. Defaults to 1.

force_pull

Passed to ggrepel::geom_text_repel. Force of attraction between a text label and its corresponding data point. Defaults to 1.

plot_title_font_size

Font size of plot title.

axis_label_font_size

Font size of axis title.

tick_label_font_size

Font size of axis tick marks.

plot_aspect_ratio

Aspect ratio for plot. Default is 1 (square plot).

log_y

Logical TRUE (default) or FALSE. Should y-axis be -log10 transformed? (TRUE recommended for plotting p-values.)

output_dir

Directory path where plot should be saved; defaults to NULL (plot not saved to file).

plot_name

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.

plot_width

Numeric value for the width of the saved plot in inches; defaults to 7.

plot_height

Numeric value for the height of the saved plot in inches; defaults to 7.

Value

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).