1 Introduction

Volcano plots represent a useful way to visualise the results of differential expression analyses. Here, we present a highly-configurable function that produces publication-ready volcano plots. EnhancedVolcano (Blighe, Rana, and Lewis 2018) will attempt to fit as many labels in the plot window as possible, thus avoiding ‘clogging’ up the plot with labels that could not otherwise have been read. Other functionality allows the user to identify up to 5 different types of attributes in the same plot space via colour, shape, size, encircling, and shade parameter configurations.

2 Installation

2.2 2. Load the package into R session

3 Quick start

For this example, we will follow the tutorial (from Section 3.1) of RNA-seq workflow: gene-level exploratory analysis and differential expression. Specifically, we will load the ‘airway’ data, where different airway smooth muscle cells were treated with dexamethasone.

Annotate the Ensembl gene IDs to gene symbols:

Conduct differential expression using DESeq2 in order to create 2 sets of results:

3.1 Plot the most basic volcano plot

For the most basic volcano plot, only a single data-frame, data-matrix, or tibble of test results is required, containing point labels, log2FC, and adjusted or unadjusted P values. The default cut-off for log2FC is >|2|; the default cut-off for P value is 10e-6.

Plot the most basic volcano plot.

Plot the most basic volcano plot.

4 Advanced features

Virtually all aspects of an EnhancedVolcano plot can be configured for the purposes of accommodating all types of statistical distributions and labelling preferences. By default, EnhancedVolcano will only attempt to label genes that pass the thresholds that you set for statistical significance, i.e., ‘pCutoff’ and ‘FCcutoff’. In addition, it will only label as many of these that can reasonably fit in the plot space. The user can optionally supply a vector of labels (as ‘selectLab’) that s/he wishes to label in the plot.

4.1 Modify cut-offs for log2FC and P value; specify title; adjust point and label size

The default P value cut-off of 10e-6 may be too relaxed for most studies, which may therefore necessitate increasing this threshold by a few orders of magnitude. Equally, the log2FC cut-offs may be too stringent, given that moderated ‘shrunk’ estimates of log2FC differences in differential expression analysis can now be calculated.

In this example, we also modify the point and label size, which can help to improve clarity where many variables went into the differential expression analysis.

Modify cut-offs for log2FC and P value; specify title; adjust point and label size.

Modify cut-offs for log2FC and P value; specify title; adjust point and label size.

4.2 Adjust colour and alpha for point shading

The default colour scheme may not be to everyone’s taste. Here we make it such that only the variables passing both the log2FC and P value thresholds are coloured red, with everything else black. We also adjust the value for ‘alpha’, which controls the transparency of the plotted points: 1 = 100% opaque; 0 = 100% transparent.

Adjust colour and alpha for point shading.

Adjust colour and alpha for point shading.

4.3 Adjust shape of plotted points

It can help, visually, to also plot different points as different shapes. The default shape is a circle. The user can specify their own shape encoding via the ‘shape’ parameter, which accepts either a single or four possible values: if four values, these then map to the standard designation that is also assigned by the colours; if a single value, all points are shaped with this value.

For more information on shape encoding search online at ggplot2 Quick Reference: shape

Adjust shape of plotted points.

Adjust shape of plotted points.

4.4 Adjust p-value cut-off

The lines that are drawn to indicate cut-off points are also modifiable. The parameter ‘cutoffLineType’ accepts the following values: “blank”, “solid”, “dashed”, “dotted”, “dotdash”, “longdash”, and “twodash”. The colour and thickness of these can also be modified with ‘cutoffLineCol’ and ‘cutoffLineWidth’, respectively. To disable the lines, set either cutoffLineType=“blank” or cutoffLineWidth=0.

Also, by using pCutoffCol=‘padj’, we instruct EnhancedVolcano to generate a traditonal volcano using nominal / un-adjusted p-values (or whatever is passed as ‘y’), but using adjusted p-values as the cut-off.

Extra lines can also be added via ‘hline’ and ‘vline’ to display other custom cut-offs. To make these more visible, we will also remove the default gridlines (gridlines.major and gridlines.minor).

Adjust cut-off and add extra threshold lines.

Adjust cut-off and add extra threshold lines.

4.5 Adjust legend position, size, and text

The position of the legend can also be changed to “left” or “right” (and stacked vertically), or ‘top’ or “bottom” (stacked horizontally). The legend text, label size, and icon size can also be modified.

Note: to make the legend completely invisible, specify:

