Hi,
Thanks - that's very useful code and I may add it to the main package vignette, eventually.
I tried it here on my computer and I was able to get it working in my browser, but some components of the original plot seem to have been lost. I think that you just need to convert your column, 'qsec', to numerical values.
Re-using an example from my Vignette, here is a perfectly reproducible example:
library("pasilla")
pasCts <- system.file("extdata", "pasilla_gene_counts.tsv",
package="pasilla", mustWork=TRUE)
pasAnno <- system.file("extdata", "pasilla_sample_annotation.csv",
package="pasilla", mustWork=TRUE)
cts <- as.matrix(read.csv(pasCts,sep="\t",row.names="gene_id"))
coldata <- read.csv(pasAnno, row.names=1)
coldata <- coldata[,c("condition","type")]
rownames(coldata) <- sub("fb", "", rownames(coldata))
cts <- cts[, rownames(coldata)]
library("DESeq2")
dds <- DESeqDataSetFromMatrix(countData = cts,
colData = coldata,
design = ~ condition)
featureData <- data.frame(gene=rownames(cts))
mcols(dds) <- DataFrame(mcols(dds), featureData)
dds <- DESeq(dds)
res <- results(dds)
library(EnhancedVolcano)
p1 <- EnhancedVolcano(res,
lab = rownames(res),
x = "log2FoldChange",
y = "pvalue",
pCutoff = 10e-4,
FCcutoff = 2,
xlim = c(-5.5, 5.5),
ylim = c(0, -log10(10e-12)),
pointSize = c(ifelse(res$log2FoldChange>2, 8, 1)),
labSize = 4.0,
shape = c(6, 6, 19, 16),
title = "DESeq2 results",
subtitle = "Differential expression",
caption = "FC cutoff, 1.333; p-value cutoff, 10e-4",
legendPosition = "right",
legendLabSize = 14,
col = c("grey30", "forestgreen", "royalblue", "red2"),
colAlpha = 0.9,
drawConnectors = TRUE,
hline = c(10e-8),
widthConnectors = 0.5)
p1 <- p1 +
ggplot2::coord_cartesian(xlim=c(-6, 6)) +
ggplot2::scale_x_continuous(
breaks=seq(-6,6, 1))
library(plotly)
library(DT)
library(crosstalk)
bscols(
ggplotly(p1 + aes(x= log2FoldChange, y= -log10(pvalue))),
datatable(
data.frame(res),
style="bootstrap",
class="compact", width="100%",
options=list(deferRender=FALSE, dom='t')))
Unfortunately, plotly and/or bscols don't like the use of bquote()
, so, one cannot have the fancy axes names that I use in EnhancedVolcano:
... + xlab(bquote(~Log[2] ~ "fold change")) + ylab(bquote(~-Log[10] ~ italic(P)))
When i try to add these, it throws an error.
Kevin
I developed EnhancedVolcano and indeed it is a 'big wrapper' around ggplot2, to quote the person on StackOverflow. It's amazing how complex a simple
plot(x, -log10(y))
can become...I have never even heard of crosstalk. Can you show me in commands exactly what you are trying to do?
Edit: you had posted code on StackOverflow. I will take a look.
in a nutshell, I am trying to make interactive visualization, so my Volcano Plot should be able to "communicate" with the table and vice versa, basically to show information on a plot or table.
After some research, I ended up trying
crosstalk
, which is quite new to me, but I managed to make it work on a simple example, however, not so successful with Volcano Plot. I need to create shared data object withSharedData
, which is an R6 class,Link that describes
SharedData
https://rdrr.io/cran/crosstalk/man/SharedData.htmlbetween All credit to you, this is amazing package !!
Thanks, for your prompt response.
Unfortunately, this is not what was not working.
The issue is that the output
data_shared
,data_shared = SharedData$new(data1)
fromSharedData$new()
is not seen properly inEnhancedVolcano(data_shared)
. I assume thatEnhancedVolcano()
doesn't recognize this output as the data frame anymore.I am failing to see the difference. In your question on StackOverflow, you generate the volcano with the same data object that you use for
datatable
, which is precisely what I do in my answer here (the object being 'res' in my case, 'data_shared' in your case).The error being thrown is from THIS line in the code, which indicates that your 'x' column is not numeric.
Also, you are not using the
lab
parameter correctly. It probably should be:the difference is that
SharedData$new(...)
provides interactivity between two objects. click on a dot from the plot and get the information of this dot in the table highlighted and vice versa click on a row in the table and the dot that represents this row in the plot is highlighted. At the moment, I can see plot information if you hover with the mouse over specific dot, but it doesn't show which row it corresponds to in the table. Well at least I can't highlighted dots of interest and see corresponding information in the table. Hope this makes sense.tried to modify few things in volcano function, got following error:
not sure how to fix it, yet.
I see... you may take the recommendation from the person who originally replied on SO, i.e., StupidWolf. EnhancedVolcano is a function that creates a ggplot2 and ggrepel object. The data-frame that you pass to EnhancedVolcano is manipulated internally, perhaps beyond that which is then needed to work properly by bscols or gplotly.
Note that EnhancedVolcano was primarily put on Bioconductor for my own use, as I work on a lot of expression studies. It's a bit crazy that it now gets > 1000 unique IP downloads per month...