Create a “volcano” plot to visualize the results of a differential count analysis using a topic model. Here, the volcano plot is a scatterplot in which the posterior mean log-fold change (LFC), estimated by running the methods implemented in de_analysis, is plotted against the estimated z-score. Variations on this volcano plot may also be created, for example by showing f0 (the null-model estimates) instead of the z-scores. Use volcano_plotly to create an interactive volcano plot.

volcano_plot(
  de,
  k,
  labels,
  y = c("z", "f0"),
  do.label = volcano_plot_do_label_default,
  ymin = 1e-06,
  ymax = Inf,
  max.overlaps = Inf,
  plot.title = paste("topic", k),
  ggplot_call = volcano_plot_ggplot_call
)

# S3 method for topic_model_de_analysis
plot(x, ...)

volcano_plotly(
  de,
  k,
  file,
  labels,
  y = c("z", "f0"),
  ymin = 1e-06,
  ymax = Inf,
  width = 500,
  height = 500,
  plot.title = paste("topic", k),
  plot_ly_call = volcano_plot_ly_call
)

volcano_plot_do_label_default(lfc, y)

volcano_plot_ggplot_call(dat, y, plot.title, max.overlaps = Inf, font.size = 9)

volcano_plot_ly_call(dat, y, plot.title, width, height)

Arguments

de

An object of class “topic_model_de_analysis”, usually an output from de_analysis. It is better to run de_analysis with shrink.method = "ash" so that the points in the volcano plot can be coloured by their local false sign rate (lfsr).

k

The topic, selected by number or name.

labels

Character vector specifying how the points in the volcano plot are labeled. This should be a character vector with one entry per LFC estimate (row of de$postmean). When not specified, the row names of de$postmean are used. When available. labels are added to the plot using geom_text_repel.

y

A vector of the same length as lfc.

do.label

The function used to deetermine which LFC estimates to label. Replace volcano_plot_do_label_default with your own function to customize the labeling of points in the volcano plot.

ymin

Y-axis values less than ymin are shown as ymin.

ymax

Y-axis values greater than ymax are shown as ymax. When y = "z", setting ymax to a finite value can improve the volcano plot when some z-scores are much larger (in magnitude) than others.

max.overlaps

Argument passed to geom_text_repel.

plot.title

The title of the plot.

ggplot_call

The function used to create the plot. Replace volcano_plot_ggplot_call with your own function to customize the appearance of the plot.

x

An object of class “topic_model_de_analysis”, usually an output from de_analysis.

...

Additional arguments passed to volcano_plot.

file

Save the interactive volcano plot to this HTML file using saveWidget.

width

Width of the plot in pixels. Passed as argument “width” to plot_ly.

height

Height of the plot in pixels. Passed as argument “height” to plot_ly.

plot_ly_call

The function used to create the plot. Replace volcano_plot_ly_call with your own function to customize the appearance of the interactive plot.

lfc

A vector of log-fold change estimates.

dat

A data frame passed as input to ggplot, containing, at a minimum, columns “f0”, “postmean”, “y”, “lfsr” and “label”.

font.size

Font size used in plot.

Value

A ggplot object or a plotly object.

Details

Interactive volcano plots can be created using the ‘plotly’ package. The “hover text” shows the label and detailed LFC statistics.

See also

Examples

# See help(de_analysis) for examples.