Displaying points which fall outside of the plot window in EnhancedVolcano
1
0
Entering edit mode
12 months ago
os306 ▴ 10

Hello,

I am using DESeq2 for a differential gene expression analysis of bulk RNAseq data. I am attempting to generate a volcano plot using EnchancedVolcano and was wondering whether it is possible to plot points which fall outside of the figure window. For example, the function plotMA displays points which fall out of the window as open triangles pointing either up or down. Is it possible to do this using EnhancedVolcano (or some other method?)

Thanks very much

EnhancedVolcano plot volcano • 1.4k views
0
Entering edit mode
0
Entering edit mode

Thanks very much for taking the time to reply. Sorry if this is a silly question, but I had a look at that part of the vignette and I still wasn’t sure how to achieve what I’m looking for (i.e. open triangles to represent outliers that fall outside of the plot window). Would be very grateful for any guidance!

1
Entering edit mode

There is no equivalent function in EnhancedVolcano for this. I would suggest that you simply modify the limits of the x axis via xlim, or, if you want to genuinely reproduce this functionality in EnhancedVolcano, you could achieve it by modifying the underlying log [base 2] fold change values in your input object for these points, and also change their shape to be open triangles.

It's obviously quite difficult to account for every eventuality, and the EnhancedVolcano function / package is already 'parameter overloaded'. I am tentative about doing any further modifications.

0
Entering edit mode

Hi, thanks for your reply. I totally get it. Regardless, it's a fantastic package and very intuitive, particularly for a novice like myself. Thank you for making it!

1
Entering edit mode

No problem. You could try the solution by ATpoint (below) and adapt it to make a volcano, but, then, one can begin to see how there is a learning curve with ggplot2's 'unique' format.

4
Entering edit mode
12 months ago

ATpoint made me try this! Unfortunately, it is not as easy with EnhancedVolcano, and I may suggest a customised way via ggplot2, as per ATpoint's code.

Credit to Carlo Yague for the left and right arrow codes.

From the vignette (https://github.com/kevinblighe/EnhancedVolcano):

library(EnhancedVolcano)

library(airway)
library(magrittr)

data('airway')
airway$dex %<>% relevel('untrt') ens <- rownames(airway) library(org.Hs.eg.db) symbols <- mapIds(org.Hs.eg.db, keys = ens, column = c('SYMBOL'), keytype = 'ENSEMBL') symbols <- symbols[!is.na(symbols)] symbols <- symbols[match(rownames(airway), names(symbols))] rownames(airway) <- symbols keep <- !is.na(rownames(airway)) airway <- airway[keep,] library(DESeq2) dds <- DESeqDataSet(airway, design = ~ cell + dex) dds <- DESeq(dds, betaPrior=FALSE) res <- results(dds, contrast = c('dex','trt','untrt')) res <- lfcShrink(dds, contrast = c('dex','trt','untrt'), res=res, type = 'normal') p1 <- EnhancedVolcano(res, lab = rownames(res), x = 'log2FoldChange', y = 'pvalue', drawConnectors = TRUE, legendPosition = 'none')  Now, for the new volcano, where absolute log2 FC 2.5 is our cut-off for display purposes: res.new <- res cutoff <- 2.5 # identify genes that pass the threshold of 2.5 up <- rownames(subset(res, log2FoldChange >= cutoff)) up down <- rownames(subset(res, log2FoldChange <= cutoff * -1)) down # impute log2 FCs in the object to be max 2.5 or min -2.5 res.new$log2FoldChange <- ifelse(res.new$log2FoldChange >= cutoff, cutoff, ifelse(res.new$log2FoldChange <= cutoff * -1, cutoff * -1,
res.new$log2FoldChange)) max(res.new$log2FoldChange, na.rm = TRUE)
min(res.new\$log2FoldChange, na.rm = TRUE)

# custom shapes for the points
customshape <- rep(19, nrow(res.new))
names(customshape) <- rep('group1', nrow(res.new))
customshape[which(rownames(res.new) %in% up)] <- -9658
names(customshape)[which(rownames(res.new) %in% up)] <- 'group2'
customshape[which(rownames(res.new) %in% down)] <- -9668
names(customshape)[which(rownames(res.new) %in% down)] <- 'group3'

# custom sizes for the points
customsize <- rep(2.0, nrow(res.new))
customsize [which(rownames(res.new) %in% up)] <- 8
customsize [which(rownames(res.new) %in% down)] <- 8

p2 <- EnhancedVolcano(res.new,
lab = rownames(res.new),
x = 'log2FoldChange',
y = 'pvalue',
drawConnectors = TRUE,
shapeCustom = customshape,
legendPosition = 'none',
pointSize = customsize,
xlim = c(-2.5,2.5))


Now draw the 2 plots:

cowplot::plot_grid(p1, p2, ncol = 2)


1
Entering edit mode

Thank you, once again, for taking the time to do this. This, and the package from ATpoint below, are exactly what I was looking for.