Interactive Volcano Plots in R with Plotly

[This article was first published on R – Modern Data, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.


In a recent blog post, I introduced the new R package, manhattanly, which creates interactive manhattan and Q-Q plots using the plotly.js engine. In the latest CRAN release, you can also create volcano plots.

In this post, I describe how to create interactive volcano plots using the manhattanly package. Volcano plots are the negative log10 p-values plotted against their effect size, odds ratio or log fold-change. They are used to identify clinically meaningful markers in genomic experiments, i.e., markers that are statistically significant and have an effect size greater than some threshold.

Visit the package website for full details and example usage.

Quick Start

The following three lines of code will produce the Volcano plot below

volcanoly(HapMap, snp = "SNP", gene = "GENE")

Notice that we have added two annotations (the SNP and nearest GENE), that are revealed when hovering the mouse over a point. This feature of interactive volcano plots adds a great deal of information to the plot without cluttering it with text.

The Data

Inspired by the heatmaply package by Tal Galili, we split the tasks into data pre-processing and plot rendering. Therefore, we can use the manhattanly::volcanor function to get the data used to produce a volcano plot. This allows flexibility in the rendering of the plot, since any graphics package, such as plot in base R can make used to create the plot.

The plot data is derived using the manhattanly::volcanor function:

volcanorObject <- volcanor(HapMap, snp = "SNP")

List of 8 $ data :'data.frame': 14412 obs. of 4 variables: ..$ EFFECTSIZE: num [1:14412] -0.0946 -0.0947 -0.0741 0.0146 0.1234 ... ..$ P : num [1:14412] 0.335 0.246 0.823 0.493 0.605 ... ..$ SNP : chr [1:14412] "rs9697358" "rs34945898" "rs12034613" "rs4648633" ... ..$ LOG10P : num [1:14412] 0.4745 0.6093 0.0844 0.307 0.218 ... $ pName : chr "P" $ effectName : chr "EFFECTSIZE" $ xlabel : chr "EFFECTSIZE" $ snpName : chr "SNP" $ geneName : logi NA $ annotation1Name: logi NA $ annotation2Name: logi NA - attr(*, "class")= chr "volcanor"


EFFECTSIZE P SNP LOG10P 1 -0.0946 0.3353438 rs9697358 0.47450973 2 -0.0947 0.2458571 rs34945898 0.60931719 3 -0.0741 0.8232859 rs12034613 0.08444933 4 0.0146 0.4932038 rs4648633 0.30697357 5 0.1234 0.6053916 rs4430271 0.21796358 6 0.1979 0.1944431 rs6685625 0.71120743

This volcanorObject which is of class volcanor can also be passed to the manhattanly::volcanoly function to produce the inteactive volcano plot above:


Automatic Highlighting

By default, the points greater than the default genomewideline and effect_size_line arguments are highlighted. The defaults are genomewideline = -log10(1e-5) and effect_size_line = c(-1,1). The effect_size_line argument must be a numeric vector of length 2 and the first argument must be smaller than the second. To highlight more points, you simply need to change those thresholds. You can set either of the genomewideline and effect_size_line arguments to FALSE to remove that threshold:

volcanoly(HapMap, snp = "SNP",  genomewideline = -log10(1e-2), effect_size_line = FALSE)

Related Work

The manhattanly package is based on the qqman package by Stephen Turner. It produces similar manhattan and Q-Q plots as the qqman::manhattan and qqman::qq functions; the main difference here is being able to interact with the plot, including extra annotation information, seamless integration with HTML and creating interactive volcano plots with automated highlighting of interesting points.

To leave a comment for the author, please follow the link and comment on their blog: R – Modern Data. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)