4.6 Fit more labels by adding connectors

In order to maximise free space in the plot window, one can fit more labels by adding connectors from labels to points, where appropriate. The width and colour of these connectors can also be modified with ‘widthConnectors’ and ‘colConnectors’, respectively. Further configuration is achievable via ‘typeConnectors’ (“open”, “closed”), ‘endsConnectors’ (“last”, “first”, “both”), and lengthConnectors (default = unit(0.01, ‘npc’)).

The result may not always be desirable as it can make the plot look overcrowded.

Fit more labels by adding connectors.

Fit more labels by adding connectors.

4.7 Only label key variables

In many situations, people may only wish to label their key variables / variables of interest. One can therefore supply a vector of these variables via the ‘selectLab’ parameter, the contents of which have to also be present in the vector passed to ‘lab’. In addition, only those variables that pass both the cutoff for log2FC and P value will be labelled.

4.9 Italicise labels and flip volcano on it’s side

To make the labels italic, we can create a new vector in which we encode the labels as follows: italic(‘[LABEL]’). By then setting parseLabels = TRUE, these will be parsed by the internal ggplot2 or ggrepel engine and presented as italicised text. Advanced users can encode any expression as the label, which will then also be parsed.

To flip the volcano on its side, we just use EnhancedVolcano(…) + coord_flip().

Italicise labels and flip volcano on it's side.

Italicise labels and flip volcano on it’s side.

4.10 Over-ride colouring scheme with custom key-value pairs

In certain situations, one may wish to over-ride the default colour scheme with their own colour-scheme, such as colouring variables by pathway, cell-type or group. This can be achieved by supplying a named vector as ‘colCustom’.

In this example, we just wish to colour all variables with log2FC > 2.5 as ‘high’ and those with log2FC < -2.5 as ‘low’.

Over-ride colouring scheme with custom key-value pairs.

Over-ride colouring scheme with custom key-value pairs.

4.11 Over-ride colour and/or shape scheme with custom key-value pairs

In this example, we first over-ride the existing shape scheme and then both the colour and shape scheme at the same time.

  p1 <- EnhancedVolcano(res,
    lab = rownames(res),
    x = 'log2FoldChange',
    y = 'pvalue',
    selectLab = rownames(res)[which(names(keyvals) %in% c('high', 'low'))],
    xlab = bquote(~Log[2]~ 'fold change'),
    title = 'Custom shape over-ride',
    pCutoff = 10e-14,
    FCcutoff = 1.0,
    pointSize = 4.5,
    labSize = 4.5,
    shapeCustom = keyvals.shape,
    colCustom = NULL,
    colAlpha = 1,
    legendLabSize = 15,
    legendPosition = 'left',
    legendIconSize = 5.0,
    drawConnectors = TRUE,
    widthConnectors = 0.5,
    colConnectors = 'grey50',
    gridlines.major = TRUE,
    gridlines.minor = FALSE,
    border = 'partial',
    borderWidth = 1.5,
    borderColour = 'black')

  # create custom key-value pairs for 'high', 'low', 'mid' expression by fold-change
  # this can be achieved with nested ifelse statements
  keyvals.colour <- ifelse(
    res$log2FoldChange < -2.5, 'royalblue',
      ifelse(res$log2FoldChange > 2.5, 'gold',
        'black'))
  keyvals.colour[is.na(keyvals.colour)] <- 'black'
  names(keyvals.colour)[keyvals.colour == 'gold'] <- 'high'
  names(keyvals.colour)[keyvals.colour == 'black'] <- 'mid'
  names(keyvals.colour)[keyvals.colour == 'royalblue'] <- 'low'

  p2 <- EnhancedVolcano(res,
    lab = rownames(res),
    x = 'log2FoldChange',
    y = 'pvalue',
    selectLab = rownames(res)[which(names(keyvals) %in% c('High', 'Low'))],
    xlab = bquote(~Log[2]~ 'fold change'),
    title = 'Custom shape & colour over-ride',
    pCutoff = 10e-14,
    FCcutoff = 1.0,
    pointSize = 5.5,
    labSize = 0.0,
    shapeCustom = keyvals.shape,
    colCustom = keyvals.colour,
    colAlpha = 1,
    legendPosition = 'right',
    legendLabSize = 15,
    legendIconSize = 5.0,
    drawConnectors = TRUE,
    widthConnectors = 0.5,
    colConnectors = 'grey50',
    gridlines.major = TRUE,
    gridlines.minor = FALSE,
    border = 'full',
    borderWidth = 1.0,
    borderColour = 'black')

  library(gridExtra)
  library(grid)
  grid.arrange(p1, p2,
    ncol=2,
    top = textGrob('EnhancedVolcano',
      just = c('center'),
      gp = gpar(fontsize = 32)))
