lawremi / rtracklayer

R interface to genome annotation files and the UCSC genome browser
Other
27 stars 17 forks source link

error import bw file #74

Open bosmont opened 2 years ago

bosmont commented 2 years ago

Hi I am new to rtracklayer. Just install it from the github. But when I run the test code:

 test_path <- system.file("tests", package = "rtracklayer")
 test_bw <- file.path(test_path, "test.bw")
 gr <- import(test_bw)

I got the following error:

Error in stop_if_wrong_length(what, ans_len) : 
  'ranges' must have the length of the object to construct (9) or length 1

I found people posting similar problem but no good answer https://support.bioconductor.org/p/9145565/

Below is my R info:

R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so

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

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

other attached packages:
[1] devtools_2.4.4       usethis_2.1.6        rtracklayer_1.57.0   GenomicRanges_1.48.0 GenomeInfoDb_1.32.3  IRanges_2.30.1      
[7] S4Vectors_0.34.0     BiocGenerics_0.42.0 

loaded via a namespace (and not attached):
  [1] VGAM_1.1-7                  colorspace_2.0-3            PureCN_2.2.0                rjson_0.2.21                ellipsis_0.3.2             
  [6] rprojroot_2.0.3             mclust_5.4.10               DNAcopy_1.70.0              futile.logger_1.4.3         XVector_0.36.0             
 [11] fs_1.5.2                    rstudioapi_0.14             remotes_2.4.2               bit64_4.0.5                 AnnotationDbi_1.58.0       
 [16] fansi_1.0.3                 xml2_1.3.3                  codetools_0.2-18            splines_4.2.1               cachem_1.0.6               
 [21] knitr_1.40                  pkgload_1.3.0               Rsamtools_2.12.0            dbplyr_2.2.1                png_0.1-7                  
 [26] shiny_1.7.2                 compiler_4.2.1              httr_1.4.4                  assertthat_0.2.1            Matrix_1.4-1               
 [31] fastmap_1.1.0               cli_3.3.0                   later_1.3.0                 formatR_1.12                htmltools_0.5.3            
 [36] prettyunits_1.1.1           tools_4.2.1                 gtable_0.3.0                glue_1.6.2                  GenomeInfoDbData_1.2.8     
 [41] dplyr_1.0.9                 rappdirs_0.3.3              Rcpp_1.0.9                  Biobase_2.56.0              vctrs_0.4.1                
 [46] Biostrings_2.64.1           rhdf5filters_1.8.0          xfun_0.32                   stringr_1.4.1               ps_1.7.1                   
 [51] mime_0.12                   miniUI_0.1.1.1              lifecycle_1.0.1             restfulr_0.0.15             XML_3.99-0.10              
 [56] zlibbioc_1.42.0             scales_1.2.1                BSgenome_1.64.0             VariantAnnotation_1.42.1    hms_1.1.2                  
 [61] promises_1.2.0.1            MatrixGenerics_1.8.1        parallel_4.2.1              SummarizedExperiment_1.26.1 rhdf5_2.40.0               
 [66] lambda.r_1.2.4              RColorBrewer_1.1-3          yaml_2.3.5                  curl_4.3.2                  memoise_2.0.1              
 [71] gridExtra_2.3               ggplot2_3.3.6               biomaRt_2.52.0              stringi_1.7.8               RSQLite_2.2.16             
 [76] BiocIO_1.6.0                GenomicFeatures_1.48.3      filelock_1.0.2              pkgbuild_1.3.1              BiocParallel_1.30.3        
 [81] rlang_1.0.4                 pkgconfig_2.0.3             matrixStats_0.62.0          bitops_1.0-7                evaluate_0.16              
 [86] lattice_0.20-45             purrr_0.3.4                 Rhdf5lib_1.18.2             htmlwidgets_1.5.4           GenomicAlignments_1.32.1   
 [91] bit_4.0.4                   tidyselect_1.1.2            processx_3.7.0              magrittr_2.0.3              R6_2.5.1                   
 [96] profvis_0.3.7               generics_0.1.3              DelayedArray_0.22.0         DBI_1.1.3                   withr_2.5.0                
[101] pillar_1.8.1                KEGGREST_1.36.3             RCurl_1.98-1.8              tibble_3.1.8                crayon_1.5.1               
[106] futile.options_1.0.1        utf8_1.2.2                  BiocFileCache_2.4.0         urlchecker_1.0.1            rmarkdown_2.16             
[111] progress_1.2.2              grid_4.2.1                  data.table_1.14.2           blob_1.2.3                  callr_3.7.2                
[116] digest_0.6.29               xtable_1.8-4                httpuv_1.6.5                munsell_0.5.0               sessioninfo_1.2.2    

Thanks in advance for your help.

Best

bosmont commented 2 years ago

Forgot to mention, I am running the above command in my linux box in Rstudio

lawremi commented 1 year ago

Please install the version from Bioconductor using BiocManager, which will also help you update all of your packages. If you still get the error, then please post a stack trace to help us figure this out.

qouoq commented 1 year ago

