Skip to contents

[Experimental]

Creates a volcano plot with ggplot

Usage

volcano_plot(
  data,
  col.estimate = c("estimate", "est", "beta", "loghr"),
  col.p = c("p.value", "p", "pval"),
  col.label = "label",
  exponentiate = FALSE,
  logscale = exponentiate,
  p_threshold = 0.05,
  point_colours = c(pos = "red3", neg = "blue3", null = "grey50"),
  point_labels = NULL,
  xlims = NULL,
  ylims = NULL,
  xbreaks = NULL,
  ybreaks = NULL,
  xlabels = NULL,
  ylabels = NULL,
  xlab = "Estimate",
  ylab = "**-log{.sub 10}(p-value)**",
  title = NULL,
  base_size = 11,
  base_line_size = base_size/22,
  addarg = NULL,
  addaes = NULL,
  add = NULL,
  quiet = FALSE,
  printplot = !quiet,
  showcode = !quiet,
  envir = NULL
)

Arguments

data

The data frame containing estimates and p-values.

col.estimate

Name of column that provides point estimates.

col.p

Name of column that provides p-values.

col.label

Name of column that provides labels for points.

exponentiate

Exponentiate estimates before plotting and use log scale on the axis. (Default: FALSE)

logscale

Use log scale for the estimates axis. (Default: exponentiate)

p_threshold

P-value significance threshold. (Default: 0.05)

point_colours

Colours to use for points according to significance and sign of estimate (Default: c(pos = "red3", neg = "blue3", null = "grey50"))

point_labels

A data frame to add labels to points.

xlims

A numeric vector of length two. The limits of the x-axis.

ylims

A numeric vector of length two. The limits of the y-axis.

xbreaks

Breaks for the x axis. Passed to ggplot2::scale_x_continuous. (Default: NULL)

ybreaks

Breaks for the y axis. Passed to ggplot2::scale_y_continuous. (Default: NULL)

xlabels

Labels for x axis breaks. Passed to ggplot2::scale_x_continuous. (Default: NULL)

ylabels

Labels for y axis breaks. Passed to ggplot2::scale_y_continuous. (Default: NULL)

xlab

Label for x-axis. (Default: "Estimate")

ylab

Label for y-axis. (Default: "**-log{.sub 10}(p-value)**")

title

Plot title. (Default: NULL)

base_size

Base font size, given in pts. (Default: 11)

base_line_size

Base size for line elements. (Default: base_size/22)

addaes, addarg, add

Methods for customising the plot. See documentation for details.

quiet

Set to TRUE to not print the plot nor show generated code in the RStudio 'Viewer' pane. (Default: FALSE)

printplot

Print the plot. (Default: !quiet)

showcode

Show the ggplot2 code to generate the plot in RStudio 'Viewer' pane. (Default: !quiet)

envir

Environment in which to evaluate the plot code. May be useful when calling this function inside another function.

Value

A list:

plot

the plot

code

ggplot2 code to generate the plot

Details

The function returns the plot and ggplot2 code to create the plot. In RStudio, the ggplot2 code will be shown in the viewer.