lawremi / ggbio

Grid and ggplot2 based visualization for biological data
111 stars 24 forks source link

Error: Don't know how to add o to a plot #95

Open wibom opened 6 years ago

wibom commented 6 years ago

Trying out ggbio for the first time. I get stuck on the first example I try:

library (ggplot2)
library (ggbio)

library (EnsDb.Hsapiens.v86)
ensdb <- EnsDb.Hsapiens.v86
autoplot(ensdb, GenenameFilter("PHKG2"))

This gives the following output/error:

Fetching data...OK
Parsing exons...OK
Defining introns...OK
Defining UTRs...OK
Defining CDS...OK
aggregating...
Done
Constructing graphics...
Error: Don't know how to add o to a plot

sessionInfo:

R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=Swedish_Sweden.1252  LC_CTYPE=Swedish_Sweden.1252    LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C                   
[5] LC_TIME=Swedish_Sweden.1252    

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

other attached packages:
 [1] EnsDb.Hsapiens.v86_2.99.0 ensembldb_2.2.0           AnnotationFilter_1.2.0    GenomicFeatures_1.30.0    AnnotationDbi_1.40.0     
 [6] Biobase_2.38.0            GenomicRanges_1.30.1      GenomeInfoDb_1.14.0       IRanges_2.12.0            S4Vectors_0.16.0         
[11] ggbio_1.26.0              BiocGenerics_0.24.0       ggplot2_2.2.1.9000       

loaded via a namespace (and not attached):
 [1] ProtGenerics_1.10.0           bitops_1.0-6                  matrixStats_0.52.2            bit64_0.9-7                  
 [5] RColorBrewer_1.1-2            progress_1.1.2                httr_1.3.1                    tools_3.4.3                  
 [9] backports_1.1.2               R6_2.2.2                      rpart_4.1-11                  Hmisc_4.1-1                  
[13] DBI_0.7                       lazyeval_0.2.1                colorspace_1.3-2              nnet_7.3-12                  
[17] gridExtra_2.3                 prettyunits_1.0.2             GGally_1.3.2                  RMySQL_0.10.13               
[21] bit_1.1-12                    curl_3.1                      compiler_3.4.3                graph_1.56.0                 
[25] htmlTable_1.11.1              DelayedArray_0.4.1            rtracklayer_1.38.2            scales_0.5.0.9000            
[29] checkmate_1.8.5               RBGL_1.54.0                   stringr_1.2.0                 digest_0.6.13                
[33] Rsamtools_1.30.0              foreign_0.8-69                XVector_0.18.0                pkgconfig_2.0.1              
[37] base64enc_0.1-3               dichromat_2.0-0               htmltools_0.3.6               BSgenome_1.46.0              
[41] htmlwidgets_0.9               rlang_0.1.6                   rstudioapi_0.7                RSQLite_2.0                  
[45] BiocInstaller_1.28.0          shiny_1.0.5                   BiocParallel_1.12.0           acepack_1.4.1                
[49] VariantAnnotation_1.24.5      RCurl_1.95-4.10               magrittr_1.5                  GenomeInfoDbData_1.0.0       
[53] Formula_1.2-2                 Matrix_1.2-12                 Rcpp_0.12.14                  munsell_0.4.3                
[57] stringi_1.1.6                 yaml_2.1.16                   SummarizedExperiment_1.8.1    zlibbioc_1.24.0              
[61] plyr_1.8.4                    AnnotationHub_2.10.1          grid_3.4.3                    blob_1.1.0                   
[65] lattice_0.20-35               Biostrings_2.46.0             splines_3.4.3                 knitr_1.18                   
[69] pillar_1.0.1                  reshape2_1.4.3                biomaRt_2.34.1                XML_3.98-1.9                 
[73] biovizBase_1.26.0             latticeExtra_0.6-28           data.table_1.10.4-3           httpuv_1.3.5                 
[77] gtable_0.2.0                  reshape_0.8.7                 assertthat_0.2.0              mime_0.5                     
[81] xtable_1.8-2                  survival_2.41-3               tibble_1.4.1                  OrganismDbi_1.20.0           
[85] GenomicAlignments_1.14.1      memoise_1.1.0                 cluster_2.0.6                 interactiveDisplayBase_1.16.0

What gives?

davemcg commented 6 years ago

Same issue

> library(ggbio)
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: ‘BiocGenerics’

The following objects are masked from ‘package:parallel’:

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ, clusterExport, clusterMap, parApply, parCapply, parLapply, parLapplyLB,
    parRapply, parSapply, parSapplyLB

The following objects are masked from ‘package:stats’:

    IQR, mad, sd, var, xtabs

The following objects are masked from ‘package:base’:

    anyDuplicated, append, as.data.frame, cbind, colMeans, colnames, colSums, do.call, duplicated, eval, evalq, Filter, Find, get,
    grep, grepl, intersect, is.unsorted, lapply, lengths, Map, mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int,
    Position, rank, rbind, Reduce, rowMeans, rownames, rowSums, sapply, setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

Loading required package: ggplot2
Need specific help about ggbio? try mailing 
 the maintainer or visit http://tengfei.github.com/ggbio/

Attaching package: 'ggbio'

The following objects are masked from 'package:ggplot2':

    geom_bar, geom_rect, geom_segment, ggsave, stat_bin, stat_identity, xlim

