ggcoverage icon indicating copy to clipboard operation
ggcoverage copied to clipboard

Error when running ggcoverage() examples

Open lasi-g opened this issue 1 year ago • 16 comments

Hello, I have installed the ggcoverage and currently testing this package running ggcoverage() examples. But the problem arose when I wanted to draw an ideogram, here's the error message: Loading ideogram... Error in normArgTrack(track, trackids) : Unknown track: cytoBand cytoBand informatin is not available, only get ranges. Loading ranges... Done Error in .local(data, ...) : Need cytoband information, please check the getIdeogram function

Thank you for developing ggcoverage and providing me with a great tool for visualizing genes and variation information. I also appreciate your help in solving this problem.

Best, Yanze

lasi-g avatar Jan 13 '24 05:01 lasi-g

Can you paste here the exact code that you tried and that failed for you?

m-jahn avatar Jan 15 '24 07:01 m-jahn

Sure, and thanks for your attention. The code was constant with the manual of ggcoverage (RNA-seq data) showed in github. And here is the details: #test library("rtracklayer") library("ggcoverage") library("ggpattern")

load metadata

meta.file <- system.file("extdata", "RNA-seq", "meta_info.csv", package = "ggcoverage") sample.meta = read.csv(meta.file)

track folder

track.folder = system.file("extdata", "RNA-seq", package = "ggcoverage")

load bigwig file

track.df = LoadTrackFile(track.folder = track.folder, format = "bw", region = "chr14:21,677,306-21,737,601", extend = 2000, meta.info = sample.meta)

create mark region

mark.region=data.frame(start=c(21678900,21732001,21737590), end=c(21679900,21732400,21737650), label=c("M1", "M2", "M3")) #Load GTF gtf.file = system.file("extdata", "used_hg19.gtf", package = "ggcoverage") gtf.gr = rtracklayer::import.gff(con = gtf.file, format = 'gtf') #Basic coverage basic.coverage = ggcoverage(data = track.df, plot.type = "facet", mark.region = mark.region, range.position = "out") basic.coverage #add ideogram basic.coverage + geom_gene(gtf.gr=gtf.gr) + geom_ideogram(genome = "hg19",plot.space = 0)

Thank you

lasi-g avatar Jan 15 '24 08:01 lasi-g

I just put the example code here again in clean form. This works for me out of the box using the latest version of ggcoverage with some fixes:

library("rtracklayer")
library("ggcoverage")
library("ggpattern")

# load metadata
meta.file <- system.file("extdata", "RNA-seq", "meta_info.csv", package = "ggcoverage")
sample.meta = read.csv(meta.file)

# track folder
track.folder = system.file("extdata", "RNA-seq", package = "ggcoverage")

# load bigwig file
track.df = LoadTrackFile(track.folder = track.folder, format = "bw",
                         region = "chr14:21,677,306-21,737,601", extend = 2000,
                         meta.info = sample.meta)

# create mark region
mark.region=data.frame(start=c(21678900,21732001,21737590),
                       end=c(21679900,21732400,21737650),
                       label=c("M1", "M2", "M3"))
# load GTF
gtf.file = system.file("extdata", "used_hg19.gtf", package = "ggcoverage")
gtf.gr = rtracklayer::import.gff(con = gtf.file, format = 'gtf')

# basic coverage
basic.coverage = ggcoverage(data = track.df, plot.type = "facet",
                            mark.region = mark.region, range.position = "out")
basic.coverage

#add ideogram
basic.coverage +
  geom_gene(gtf.gr=gtf.gr) +
  geom_ideogram(genome = "hg19",plot.space = 0)

Try to install ggcoverage from my fork using:

remotes::install_github("https://github.com/m-jahn/ggcoverage", ref = "colors")

Try to install the dependencies of the package if it still fails.

Result:

image

m-jahn avatar Jan 16 '24 10:01 m-jahn

@lasi-g can be closed now?

m-jahn avatar Jan 28 '24 07:01 m-jahn

Sorry for taking so long to reply to you. I have run the code you provided above and still encounter the same problem as before. Loading ideogram... Error in normArgTrack(track, trackids) : Unknown track: cytoBand cytoBand informatin is not available, only get ranges. Loading ranges... Done Error in .local(data, ...) : Need cytoband information, please check the getIdeogram function

lasi-g avatar Feb 02 '24 15:02 lasi-g

since it works on my end with the latest package installs, the problem must be your local system: Have you re-installed ggcoverage from my fork?

remotes::install_github("https://github.com/m-jahn/ggcoverage", ref = "colors")

Have you installed all required dependencies of ggcoverage? Some of the examples require suggested packages that are not automatically installed as you are probably used to when installing a new package. If you look into the DESCRIPTION file of the package you see all dependencies:

