Arrange Gviz plotTracks() figure and basic R plot on a canvas
0
1
Entering edit mode
@izzyyichaocai-12853
Last seen 3.2 years ago

Hi,

I am trying to put Gviz output and a basic R plot on the same canvas.

The figures I have:

1) A basic R plot recorded with recordPlot()

2) A bunch of Gviz tracks

Attempts I took:

I tried to grab the Gviz output using grid::grid.grabExp() and use cowplot::plot_grid() to put them on the same canvas.

tp <- grid.grabExpr(plotTracks(list(gtrack,ht),from = chrstart, to=chrend, chromosome = chrm, add = TRUE))

# >Warning message:

# >In grabDL(warn, wrap, ...) :

# >one of more grobs overwritten (grab WILL not be faithful; try 'wrap = TRUE')

figure <- plot_grid(basic_R, tp)

The final figure did no 100% replicate what I saw with plotTracks(). Some (NOT ALL!) data tracks in "polygon" style lost their color fill in mountains. I could still see the colored line but the fill between colored peaks and baseline was totally lost.

Adding the 'wrap = TRUE' would not solve this problem and the error still occured.

How could I properly arrange them on the same canvas?

Thank you so much for your help!

 

 

SessionInfo:

R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.0
LAPACK: /usr/lib/lapack/liblapack.so.3.0

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

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

other attached packages:
[1] gridGraphics_0.3-0                      gdtools_0.1.7                           bindrcpp_0.2                          
[4] org.Hs.eg.db_3.5.0                      TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 GenomicFeatures_1.30.3                
[7] AnnotationDbi_1.40.0                    Biobase_2.38.0                          Gviz_1.22.3                           
[10] GenomicRanges_1.30.3                    GenomeInfoDb_1.14.0                     IRanges_2.12.0                        
[13] S4Vectors_0.16.0                        BiocGenerics_0.24.0                     optparse_1.4.4                        
[16] Sushi_1.16.0                            biomaRt_2.34.2                          zoo_1.8-1                             
[19] forcats_0.3.0                           stringr_1.3.0                           tidyr_0.8.0                           
[22] tibble_1.4.2                            tidyverse_1.2.1                         RColorBrewer_1.1-2                    
[25] cowplot_0.9.2                           gridExtra_2.3                           ggpubr_0.1.6.999                      
[28] magrittr_1.5                            svglite_1.2.1                           scales_0.5.0.9000                     
[31] ggrepel_0.7.3                           ggplot2_2.2.1.9000                      purrr_0.2.4                           
[34] readr_1.1.1                             dplyr_0.7.4                             here_0.1                               

loaded via a namespace (and not attached):
[1] colorspace_1.3-2              rprojroot_1.3-2               biovizBase_1.26.0             htmlTable_1.11.2            
[5] XVector_0.18.0                base64enc_0.1-3               dichromat_2.0-0               rstudioapi_0.7              
[9] getopt_1.20.2                 bit64_0.9-7                   interactiveDisplayBase_1.16.0 lubridate_1.7.4             
[13] xml2_1.2.0                    splines_3.4.4                 mnormt_1.5-5                  knitr_1.20                  
[17] Formula_1.2-2                 jsonlite_1.5                  Rsamtools_1.30.0              broom_0.4.3                 
[21] cluster_2.0.7-1               shiny_1.0.5                   compiler_3.4.4                httr_1.3.1                  
[25] backports_1.1.2               assertthat_0.2.0              Matrix_1.2-14                 lazyeval_0.2.1              
[29] cli_1.0.0                     acepack_1.4.1                 htmltools_0.3.6               prettyunits_1.0.2           
[33] tools_3.4.4                   gtable_0.2.0                  glue_1.2.0                    GenomeInfoDbData_1.0.0      
[37] reshape2_1.4.3                Rcpp_0.12.16                  cellranger_1.1.0              Biostrings_2.46.0           
[41] nlme_3.1-137                  rtracklayer_1.38.3            psych_1.7.8                   rvest_0.3.2                 
[45] mime_0.5                      ensembldb_2.2.2               XML_3.98-1.10                 AnnotationHub_2.10.1        
[49] zlibbioc_1.24.0               BSgenome_1.46.0               BiocInstaller_1.28.0          VariantAnnotation_1.24.5    
[53] ProtGenerics_1.10.0           hms_0.4.2                     SummarizedExperiment_1.8.1    AnnotationFilter_1.2.0      
[57] curl_3.1                      yaml_2.1.18                   memoise_1.1.0                 rpart_4.1-13                
[61] latticeExtra_0.6-28           stringi_1.1.7                 RSQLite_2.0                   RMySQL_0.10.14              
[65] checkmate_1.8.5               BiocParallel_1.12.0           rlang_0.2.0.9001              pkgconfig_2.0.1             
[69] bitops_1.0-6                  matrixStats_0.53.1            lattice_0.20-35               bindr_0.1.1                 
[73] labeling_0.3                  GenomicAlignments_1.14.1      htmlwidgets_1.0               bit_1.1-12                  
[77] plyr_1.8.4                    R6_2.2.2                      Hmisc_4.1-1                   DelayedArray_0.4.1          
[81] DBI_0.8                       pillar_1.2.2                  haven_1.1.1                   foreign_0.8-70              
[85] withr_2.1.2                   survival_2.42-3               RCurl_1.95-4.10               nnet_7.3-12                 
[89] modelr_0.1.1                  crayon_1.3.4                  progress_1.1.2                readxl_1.1.0                
[93] data.table_1.10.4-3           blob_1.1.0                    digest_0.6.15                 xtable_1.8-2                
[97] httpuv_1.3.6.2                munsell_0.4.3                
gviz gviz-package • 489 views
ADD COMMENT

Login before adding your answer.

Traffic: 133 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