Hey @lawremi, I sent the original post in support.bioconductor.org mentioned above, but let it rest in the meantime.

Here are the details with an up-to-date R 4.2.2, Bioconductor 3.16, rtracklayer 1.58.0, running the first import.bw example:

import.bw call ```R library('rtracklayer') test_path <- system.file("tests", package = "rtracklayer") test_bw <- file.path(test_path, "test.bw") import.bw(test_bw) ``` Output: ``` Loading required package: GenomicRanges Loading required package: stats4 Loading required package: BiocGenerics Attaching package: ‘BiocGenerics’ The following objects are masked from ‘package:stats’: IQR, mad, sd, var, xtabs The following objects are masked from ‘package:base’: anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep, grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank, rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply, union, unique, unsplit, which.max, which.min Loading required package: S4Vectors Attaching package: ‘S4Vectors’ The following objects are masked from ‘package:base’: expand.grid, I, unname Loading required package: IRanges Loading required package: GenomeInfoDb Error in stop_if_wrong_length(what, ans_len) : 'ranges' must have the length of the object to construct (9) or length 1 ```
traceback() ``` 11: stop(wmsg(what, " must have the length of the object ", "to construct (", ans_len, ") or length 1")) 10: stop_if_wrong_length(what, ans_len) 9: new_GRanges("GRanges", seqnames = seqnames, ranges = ranges, strand = strand, mcols = mcols, seqinfo = seqinfo) 8: GRanges(rep(seqnames(which), nhits), C_ans[[1L]], seqinfo = si) 7: .local(con, format, text, ...) 6: import(FileForFormat(con, format), ...) 5: import(FileForFormat(con, format), ...) 4: import(con, "BigWig", ...) 3: import(con, "BigWig", ...) 2: import.bw(test_bw) 1: import.bw(test_bw) ```
sessionInfo() ``` R version 4.2.2 (2022-10-31) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Arch Linux Matrix products: default BLAS: /usr/lib/libblas.so.3.11.0 LAPACK: /usr/lib/liblapack.so.3.11.0 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats4 stats graphics grDevices utils datasets methods base other attached packages: [1] rtracklayer_1.58.0 GenomicRanges_1.50.2 GenomeInfoDb_1.34.6 IRanges_2.32.0 S4Vectors_0.36.1 [6] BiocGenerics_0.44.0 colorout_1.2-2 loaded via a namespace (and not attached): [1] XVector_0.38.0 zlibbioc_1.44.0 GenomicAlignments_1.34.0 BiocParallel_1.32.5 [5] lattice_0.20-45 rjson_0.2.21 tools_4.2.2 grid_4.2.2 [9] SummarizedExperiment_1.28.0 parallel_4.2.2 Biobase_2.58.0 matrixStats_0.63.0 [13] yaml_2.3.6 crayon_1.5.2 BiocIO_1.8.0 Matrix_1.5-3 [17] GenomeInfoDbData_1.2.9 restfulr_0.0.15 bitops_1.0-7 codetools_0.2-18 [21] RCurl_1.98-1.9 DelayedArray_0.24.0 compiler_4.2.2 MatrixGenerics_1.10.0 [25] Biostrings_2.66.0 Rsamtools_2.14.0 XML_3.99-0.13 ```

The other tests run without problem:

rtracklayer:::.test() ``` Attaching package: ‘BiocGenerics’ The following objects are masked from ‘package:stats’: IQR, mad, sd, var, xtabs The following objects are masked from ‘package:base’: anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep, grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank, rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply, union, unique, unsplit, which.max, which.min Attaching package: ‘S4Vectors’ The following objects are masked from ‘package:base’: expand.grid, I, unname Attaching package: ‘Biostrings’ The following object is masked from ‘package:base’: strsplit Timing stopped at: 0.056 0 0.057 Error in stop_if_wrong_length(what, ans_len) : 'ranges' must have the length of the object to construct (9) or length 1 In addition: Warning messages: 1: Use BiocIO::FileForFormat 2: Use BiocIO::FileForFormat Warning in readGFF(filepath, version = version, filter = filter) : connection is not positioned at the start of the file, rewinding it Warning in readGFF(filepath, version = version, filter = filter) : connection is not positioned at the start of the file, rewinding it Warning in readGFF(filepath, version = version, filter = filter) : connection is not positioned at the start of the file, rewinding it For efficiency, consider converting this WIG file to a BigWig file; see ?wigToBigWig RUNIT TEST PROTOCOL -- Fri Jan 20 01:32:59 2023 *********************************************** Number of test functions: 11 Number of errors: 1 Number of failures: 0 1 Test Suite : rtracklayer RUnit Tests - 11 test functions, 1 error, 0 failures ERROR in test_bw: Error in stop_if_wrong_length(what, ans_len) : 'ranges' must have the length of the object to construct (9) or length 1 Test files with failing tests test_bw.R test_bw Error in BiocGenerics:::testPackage("rtracklayer") : unit tests failed for package rtracklayer In addition: There were 14 warnings (use warnings() to see them) ```