Imports: 
    dplyr,
    GenomicRanges,
    ggbio,
    ggh4x,
    ggplot2,
    ggrepel,
    grDevices,
    IRanges,
    magrittr,
    patchwork,
    RColorBrewer,
    rlang,
    Rsamtools,
    rtracklayer,
    scales,
    stats,
    utils,
    methods,
    GenomeInfoDb,
    S4Vectors,
    Biostrings,
    BSgenome,
    GenomicAlignments,
    reshape2,
    seqinr,
    ggforce,
    HiCBricks,
    ggpattern,
    BiocParallel,
    openxlsx,
    stringr,
    ggpp
Suggests: 
    rmarkdown,
    knitr,
    BiocStyle,
    htmltools,
    BSgenome.Hsapiens.UCSC.hg19,
    graphics,
    HiCDataHumanIMR90

I know this is a long list; but try to install the Suggests and you should be good. Also, check that you are running a recent R version. I run 4.3.2.

m-jahn avatar Feb 05 '24 07:02 m-jahn

@lasi-g issue resolved?

m-jahn avatar Mar 07 '24 08:03 m-jahn

@m-jahn I cannot repeat the example on window10 too. First time, remotes::install_github("showteeth/ggcoverage"), it gives the same error.

> basic.coverage +
+   geom_gc(bs.fa.seq=BSgenome.Hsapiens.UCSC.hg19) +
+   geom_gene(gtf.gr=gtf.gr) +
+   geom_ideogram(genome = "hg19")
Loading ideogram...
Error in normArgTrack(track, trackids) : Unknown track: cytoBand
cytoBand information is not available, only getting ranges.
Loading ranges...
Done
Error in .local(data, ...) : 
  Need cytoband information, please check the getIdeogram function


Second time,

