This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to retain interactive plots from Glimma in R Markdown HTML Document

I created an interactive volcano plot using the code below using glXYPlot function in Glimma. A separate HTML page is created; however, when I knit the R markdown document, the interactive plot is not displayed in the final HTML document. How can I retain the interactive plot in the final document?

{r eval = T, echo = T}
glXYPlot(x=fit.contrst$coefficients[,1], 
     y=fit.contrst$lods[,1],
     xlab="Log fold-change", 
     ylab="B", 
     main="CFVsNormal",
     counts=voom$E, 
     groups=group.data, 
     status=summary.data[,1],
     anno=fit.contrst$genes, 
     side.main="ENTREZID",
     folder = "volcano",
     ) 
r glimma markdown

Have you tried implicitly setting "html=NULL"?

Looking at the github for GlimmaV2, the internally called function glimmaXYWidget will return the widget without exporting it if html=NULL

glimmaXYWidget <- function(xData, width, height, html)
{
  widget <- htmlwidgets::createWidget(
    name = 'glimmaXY',
    xData,
    width = width,
    height = height,
    package = 'Glimma',
    elementId = NULL,
    sizingPolicy = htmlwidgets::sizingPolicy(defaultWidth=width, defaultHeight=height, browser.fill=TRUE, viewer.suppress=TRUE)
  )
  if (is.null(html))
  {
    return(widget)
  }
  else
  {
    message("Saving widget...")
    htmlwidgets::saveWidget(widget, file=html)
    message(html, " generated.")
  }
}

I'm trying to build the XYData, but I get the error "could not find function "buildXYData""

Sorry, I meant in your original example to explicitly state:

glXYPlot(x=fit.contrst$coefficients[,1], 
     y=fit.contrst$lods[,1],
     xlab="Log fold-change", 
     ylab="B", 
     main="CFVsNormal",
     counts=voom$E, 
     groups=group.data, 
     status=summary.data[,1],
     anno=fit.contrst$genes, 
     side.main="ENTREZID",
     folder = "volcano",
     html=NULL ### changed here
     ) 

Otherwise because these functions are internal Glimma functions if you want to edit the function you'll need to prepend them with Glimma:: or Glimma::: depending on whether it's an exported function or an internal one

0 answers

No answers yet.

Log in to answer this question.