RStudio vs R: using rtracklayer to import bigwig files from http works in R but not in RStudio.
0
0
Entering edit mode
Søren • 0
@sren-24265
Last seen 4.0 years ago

I have used RStudio for several years and it has worked flawlessly, but recently I stumbled upon the following problem:

I use the package 'rtracklayer' to load and manipulate bigwig files. These files are generally large and they are stored on a ftp-server, such that all members of our group can access them easily.

After updating computer (MacBook Pro), OS (macOS Catalina 10.15.7), R (4.0.3) and RStudio (1.3.1093), I now cannot use rtracklayer to import bigwig files from http. It is, however, still possible to do from R (which is the same R used by RStudio). Both programs can do the import with local bigwig files.

What am I missing here?

I include an example that should be generally accessible below.

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("rtracklayer")

library(rtracklayer)

bw = import.bw('http://people.binf.ku.dk/~bwp982/RNAseq_Claudia/01_Ars2-tot-1-repplus.bw')

I get the following error message in RStudio:

Error in seqinfo(ranges) : UCSC library operation failed
In addition: Warning message:
In seqinfo(ranges) :
  unable to parse last-modified string [Tue, 31 May 2016 09:25:30 GMT]

whereas R imports the bigwig as a GRanges object that looks like this:

GRanges object with 13309471 ranges and 1 metadata column:
             seqnames            ranges strand |     score
                <Rle>         <IRanges>  <Rle> | <numeric>
         [1]     chr1       11295-11304      * |  0.041125
         [2]     chr1       11305-11382      * |  0.082250
         [3]     chr1       11383-11392      * |  0.041125
         [4]     chr1       14770-14819      * |  0.041125
         [5]     chr1       14820-14857      * |  0.082250
         ...      ...               ...    ... .       ...
  [13309467]     chrY 28561260-28561276      * |  0.041125
  [13309468]     chrY 28577864-28577894      * |  0.041125
  [13309469]     chrY 28577895-28577940      * |  0.082250
  [13309470]     chrY 59033830-59033917      * |  0.041125
  [13309471]     chrY 59120015-59120102      * |  0.041125
  -------
  seqinfo: 24 sequences from an unspecified genome

Traceback of the error in RStudio:

traceback()
12: seqinfo(ranges)
11: seqinfo(ranges)
10: BigWigSelection(which, ...)
9: .class1(object)
8: as(selection, "BigWigSelection")
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("http://people.binf.ku.dk/~bwp982/RNAseq_Claudia/01_Ars2-tot-1-repplus.bw")
1: import.bw("http://people.binf.ku.dk/~bwp982/RNAseq_Claudia/01_Ars2-tot-1-repplus.bw")

sessionInfo from RStudio:

sessionInfo( )
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

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

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

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

other attached packages:
[1] rtracklayer_1.50.0   GenomicRanges_1.42.0 GenomeInfoDb_1.26.1  IRanges_2.24.0       S4Vectors_0.28.0     BiocGenerics_0.36.0  pacman_0.5.1        

loaded via a namespace (and not attached):
 [1] XVector_0.30.0              zlibbioc_1.36.0             GenomicAlignments_1.26.0    BiocParallel_1.24.1         lattice_0.20-41            
 [6] tools_4.0.3                 grid_4.0.3                  SummarizedExperiment_1.20.0 Biobase_2.50.0              matrixStats_0.57.0         
[11] crayon_1.3.4                Matrix_1.2-18               GenomeInfoDbData_1.2.4      BiocManager_1.30.10         bitops_1.0-6               
[16] RCurl_1.98-1.2              DelayedArray_0.16.0         compiler_4.0.3              MatrixGenerics_1.2.0        Biostrings_2.58.0          
[21] Rsamtools_2.6.0             XML_3.99-0.5

sessionInfo from R:

R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] C

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

other attached packages:
[1] rtracklayer_1.50.0   GenomicRanges_1.42.0 GenomeInfoDb_1.26.1  IRanges_2.24.0       S4Vectors_0.28.0     BiocGenerics_0.36.0  pacman_0.5.1        

loaded via a namespace (and not attached):
 [1] XVector_0.30.0              zlibbioc_1.36.0             GenomicAlignments_1.26.0    BiocParallel_1.24.1         lattice_0.20-41             tools_4.0.3                 SummarizedExperiment_1.20.0 grid_4.0.3                  Biobase_2.50.0             
[10] matrixStats_0.57.0          crayon_1.3.4                Matrix_1.2-18               GenomeInfoDbData_1.2.4      bitops_1.0-6                RCurl_1.98-1.2              DelayedArray_0.16.0         compiler_4.0.3              MatrixGenerics_1.2.0       
[19] Biostrings_2.58.0           Rsamtools_2.6.0             XML_3.99-0.5
import.bw rtracklayer http RStudio • 5.1k views
ADD COMMENT
1
Entering edit mode

Not sure how, but I think that to download data R uses the locales variables available. In your Rstudio session information you don't have anything. Perhaps this is the root cause. Try to set them or find how did you end up without locales.

ADD REPLY
0
Entering edit mode

That did it. So simple. Thank you very much!

Sys.setlocale(locale="C")
ADD REPLY
0
Entering edit mode

Now that I re-read the question I am surprised that using just locale C works (I confused which sessionInfo was from which setting). I would expect you needed to specify UTF-8 locales or something alike. Anyway, great to hear that it works!

ADD REPLY
0
Entering edit mode

So is this a bug in rtracklayer (it assumes local == C, or at least not da_DK.UTF-8)? If so maybe this should be reported as an issue on https://github.com/lawremi/rtracklayer. (Nice catch, Lluís!)

ADD REPLY
0
Entering edit mode

Yea, strptime() is locale dependent, while HTTP obviously is not. This is an issue in the Kent library. Easy to fix by temporarily forcing the C locale.

ADD REPLY

Login before adding your answer.

Traffic: 1043 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6