> remotes::install_github("https://github.com/m-jahn/ggcoverage", ref = "colors")
Using GitHub PAT from the git credential store.
Downloading GitHub repo m-jahn/ggcoverage@colors
Error in utils::download.file(url, path, method = method, quiet = quiet,  : 
  无法打开URL'https://api.github.com/repos/m-jahn/ggcoverage/tarball/colors'

Can you check it please ? Best, xiucz

xiucz avatar May 08 '24 10:05 xiucz

Please Install the 'Suggested' packages, These are required to run geom_ideogram().

m-jahn avatar May 08 '24 15:05 m-jahn

You find those in the DESCRIPTION File of the repo.

m-jahn avatar May 08 '24 15:05 m-jahn

> library("BiocStyle")
> library("ggbio")
> library(HiCBricks)
> library(HiCDataHumanIMR90)
> library(BSgenome.Hsapiens.UCSC.hg19)
>
> basic.coverage +
+   geom_gc(bs.fa.seq=BSgenome.Hsapiens.UCSC.hg19) +
+   geom_gene(gtf.gr=gtf.gr) +
+   geom_ideogram(genome = "hg19")
Loading ideogram...
Error in normArgTrack(track, trackids) : Unknown track: cytoBand
cytoBand information is not available, only getting ranges.
Loading ranges...
Done
Error in .local(data, ...) : 
  Need cytoband information, please check the getIdeogram function

I review the source code, geom_ideogram() use the ggbio package to get the cytoband info. However, the package was installed. https://rdrr.io/cran/ggcoverage/src/R/geom_ideogram.R#:~:text=genome.info%20%3C%2D%20suppressWarnings(getIdeogram(genome%20%3D%20genome%2C%20subchr%20%3D%20plot.chr%2C%20cytobands%20%3D%20TRUE)) Any further suggestions? thank you! Best, xiucz

xiucz avatar May 09 '24 00:05 xiucz

OK, then I can only try to reproduce the issue. Can you post the output from SessionInfo()?

m-jahn avatar May 09 '24 15:05 m-jahn

Restart my R4.3.3 on my window10 first , then

> suppressPackageStartupMessages({
    library("ggcoverage")
     library("BiocStyle")
 library("ggbio")
 library("BSgenome.Hsapiens.UCSC.hg19")
 })
> 
> SessionInfo()
Error in SessionInfo() : 没有"SessionInfo"这个函数
> sessionInfo()
R version 4.3.3 (2024-02-29 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default


locale:
[1] LC_COLLATE=Chinese (Simplified)_China.utf8 
[2] LC_CTYPE=Chinese (Simplified)_China.utf8   
[3] LC_MONETARY=Chinese (Simplified)_China.utf8
[4] LC_NUMERIC=C                               
[5] LC_TIME=Chinese (Simplified)_China.utf8    

time zone: Asia/Shanghai
tzcode source: internal

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

other attached packages:
 [1] BSgenome.Hsapiens.UCSC.hg19_1.4.3 BSgenome_1.70.2                  
 [3] rtracklayer_1.62.0                BiocIO_1.12.0                    
 [5] Biostrings_2.70.3                 XVector_0.42.0                   
 [7] GenomicRanges_1.54.1              GenomeInfoDb_1.38.8              
 [9] IRanges_2.36.0                    S4Vectors_0.40.2                 
[11] ggbio_1.50.0                      ggplot2_3.5.0                    
[13] BiocGenerics_0.48.1               BiocStyle_2.30.0                 
[15] ggcoverage_1.4.0                 

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3          rstudioapi_0.16.0          
  [3] magrittr_2.0.3              GenomicFeatures_1.54.4     
  [5] rmarkdown_2.26              zlibbioc_1.48.2            
  [7] vctrs_0.6.5                 memoise_2.0.1              
  [9] Rsamtools_2.18.0            RCurl_1.98-1.14            
 [11] base64enc_0.1-3             htmltools_0.5.8.1          
 [13] S4Arrays_1.2.1              progress_1.2.3             
 [15] curl_5.2.1                  SparseArray_1.2.4          
 [17] Formula_1.2-5               htmlwidgets_1.6.4          
 [19] plyr_1.8.9                  cachem_1.0.8               
 [21] GenomicAlignments_1.38.2    lifecycle_1.0.4            
 [23] pkgconfig_2.0.3             Matrix_1.6-5               
 [25] R6_2.5.1                    fastmap_1.1.1              
 [27] GenomeInfoDbData_1.2.11     MatrixGenerics_1.14.0      
 [29] digest_0.6.35               colorspace_2.1-0           
 [31] GGally_2.2.1                patchwork_1.2.0            
 [33] AnnotationDbi_1.64.1        OrganismDbi_1.44.0         
 [35] Hmisc_5.1-2                 RSQLite_2.3.6              
 [37] filelock_1.0.3              fansi_1.0.6                
 [39] httr_1.4.7                  abind_1.4-5                
 [41] compiler_4.3.3              bit64_4.0.5                
 [43] withr_3.0.0                 htmlTable_2.4.2            
 [45] backports_1.4.1             BiocParallel_1.36.0        
 [47] DBI_1.2.2                   ggstats_0.6.0              
 [49] biomaRt_2.58.2              rappdirs_0.3.3             
 [51] DelayedArray_0.28.0         rjson_0.2.21               
 [53] tools_4.3.3                 foreign_0.8-86             
 [55] nnet_7.3-19                 glue_1.7.0                 
 [57] restfulr_0.0.15             grid_4.3.3                 
 [59] checkmate_2.3.1             cluster_2.1.6              
 [61] reshape2_1.4.4              generics_0.1.3             
 [63] gtable_0.3.4                ggpattern_1.0.1            
 [65] tidyr_1.3.1                 ensembldb_2.26.1           
 [67] data.table_1.15.4           hms_1.1.3                  
 [69] xml2_1.3.6                  utf8_1.2.4                 
 [71] ggrepel_0.9.5               pillar_1.9.0               
 [73] stringr_1.5.1               dplyr_1.1.4                
 [75] BiocFileCache_2.10.2        lattice_0.22-5             
 [77] bit_4.0.5                   biovizBase_1.50.0          
 [79] RBGL_1.78.0                 tidyselect_1.2.1           
 [81] knitr_1.46                  gridExtra_2.3              
 [83] ProtGenerics_1.34.0         SummarizedExperiment_1.32.0
 [85] xfun_0.43                   Biobase_2.62.0             
 [87] matrixStats_1.2.0           stringi_1.8.3              
 [89] lazyeval_0.2.2              yaml_2.3.8                 
 [91] evaluate_0.23               codetools_0.2-19           
 [93] tibble_3.2.1                graph_1.80.0               
 [95] BiocManager_1.30.22         cli_3.6.2                  
 [97] rpart_4.1.23                munsell_0.5.1              
 [99] dichromat_2.0-0.1           Rcpp_1.0.12                
[101] dbplyr_2.5.0                png_0.1-8                  
[103] XML_3.99-0.16.1             parallel_4.3.3             
[105] ggh4x_0.2.8                 blob_1.2.4                 
[107] prettyunits_1.2.0           AnnotationFilter_1.26.0    
[109] bitops_1.0-7                VariantAnnotation_1.48.1   
[111] scales_1.3.0                purrr_1.0.2                
[113] crayon_1.5.2                rlang_1.1.3                
[115] KEGGREST_1.42.0            
> 

Best, xiucz

xiucz avatar May 09 '24 23:05 xiucz

I can reproduce the error. There is a problem with the rtracklayer package getting cytoband (and other other types of info) from USCS databases. Cytoband information is fetched remotely, so we need both internet access and a working API on the server side. I try to look into this but it could be a server issue on their side.

m-jahn avatar May 13 '24 08:05 m-jahn

check out the latest version from the linked repo above, it should fix the issue

remotes::install_github("https://github.com/m-jahn/ggcoverage/tree/dev")

m-jahn avatar May 13 '24 09:05 m-jahn

^_^, I thought the problem was with ggbio packages, haha. Thank you for debugging it. Downloading databases from websites every time seems to be not a very reliable choice because once the website encounters issues or a poor network, the tool will be broken.

After the rebuild, it works. Best, xiucz

xiucz avatar May 14 '24 03:05 xiucz