[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empty custom panel plot from Gviz #426

Closed
sib-bcf opened this issue Jun 16, 2020 · 2 comments
Closed

empty custom panel plot from Gviz #426

sib-bcf opened this issue Jun 16, 2020 · 2 comments

Comments

@sib-bcf
Copy link
sib-bcf commented Jun 16, 2020

I'm trying to adapt to the latest iSEE version (2.0.0) the custom panel for displaying IGV tracks from github https://github.com/iSEE/iSEE_custom/tree/master/plot_coverage

I almost made it work (the modified code at https://github.com/sib-bcf/iSEE_test). When loading the app, the coverage tracks are displayed correctly. But, when I select a new gene from the Row Data Plot 1, then the track panel stays white. The gene selection is correctly passed to the custom panel function, and the plot is also correctly generated (as you can see from the code, I've added a few print statement and a pdf plot for checking). But, for some reason, the Gviz plot is not displayed in the iSEE panel.
First, the row data plot is reloading every time a new selection is made (and in the process, the custom function replots the default gene). Second, the Gviz plot is generated, but redirected to the R plot window [(i.e.,] the RStudio plot panel)

Thanks in advance for your help.
Cheers,
Paolo

PS: I'm running a fresh Rstudio install on docker. Here is the docker command:

docker run -d -p 8787:8787 -p 1234:1234 -v $PWD:/iSEE_APP bioconductor/bioconductor_docker:RELEASE_3_11

After, I installed the tidyverse and iSEE packages:

BiocManager::install(c("tidyverse", "iSEE", "Gviz"), ask = F)

Here is sessionInfo() output:

sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=C
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] grid parallel stats4 stats graphics grDevices utils datasets methods
[10] base

other attached packages:
[1] Gviz_1.32.0 rtracklayer_1.48.0 tidyr_1.1.0
[4] iSEE_2.0.0 SingleCellExperiment_1.10.1 SummarizedExperiment_1.18.1
[7] DelayedArray_0.14.0 matrixStats_0.56.0 Biobase_2.48.0
[10] GenomicRanges_1.40.0 GenomeInfoDb_1.24.0 IRanges_2.22.2
[13] S4Vectors_0.26.1 BiocGenerics_0.34.0 shiny_1.4.0.2
[16] BiocManager_1.30.10

loaded via a namespace (and not attached):
[1] backports_1.1.7 circlize_0.4.9 Hmisc_4.4-0
[4] BiocFileCache_1.12.0 igraph_1.2.5 lazyeval_0.2.2
[7] shinydashboard_0.7.1 splines_4.0.0 BiocParallel_1.22.0
[10] crosstalk_1.1.0.1 ggplot2_3.3.1 digest_0.6.25
[13] ensembldb_2.12.1 htmltools_0.4.0 magrittr_1.5
[16] checkmate_2.0.0 memoise_1.1.0 BSgenome_1.56.0
[19] cluster_2.1.0 ComplexHeatmap_2.4.2 Biostrings_2.56.0
[22] askpass_1.1 prettyunits_1.1.1 jpeg_0.1-8.1
[25] colorspace_1.4-1 blob_1.2.1 rappdirs_0.3.1
[28] xfun_0.14 dplyr_1.0.0 crayon_1.3.4
[31] RCurl_1.98-1.2 jsonlite_1.6.1 survival_3.1-12
[34] VariantAnnotation_1.34.0 glue_1.4.1 gtable_0.3.0
[37] zlibbioc_1.34.0 XVector_0.28.0 GetoptLong_0.1.8
[40] shape_1.4.4 scales_1.1.1 DBI_1.1.0
[43] miniUI_0.1.1.1 Rcpp_1.0.4.6 viridisLite_0.3.0
[46] xtable_1.8-4 progress_1.2.2 htmlTable_1.13.3
[49] clue_0.3-57 foreign_0.8-80 bit_1.1-15.2
[52] Formula_1.2-3 DT_0.13 htmlwidgets_1.5.1
[55] httr_1.4.1 RColorBrewer_1.1-2 shinyAce_0.4.1
[58] acepack_1.4.1 ellipsis_0.3.1 farver_2.0.3
[61] pkgconfig_2.0.3 XML_3.99-0.3 nnet_7.3-14
[64] dbplyr_1.4.4 labeling_0.3 tidyselect_1.1.0
[67] rlang_0.4.6 later_1.0.0 AnnotationDbi_1.50.0
[70] munsell_0.5.0 tools_4.0.0 generics_0.0.2
[73] RSQLite_2.2.0 rintrojs_0.2.2 stringr_1.4.0
[76] fastmap_1.0.1 yaml_2.2.1 knitr_1.28
[79] bit64_0.9-7 purrr_0.3.4 AnnotationFilter_1.12.0
[82] nlme_3.1-148 mime_0.9 biomaRt_2.44.0
[85] compiler_4.0.0 rstudioapi_0.11 curl_4.3
[88] png_0.1-7 tibble_3.0.1 stringi_1.4.6
[91] GenomicFeatures_1.40.0 lattice_0.20-41 ProtGenerics_1.20.0
[94] Matrix_1.2-18 shinyjs_1.1 vctrs_0.3.0
[97] pillar_1.4.4 lifecycle_0.2.0 GlobalOptions_0.1.1
[100] data.table_1.12.8 bitops_1.0-6 httpuv_1.5.3.1
[103] R6_2.4.1 latticeExtra_0.6-29 promises_1.1.0
[106] gridExtra_2.3 vipor_0.4.5 dichromat_2.0-0
[109] colourpicker_1.0 assertthat_0.2.1 openssl_1.4.1
[112] rjson_0.2.20 shinyWidgets_0.5.3 GenomicAlignments_1.24.0
[115] Rsamtools_2.4.0 GenomeInfoDbData_1.2.3 mgcv_1.8-31
[118] hms_0.5.3 rpart_4.1-15 biovizBase_1.36.0
[121] base64enc_0.1-3

@LTLA
Copy link
Member
LTLA commented Jun 17, 2020

tl;dr Basic Gviz doesn't work in the context of createCustomPlot.

The official requirement for createCustomPlot is that the supplied function must emit a ggplot object. I think this can be relaxed to "any object that has a show method to create a plot on the current graphics device" . The reason for this requirement is because iSEE() will, by default, create the plotting object in a separate step from actually making the plot on the graphics device. This is pretty convoluted but is necessary to handle cases where one plot depends on another plot; you want to do all the data organization in one step and the actual display of the plot object in another step. ggplot2 and other grid plots fit this paradigm, so it is pretty general.

The problem is that Gviz's output doesn't follow that paradigm. It seems that we are expected to call plotTracks to create the plot on the current graphics device. That you see the plot correctly on the first call is probably down to luck, it happens that the right graphics device was open at the time when iSEE() calls your function. The rest of the time, you get the weirdness observed where iSEE() is calling your function without the graphics device open (which it is entitled to do, because it's not trying to make a plot at this point).

Nonetheless, we can maneuver our way to a solution. Behold:

CREATOR <- setClass("SuperGvizPlot", contains="list")

setMethod("show", "SuperGvizPlot", function(object) {
    do.call(plotTracks, object)
})

And then in CUSTOM_GVIZ, return:

    # End of CUSTOM_GVIZ
    cat("coords:", chr, minCoord, maxCoord, plot_title, "\n", sep = " ")

    CREATOR(list(tracks, chromosome = chr, from = minCoord,
                 to = maxCoord, main = plot_title,
                 transcriptAnnotation = "transcript", panel.only=TRUE,
                 min.width = 0, min.distance = 0, collapse = FALSE))
}

And it should Just Work. A true solution would be to write a dedicated panel class that calls plotTracks() in the plot rendering statement; one could consider filing an issue - or better, a PR - in the iSEEu repository.

@sib-bcf
Copy link
Author
sib-bcf commented Jun 17, 2020

Thanks Aaron,
your workaround did the trick for me!

Cheers,
Paolo

@sib-bcf sib-bcf closed this as completed Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants