bernatgel / karyoploteR

karyoploteR - An R/Bioconductor package to plot arbitrary data along the genome
https://bernatgel.github.io/karyoploter_tutorial/
298 stars 42 forks source link

argument "times" invalid when trying to plot genes #73

Closed lbeltrame closed 4 years ago

lbeltrame commented 4 years ago

Example code:


library(TxDb.Hsapiens.UCSC.hg38.knownGene)
library(karyoploteR)
kp <- plotKaryotype(genome="hg38", chromosomes=c("chr19"), zoom="chr19:13490001-23010000")
genes.data <- makeGenesDataFromTxDb(TxDb.Hsapiens.UCSC.hg38.knownGene, karyoplot=kp, plot.transcripts=FALSE, plot.transcripts.structure=FALSE)
genes.data <- addGeneNames(genes.data)
kpPlotGenes(kp, data=genes.data)

Result:

NOTE: Plotting many genes with detailed transcript structure may take a long time. You can set 'plot.transcripts' and 'plot.transcripts.structure' to FALSE to speed up the process reducing the detail level.
Error in rep(seq_len(NROW(x)), ...) : argument 'times' invalid
traceback()
4: extractROWS(x, rep(seq_len(NROW(x)), ...))
3: rep(genes.for.coverage, num.transcripts.per.gene)
2: rep(genes.for.coverage, num.transcripts.per.gene)
1: kpPlotGenes(kp, data = genes.data)
sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-suse-linux-gnu (64-bit)
Running under: openSUSE Tumbleweed
Matrix products: default
BLAS:   /usr/lib64/R/lib/libRblas.so
LAPACK: /usr/lib64/R/lib/libRlapack.so
locale:
 [1] LC_CTYPE=it_IT.UTF-8       LC_NUMERIC=C              
 [5] LC_MONETARY=it_IT.UTF-8    LC_MESSAGES=it_IT.UTF-8   
 [7] LC_PAPER=it_IT.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            

[1] parallel  stats4    stats     graphics  grDevices utils     datasets 

 [1] org.Hs.eg.db_3.10.0                      
 [3] GenomicFeatures_1.38.0                   
 [5] Biobase_2.46.0                           
 [7] BSgenome.Hsapiens.UCSC.hg38_1.4.1        
 [9] rtracklayer_1.46.0                       
[11] XVector_0.26.0                           
[13] karyoploteR_1.13.5                       
[15] GenomicRanges_1.38.0                     
[17] IRanges_2.20.2                           
[19] BiocGenerics_0.32.0                      

loaded via a namespace (and not attached):
 [1] ProtGenerics_1.18.0         bitops_1.0-6               
 [3] matrixStats_0.55.0          bit64_0.9-7                
 [5] RColorBrewer_1.1-2          progress_1.2.2             
 [7] httr_1.4.1                  tools_3.6.3                
 [9] backports_1.1.1             R6_2.4.1                   
[11] rpart_4.1-15                Hmisc_4.3-0                
[13] DBI_1.1.0                   lazyeval_0.2.1             
[15] colorspace_1.4-1            nnet_7.3-12                
[17] tidyselect_0.2.5            gridExtra_2.3              
[19] prettyunits_1.0.2           bit_1.1-12                 
[21] curl_4.3                    compiler_3.6.3             
[23] htmlTable_1.13.3            bezier_1.1.2               
[25] DelayedArray_0.12.2         scales_1.1.0               
[27] checkmate_1.9.4             askpass_1.1                
[29] rappdirs_0.3.1              stringr_1.4.0              
[31] digest_0.6.23               Rsamtools_2.2.1            
[33] foreign_0.8-75              dichromat_2.0-0            
[35] htmltools_0.4.0             base64enc_0.1-3            
[37] jpeg_0.1-8                  pkgconfig_2.0.2            
[39] ensembldb_2.10.2            dbplyr_1.4.2               
[41] htmlwidgets_1.2             rlang_0.4.4                
[43] rstudioapi_0.10             RSQLite_2.2.0              
[45] BiocParallel_1.20.1         acepack_1.4.1              
[47] dplyr_0.8.3                 VariantAnnotation_1.32.0   
[49] RCurl_1.95-4.11             magrittr_1.5               
[51] GenomeInfoDbData_1.2.2      Formula_1.2-3              
[53] Matrix_1.2-18               Rcpp_1.0.3                 
[55] munsell_0.5.0               bamsignals_1.18.0          
[57] lifecycle_0.1.0             stringi_1.2.4              
[59] SummarizedExperiment_1.16.1 zlibbioc_1.32.0            
[61] BiocFileCache_1.10.2        grid_3.6.3                 
[63] blob_1.2.0                  crayon_1.3.4               
[65] lattice_0.20-38             splines_3.6.3              
[67] hms_0.5.3                   knitr_1.27                 
[69] pillar_1.4.3                biomaRt_2.42.0             
[71] XML_3.98-1.9                glue_1.3.1                 
[73] biovizBase_1.34.1           latticeExtra_0.6-29        
[75] data.table_1.12.8           vctrs_0.2.2                
[77] png_0.1-7                   gtable_0.3.0               
[79] openssl_1.4.1               purrr_0.3.3                
[81] assertthat_0.2.1            ggplot2_3.2.1              
[83] xfun_0.8                    AnnotationFilter_1.10.0    
[85] survival_3.1-8              tibble_2.1.3               
[87] GenomicAlignments_1.22.1    memoise_0.2.1              
[89] cluster_2.1.0
lbeltrame commented 4 years ago

The reason is that num.transcripts.per.gene is 0, because the code looks for $transcripts in the object even if it is not there. It should be set to 1 if no transcript information is available.

lbeltrame commented 4 years ago

More in detail, plot.transcripts=TRUE (default) wants transcripts unconditionally, regardless if the object has them or not. Probably the code should error in case this happens, telling the user to use plot.transcripts=FALSE.

bernatgel commented 4 years ago

Hi Luca (@lbeltrame)

Thanks for the detailed report! I'll see what's the best option here (probably the error or defaulting to a new value "auto") and fix that.

I'll get back to you once this is done.

Bernat

PS: Obviously, if you want to contribute a Pull Request it would be more than welcome!