Interactive Volcano Plots in R with Plotly

Introduction

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.

Quick Start

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

1

2

3

4

5

install.packages("manhattanly")

library(manhattanly)

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.

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

1

2

3

volcanoly(volcanorObject)

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:

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.