> library(TxDb.Hsapiens.UCSC.hg19.knownGene)
Loading required package: GenomicFeatures
Loading required package: S4Vectors
Loading required package: stats4

Attaching package: 'S4Vectors'

The following object is masked from 'package:base':

    expand.grid

Loading required package: IRanges
Loading required package: GenomeInfoDb
Loading required package: GenomicRanges
Loading required package: AnnotationDbi
Loading required package: Biobase
Welcome to Bioconductor

    Vignettes contain introductory material; view with 'browseVignettes()'. To cite Bioconductor, see 'citation("Biobase")', and for
    packages 'citation("pkgname")'.

> data(genesymbol, package = "biovizBase")
> txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
> p1 <- ggplot() + geom_alignment(txdb, which = genesymbol["RBM17"])
Parsing transcripts...
Parsing exons...
Parsing cds...
Parsing utrs...
------exons...
------cdss...
------introns...
------utr...
aggregating...
Done
Constructing graphics...
Error: Don't know how to add o to a plot
> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.2

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 GenomicFeatures_1.28.5                  AnnotationDbi_1.38.2                   
 [4] Biobase_2.36.2                          GenomicRanges_1.28.6                    GenomeInfoDb_1.12.3                    
 [7] IRanges_2.10.5                          S4Vectors_0.14.7                        ggbio_1.24.1                           
[10] ggplot2_2.2.1.9000                      BiocGenerics_0.22.1                    

loaded via a namespace (and not attached):
 [1] ProtGenerics_1.8.0            bitops_1.0-6                  matrixStats_0.52.2            bit64_0.9-7                  
 [5] RColorBrewer_1.1-2            httr_1.3.1                    tools_3.4.1                   backports_1.1.1              
 [9] R6_2.2.2                      rpart_4.1-11                  Hmisc_4.0-3                   DBI_0.7                      
[13] lazyeval_0.2.1                colorspace_1.3-2              nnet_7.3-12                   withr_2.1.1.9000             
[17] gridExtra_2.3                 GGally_1.3.2                  bit_1.1-12                    curl_3.0                     
[21] compiler_3.4.1                graph_1.54.0                  htmlTable_1.9                 DelayedArray_0.2.7           
[25] rtracklayer_1.36.6            scales_0.5.0.9000             checkmate_1.8.5               RBGL_1.52.0                  
[29] stringr_1.2.0                 digest_0.6.14                 Rsamtools_1.28.0              foreign_0.8-69               
[33] XVector_0.16.0                base64enc_0.1-3               dichromat_2.0-0               pkgconfig_2.0.1              
[37] htmltools_0.3.6               ensembldb_2.0.4               BSgenome_1.44.2               htmlwidgets_0.9              
[41] rlang_0.1.6.9003              RSQLite_2.0                   BiocInstaller_1.26.1          shiny_1.0.5                  
[45] BiocParallel_1.10.1           acepack_1.4.1                 VariantAnnotation_1.22.3      RCurl_1.95-4.8               
[49] magrittr_1.5                  GenomeInfoDbData_0.99.0       Formula_1.2-2                 Matrix_1.2-11                
[53] Rcpp_0.12.15                  munsell_0.4.3                 stringi_1.1.5                 yaml_2.1.14                  
[57] SummarizedExperiment_1.6.5    zlibbioc_1.22.0               plyr_1.8.4                    AnnotationHub_2.8.3          
[61] grid_3.4.1                    blob_1.1.0                    lattice_0.20-35               Biostrings_2.44.2            
[65] splines_3.4.1                 knitr_1.17                    pillar_1.1.0                  reshape2_1.4.3               
[69] biomaRt_2.32.1                XML_3.98-1.9                  biovizBase_1.24.0             latticeExtra_0.6-28          
[73] data.table_1.10.4-3           httpuv_1.3.5                  gtable_0.2.0                  reshape_0.8.7                
[77] mime_0.5                      xtable_1.8-2                  AnnotationFilter_1.0.0        survival_2.41-3              
[81] tibble_1.4.2                  OrganismDbi_1.18.1            GenomicAlignments_1.12.2      memoise_1.1.0                
[85] cluster_2.0.6                 interactiveDisplayBase_1.14.0
lawremi commented 6 years ago

Is this because you guys are using ggplot2 2.2.1.9000? I guess .9000 is the github version, which I'm not going to be able to support.

davemcg commented 6 years ago

Yep, that was it. Didn't realize I was running the github version. Thanks. An extremely annoying error message....as it is not very informative.

eugenegardner commented 6 years ago

I believe this may be broken again with the release of ggplot2 3.0.0.

I did the following:

library(ggbio)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
library(GenomicRanges)
library(biomaRt)

txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
range<-GRanges(paste("chr",cnv.chr,":",cnv.start,"-",cnv.end,sep=""))
exons<-subsetByOverlaps(exonsBy(txdb,"gene"),range)
autoplot(txdb,which=exons[[2]])

And got the error message:

Error: Don't know how to add o to a plot

With v3.0.0 of ggplot2, but recieved the lovely plot:

ggbio

With v2.2.1 of ggplot2.

Thanks!

lawremi commented 6 years ago

Please send a complete reproducible example. Right now the cnv.* variables are missing.