Question: Does EnhancedVolcano() supports crosstalk()?
1
gravatar for IrK
12 days ago by
IrK50
Australia
IrK50 wrote:

Hello,

I posted a question at the StackOverflow please see my question about an error I am getting when I try to crosstalk volcano plot generated by EnhancedVolcano package. I received a reply that it is not supported, although documentation says that it generated ggplot2 object.

I would like to double check with developers if this issue could be fixed from their side or the advice how to get around it.

Thank you.

ADD COMMENTlink modified 11 days ago • written 12 days ago by IrK50
1

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.

ADD REPLYlink modified 12 days ago • written 12 days ago by Kevin Blighe54k

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 with SharedData, which is an R6 class,

Link that describes SharedData https://rdrr.io/cran/crosstalk/man/SharedData.html

ADD REPLYlink written 12 days ago by IrK50

between All credit to you, this is amazing package !!

ADD REPLYlink written 12 days ago by IrK50

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) from SharedData$new() is not seen properly in EnhancedVolcano(data_shared). I assume that EnhancedVolcano() doesn't recognize this output as the data frame anymore.

ADD REPLYlink written 11 days ago by IrK50

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).

vp =EnhancedVolcano( toptable = data_shared,
      ...) 
  bscols(
    ...
    datatable(data_shared, ...)

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:

lab = data_shared$lab
ADD REPLYlink modified 11 days ago • written 11 days ago by Kevin Blighe54k

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:

Error in as.data.frame.default(toptable) : 
  cannot coerce class ‘c("SharedData", "R6")’ to a data.frame

not sure how to fix it, yet.

ADD REPLYlink modified 8 days ago • written 8 days ago by IrK50

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...

ADD REPLYlink written 8 days ago by Kevin Blighe54k
1
gravatar for Kevin Blighe
12 days ago by
Kevin Blighe54k
Kevin Blighe54k wrote:

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')))

gg

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

ADD COMMENTlink written 12 days ago by Kevin Blighe54k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1567 users visited in the last hour