BiocStyle::html_document does not render Glimma plots
1
1
Entering edit mode
neilzhao ▴ 30
@0f8d7a2e
Last seen 11 months ago
United States

Knitting Glimma plots in Rmd files with the BiocStyle::html_document output (BiocStyle_2.25.0) do not appear and shows a blank space. However, if you remove "BiocStyle::" and use html_document, the interactive plot renders successfully and embeds/appears as expected.

For example, I followed a demonstration similar to the posted Glimma guide:

---
title: "Example: Issues rendering Glimma plots"
output:
  BiocStyle::html_document:
    toc: true
    toc_float:
      collapsed: true
      smooth_scroll: true
vignette: |
  %\VignetteIndexEntry{Example: Issues rendering Glimma plots}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

# Glimma plots do not embed with BiocStyle
```{r}
#Packages needed
if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install(c("Glimma", "limma", "edgeR", "BiocStyle"))

library(Glimma)
library(limma)
library(edgeR)


#Load and read in example RNAseq123 data from wd()
#https://github.com/hasaru-k/GlimmaV2/blob/master/inst/RNAseq123/dge.rds
dge <- readRDS("dge.rds")
```

## MDS Plot
```{r}
glimmaMDS(dge)
```

# Session info {.unnumbered}

```{r sessionInfo, echo=FALSE}
sessionInfo()
```

I tried updating all my package versions and using render(x, BiocStyle::html_document()), fig.show='asis', and results='asis' to process it, but no luck. I love the BiocStyle formatting aesthetics and want to preserve them, but want to avoid messing with the BiocStyle source code manually (if possible). Any suggestions?

Thank you!

Here is my sessioninfo:

R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] edgeR_3.39.3        limma_3.53.4        Glimma_2.7.0        BiocManager_1.30.18

loaded via a namespace (and not attached):
 [1] MatrixGenerics_1.9.1        Biobase_2.57.1              httr_1.4.3                  jsonlite_1.8.0             
 [5] bit64_4.0.5                 splines_4.2.0               assertthat_0.2.1            stats4_4.2.0               
 [9] blob_1.2.3                  GenomeInfoDbData_1.2.8      yaml_2.3.5                  pillar_1.8.0               
[13] RSQLite_2.2.15              lattice_0.20-45             glue_1.6.2                  digest_0.6.29              
[17] GenomicRanges_1.49.0        RColorBrewer_1.1-3          XVector_0.37.0              colorspace_2.0-3           
[21] htmltools_0.5.3             Matrix_1.4-1                DESeq2_1.37.4               XML_3.99-0.10              
[25] pkgconfig_2.0.3             genefilter_1.79.0           zlibbioc_1.43.0             purrr_0.3.4                
[29] xtable_1.8-4                scales_1.2.0                BiocParallel_1.31.10        tibble_3.1.7               
[33] annotate_1.75.0             KEGGREST_1.37.3             generics_0.1.3              IRanges_2.31.0             
[37] ggplot2_3.3.6               ellipsis_0.3.2              cachem_1.0.6                SummarizedExperiment_1.27.1
[41] BiocGenerics_0.43.0         cli_3.3.0                   survival_3.3-1              magrittr_2.0.3             
[45] crayon_1.5.1                memoise_2.0.1               fansi_1.0.3                 tools_4.2.0                
[49] lifecycle_1.0.1             matrixStats_0.62.0          S4Vectors_0.35.1            locfit_1.5-9.6             
[53] munsell_0.5.0               DelayedArray_0.23.0         AnnotationDbi_1.59.1        Biostrings_2.65.1          
[57] compiler_4.2.0              GenomeInfoDb_1.33.3         rlang_1.0.4                 grid_4.2.0                 
[61] RCurl_1.98-1.7              rstudioapi_0.13             htmlwidgets_1.5.4           bitops_1.0-7               
[65] gtable_0.3.0                codetools_0.2-18            DBI_1.1.3                   R6_2.5.1                   
[69] knitr_1.39                  dplyr_1.0.9                 fastmap_1.1.0               bit_4.0.4                  
[73] utf8_1.2.2                  parallel_4.2.0              Rcpp_1.0.9                  vctrs_0.4.1                
[77] geneplotter_1.75.0          png_0.1-7                   tidyselect_1.1.2            xfun_0.31   

```
Glimma BiocStyle • 1.3k views
ADD COMMENT
2
Entering edit mode

I think this is because BiocStyle modifies the HTML file, and inadvertantly breaks some of the Javascript Glimma inserts into the page. Can you try my devel version of BiocStyle? It's available via:

BiocManager::install('grimbough/BiocStyle', ref = 'glimma-plots')

You might need to play with the width argument to glimmaMDS() to get it to look nice in the BiocStyle layout.

ADD REPLY
1
Entering edit mode

Awesome, this works perfectly! Thank you so much Mike! If you want to add this as an answer, I can mark it as the solution.

On a separate but related note, do you think this is a similar reason on why the r code chunk option "animation.hook="gifski" doesn't work? For example, following this guide from Yihui:

---
title: "Example: Issues rendering animated plots"
output:
  html_document:
    toc: true
    toc_float:
      collapsed: true
      smooth_scroll: true
vignette: |
  %\VignetteIndexEntry{Example: Issues rendering animated plots}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

# Animated plots gives errors with BiocStyle
```{r eval=FALSE, include=FALSE}
#Packages needed
if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install(c("gifski"))
```

```{r}
library(gifski)
```

```{r, animation.hook="gifski"}
for (i in 1:2) {
  pie(c(i %% 2, 6), col = c('red', 'yellow'), labels = NA)
}
```

# Session info {.unnumbered}

```{r sessionInfo, echo=FALSE}
sessionInfo()
```

I get the following error:

Error in magick_image_readpath(path, density, depth, strip, defines) : 
  Rterm.exe: UnableToOpenBlob `~\RData Workspace\test_files\figure-html\unnamed-chunk-3-1.png': No such file or directory @ error/blob.c/OpenBlob/2924
Calls: <Anonymous> ... in_dir -> plot_crop -> <Anonymous> -> magick_image_readpath
Execution halted

At first, I thought this was an issue of setting my default working directory. However, if you remove "BiocStyle::" and only use "html_document:", it works as intended.

Anyways, thank you again so much!

ADD REPLY
1
Entering edit mode

Following my previous comment, Mike's fix also works with the gganimate package in case anyone is having the same issue with "animation.hook" .

ADD REPLY
1
Entering edit mode

Thanks for confirming that it works. I won't make this an answer as it'll be better to get the patch into the official BiocStyle version rather than my fork on GitHub.

I'll make a pull request and address the issue you open on GitHub and once it's in the proper version I'll update here.

ADD REPLY
1
Entering edit mode
@james-w-macdonald-5106
Last seen 9 hours ago
United States

I have no suggestions for getting BiocStyle to work with the interactive plots from Glimma - it doesn't work for me either. I tend to use bookdown instead, with this in my yaml

output:
   bookdown::html_document2:
    df_print: kable
    toc: true
    toc_float: true

Which seems to work OK. The authors of Glimma use rmarkdown:html_vignette in their yaml

title: "Introduction using limma or edgeR"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Introduction using limma or edgeR}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}

Which obviously works as well.

ADD COMMENT
0
Entering edit mode

Thanks for the suggestion! Unfortunately, it looks like I'll need to manually set the CSS styles for the time being...

ADD REPLY

Login before adding your answer.

Traffic: 941 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6