-- edit 2022-07-26: put complete session log, add results from other examples and remove speculative bits. (I feel bad for the walls of output, but if I'm not mistaken there's no way to fold code here?)
I can't get bigWig import to work with rtracklayer
.
A full session log, using the 3 first lines of ?import.bw
examples, with traceback
and sessionInfo
:
> library("rtracklayer")
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, 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
>
> test_path <- system.file("tests", package = "rtracklayer")
> test_bw <- file.path(test_path, "test.bw")
> import.bw(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
>
> 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.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux
Matrix products: default
BLAS: /usr/lib/libblas.so.3.10.1
LAPACK: /usr/lib/liblapack.so.3.10.1
locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
[4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
[7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats4 stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] rtracklayer_1.56.1 GenomicRanges_1.48.0 GenomeInfoDb_1.32.2
[4] IRanges_2.30.0 S4Vectors_0.34.0 BiocGenerics_0.42.0
loaded via a namespace (and not attached):
[1] XVector_0.36.0 zlibbioc_1.42.0
[3] GenomicAlignments_1.32.1 BiocParallel_1.30.3
[5] lattice_0.20-45 rjson_0.2.21
[7] tools_4.2.0 grid_4.2.0
[9] SummarizedExperiment_1.26.1 parallel_4.2.0
[11] Biobase_2.56.0 matrixStats_0.62.0
[13] yaml_2.3.5 crayon_1.5.1
[15] BiocIO_1.6.0 Matrix_1.4-1
[17] GenomeInfoDbData_1.2.8 restfulr_0.0.15
[19] bitops_1.0-7 codetools_0.2-18
[21] RCurl_1.98-1.7 DelayedArray_0.22.0
[23] compiler_4.2.0 MatrixGenerics_1.8.1
[25] Biostrings_2.64.0 Rsamtools_2.12.0
[27] XML_3.99-0.10
Interestingly, the second example (from ?import.bw
) works as expected:
> which <- GRanges(c("chr2", "chr2"), IRanges(c(1, 300), c(400, 1000)))
> import(test_bw, which = which)
GRanges object with 4 ranges and 1 metadata column:
seqnames ranges strand | score
<Rle> <IRanges> <Rle> | <numeric>
[1] chr2 1-300 * | -1
[2] chr2 1-300 * | -1
[3] chr2 1-300 * | -1
[4] chr2 1-300 * | -1
-------
seqinfo: 2 sequences from an unspecified genome
While the next one raises the same error:
> mini <- narrow(unlist(tile(which, 50)), 2)
> import(test_bw, which = mini, as = "RleList")
Error in stop_if_wrong_length(what, ans_len) :
'ranges' must have the length of the object to construct (83) or length
1
The same error occurs when running the package unit tests (with rtracklayer:::.test()
) for test_bw.R
, the other tests pass:
> 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, 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.045 0.003 0.049
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 -- Tue Jul 26 02:43:41 2022
***********************************************
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)
BiocManager::valid()
for this setup returns TRUE
(BiocManager::version()
is 3.15).
I also have a setup with R 4.2.1 and Bioconductor 3.16 which behaves the same as above.
Yes, the very three first lines (from
?import.bw
) you show do fail on my setup:As do the unit tests (only test_bw fails, the other 10 tests pass):
Ah, that's interesting, if I go with the next two lines of
?import.bw
, which provide awhich
argument, it works:What do you get if you do
Same as you get:
The unit tests work for me.
And here's my sessionInfo(). What you presented above was not after loading
rtracklayer
, so please provide the results after loading relevant packages.Sorry for not having been careful with the guidelines, I've been behaving like a newbie here, and thanks for your patience!
I've edited the initial post so as to put (hopefully) the proper relevant elements.
Hi I have got the exact problem. Mine worked under R4.0 but has the same as yours under R 4.2. How did you end up dealing with this?
Hi, I have the exact same problem on R 4.2. However, everything works under R 4.0. I posted my code below.
And my sessionInfo()