Skip to contents

A GPU-accelerated volcano plot for differential-expression results. Points are rendered with WebGL (via regl-scatterplot) so hundreds of thousands to millions of genes/features stay interactive, while axes, threshold guides and gene labels are drawn as crisp vector overlays.

Usage

volcano(
  data,
  fc_threshold = 1,
  p_threshold = 0.05,
  point_size = 3,
  opacity = 0.8,
  colors = NULL,
  x_label = "log2 fold change",
  y_label = "-log10 p-value",
  show_threshold_lines = TRUE,
  label_top_n = 10,
  bounded_view = TRUE,
  theme = NULL,
  width = NULL,
  height = NULL,
  element_id = NULL
)

Arguments

data

A data frame with numeric columns x (log2 fold change) and y (-log10 p-value). An optional label column supplies gene names for tooltips and top-hit labels. A y of Inf (p = 0) is drawn just above the highest finite value and the p-value threshold, and counts as significant. Rows with NA or NaN in x or y, or a y of -Inf, are not drawn, with a warning that counts them; Python gives the same warning.

fc_threshold

Absolute log2 fold-change cutoff for calling a hit.

p_threshold

P-value cutoff (applied on the -log10 scale).

point_size

Point radius in pixels.

opacity

Point opacity in [0, 1].

colors

Optional named list of hex colors for the three point classes: up, down and ns (not significant). NULL (the default) uses the component's built-in palette.

x_label, y_label

Axis titles.

show_threshold_lines

Draw the fold-change / p-value threshold guides. The y axis then always reaches the p-value guide.

label_top_n

Number of top up- and down-regulated genes to label. Inf labels every up- and down-regulated gene, as in lollipop(); 0 labels none.

bounded_view

Keep pan and zoom inside the data: zooming out stops at the view that shows all of it, a pan stops at its edges, and zooming in stops at 1/10,000 of its range. FALSE lets the view move freely. Either way a double-click, or the reset button in the top right corner of the plot, goes back to the view of all the data.

theme

Optional named list of theme overrides (colors, fonts, ...) merged over the component defaults in the browser. NULL uses the default theme. Its padding entry is the space in px between the edge of the widget and the plot: one number for every side, or numbers named top, right, bottom and left in a list or vector, a side left out keeping the default of 10. A colour given as a CSS custom property, such as background = "var(--bg)", takes the value the page gives it when the plot draws. After the page changes the property, what the plot drew on a canvas keeps the old colour until it draws again: resize the widget or render it again.

width, height

Widget dimensions (any valid CSS size).

element_id

Optional explicit DOM id.

Value

An htmlwidget object.

Examples

set.seed(1)
df <- data.frame(
  x = rnorm(2000),
  y = abs(rnorm(2000)) * 3,
  label = paste0("GENE", seq_len(2000))
)
volcano(df)