Over-ride colour and/or shape scheme with custom key-value pairs.

Over-ride colour and/or shape scheme with custom key-value pairs.

4.13 Highlighting key variables via custom point sizes

One can also supply a vector of sizes to pointSize for the purpose of having a different size for each poin. For example, if we want to change the size of just those variables with log2FC>2:

Highlighting key variabvles via custom point sizes.

Highlighting key variabvles via custom point sizes.

4.15 Custom axis tick marks

Custom axis ticks can be added in a ‘plug and play’ fashion via ggplot2 functionality, as follows:

Custom axis tick marks

Custom axis tick marks

More information on this can be found here: http://www.sthda.com/english/wiki/ggplot2-axis-ticks-a-guide-to-customize-tick-marks-and-labels

5 Acknowledgments

The development of EnhancedVolcano has benefited from contributions and suggestions from:

6 Session info

## R version 4.1.0 (2021-05-18)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.2 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.13-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.13-bioc/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_GB              LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
##  [1] grid      parallel  stats4    stats     graphics  grDevices utils    
##  [8] datasets  methods   base     
## 
## other attached packages:
##  [1] pasilla_1.19.1              gridExtra_2.3              
##  [3] DESeq2_1.32.0               org.Hs.eg.db_3.13.0        
##  [5] AnnotationDbi_1.54.0        magrittr_2.0.1             
##  [7] airway_1.11.1               SummarizedExperiment_1.22.0
##  [9] Biobase_2.52.0              GenomicRanges_1.44.0       
## [11] GenomeInfoDb_1.28.0         IRanges_2.26.0             
## [13] S4Vectors_0.30.0            BiocGenerics_0.38.0        
## [15] MatrixGenerics_1.4.0        matrixStats_0.58.0         
## [17] EnhancedVolcano_1.10.0      ggrepel_0.9.1              
## [19] ggplot2_3.3.3               knitr_1.33                 
## 
## loaded via a namespace (and not attached):
##  [1] bitops_1.0-7           bit64_4.0.5            ash_1.0-15            
##  [4] RColorBrewer_1.1-2     httr_1.4.2             tools_4.1.0           
##  [7] bslib_0.2.5.1          utf8_1.2.1             R6_2.5.0              
## [10] KernSmooth_2.23-20     vipor_0.4.5            DBI_1.1.1             
## [13] colorspace_2.0-1       withr_2.4.2            tidyselect_1.1.1      
## [16] ggrastr_0.2.3          ggalt_0.4.0            bit_4.0.4             
## [19] compiler_4.1.0         extrafontdb_1.0        isoband_0.2.4         
## [22] DelayedArray_0.18.0    labeling_0.4.2         sass_0.4.0            
## [25] scales_1.1.1           proj4_1.0-10.1         genefilter_1.74.0     
## [28] stringr_1.4.0          digest_0.6.27          rmarkdown_2.8         
## [31] XVector_0.32.0         pkgconfig_2.0.3        htmltools_0.5.1.1     
## [34] extrafont_0.17         highr_0.9              fastmap_1.1.0         
## [37] maps_3.3.0             rlang_0.4.11           RSQLite_2.2.7         
## [40] farver_2.1.0           jquerylib_0.1.4        generics_0.1.0        
## [43] jsonlite_1.7.2         BiocParallel_1.26.0    dplyr_1.0.6           
## [46] RCurl_1.98-1.3         GenomeInfoDbData_1.2.6 Matrix_1.3-3          
## [49] Rcpp_1.0.6             ggbeeswarm_0.6.0       munsell_0.5.0         
## [52] fansi_0.4.2            lifecycle_1.0.0        stringi_1.6.2         
## [55] yaml_2.2.1             MASS_7.3-54            zlibbioc_1.38.0       
## [58] blob_1.2.1             crayon_1.4.1           lattice_0.20-44       
## [61] splines_4.1.0          Biostrings_2.60.0      annotate_1.70.0       
## [64] KEGGREST_1.32.0        locfit_1.5-9.4         pillar_1.6.1          
## [67] geneplotter_1.70.0     XML_3.99-0.6           glue_1.4.2            
## [70] evaluate_0.14          vctrs_0.3.8            png_0.1-7             
## [73] Rttf2pt1_1.3.8         gtable_0.3.0           purrr_0.3.4           
## [76] assertthat_0.2.1       cachem_1.0.5           xfun_0.23             
## [79] xtable_1.8-4           survival_3.2-11        tibble_3.1.2          
## [82] beeswarm_0.3.1         memoise_2.0.0          ellipsis_0.3.2

7 References

Blighe, Rana, and Lewis (2018)

8 Session info

## R version 4.1.0 (2021-05-18)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.2 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.13-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.13-bioc/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_GB              LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
##  [1] grid      parallel  stats4    stats     graphics  grDevices utils    
##  [8] datasets  methods   base     
## 
## other attached packages:
##  [1] pasilla_1.19.1              gridExtra_2.3              
##  [3] DESeq2_1.32.0               org.Hs.eg.db_3.13.0        
##  [5] AnnotationDbi_1.54.0        magrittr_2.0.1             
##  [7] airway_1.11.1               SummarizedExperiment_1.22.0
##  [9] Biobase_2.52.0              GenomicRanges_1.44.0       
## [11] GenomeInfoDb_1.28.0         IRanges_2.26.0             
## [13] S4Vectors_0.30.0            BiocGenerics_0.38.0        
## [15] MatrixGenerics_1.4.0        matrixStats_0.58.0         
## [17] EnhancedVolcano_1.10.0      ggrepel_0.9.1              
## [19] ggplot2_3.3.3               knitr_1.33                 
## 
## loaded via a namespace (and not attached):
##  [1] bitops_1.0-7           bit64_4.0.5            ash_1.0-15            
##  [4] RColorBrewer_1.1-2     httr_1.4.2             tools_4.1.0           
##  [7] bslib_0.2.5.1          utf8_1.2.1             R6_2.5.0              
## [10] KernSmooth_2.23-20     vipor_0.4.5            DBI_1.1.1             
## [13] colorspace_2.0-1       withr_2.4.2            tidyselect_1.1.1      
## [16] ggrastr_0.2.3          ggalt_0.4.0            bit_4.0.4             
## [19] compiler_4.1.0         extrafontdb_1.0        isoband_0.2.4         
## [22] DelayedArray_0.18.0    labeling_0.4.2         sass_0.4.0            
## [25] scales_1.1.1           proj4_1.0-10.1         genefilter_1.74.0     
## [28] stringr_1.4.0          digest_0.6.27          rmarkdown_2.8         
## [31] XVector_0.32.0         pkgconfig_2.0.3        htmltools_0.5.1.1     
## [34] extrafont_0.17         highr_0.9              fastmap_1.1.0         
## [37] maps_3.3.0             rlang_0.4.11           RSQLite_2.2.7         
## [40] farver_2.1.0           jquerylib_0.1.4        generics_0.1.0        
## [43] jsonlite_1.7.2         BiocParallel_1.26.0    dplyr_1.0.6           
## [46] RCurl_1.98-1.3         GenomeInfoDbData_1.2.6 Matrix_1.3-3          
## [49] Rcpp_1.0.6             ggbeeswarm_0.6.0       munsell_0.5.0         
## [52] fansi_0.4.2            lifecycle_1.0.0        stringi_1.6.2         
## [55] yaml_2.2.1             MASS_7.3-54            zlibbioc_1.38.0       
## [58] blob_1.2.1             crayon_1.4.1           lattice_0.20-44       
## [61] splines_4.1.0          Biostrings_2.60.0      annotate_1.70.0       
## [64] KEGGREST_1.32.0        locfit_1.5-9.4         pillar_1.6.1          
## [67] geneplotter_1.70.0     XML_3.99-0.6           glue_1.4.2            
## [70] evaluate_0.14          vctrs_0.3.8            png_0.1-7             
## [73] Rttf2pt1_1.3.8         gtable_0.3.0           purrr_0.3.4           
## [76] assertthat_0.2.1       cachem_1.0.5           xfun_0.23             
## [79] xtable_1.8-4           survival_3.2-11        tibble_3.1.2          
## [82] beeswarm_0.3.1         memoise_2.0.0          ellipsis_0.3.2

9 References

Blighe, Rana, and Lewis (2018)

Blighe, K, S Rana, and M Lewis. 2018. “EnhancedVolcano: Publication-ready volcano plots with enhanced colouring and labeling.” https://github.com/kevinblighe/EnhancedVolcano.