A Problem about seqnames() in GenomicRanges
0
0
Entering edit mode
@shangguandong1996-21805
Last seen 17 months ago
China

I come up with a problem when I run the function in the "An Introduction to the GenomicRanges Package"。

> library(GenomicRanges)
> gr1 <- GRanges(
+   seqnames = "chr2",
+   ranges = IRanges(103, 106),
+   strand = "+",
+   score = 5L, GC = 0.45)
> gr2 <- GRanges(
+   seqnames = c("chr1", "chr1"),
+   ranges = IRanges(c(107, 113), width = 3),
+   strand = c("+", "-"),
+   score = 3:4, GC = c(0.3, 0.5))
> grl <- GRangesList("txA" = gr1, "txB" = gr2)
> seqnames(grl)
RleList of length 2
$txA
factor-Rle of length 1 with 1 run
Error in nchar(str[ind]) : invalid multibyte string, element 1

I run again in another PC with same GenomicRanges version, and I still meet this problem. But I run with older version, this problem disapper.

Here is my version now

> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936  LC_CTYPE=Chinese (Simplified)_China.936    LC_MONETARY=Chinese (Simplified)_China.936
[4] LC_NUMERIC=C                               LC_TIME=Chinese (Simplified)_China.936    

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

other attached packages:
[1] GenomicRanges_1.36.0 GenomeInfoDb_1.20.0  IRanges_2.18.2       S4Vectors_0.22.0     BiocGenerics_0.30.0 

loaded via a namespace (and not attached):
[1] zlibbioc_1.30.0        compiler_3.6.0         XVector_0.24.0         tools_3.6.0            GenomeInfoDbData_1.2.1 RCurl_1.95-4.12       
[7] bitops_1.0-6 

The version with no problem is GenomicRanges_1.34.0 and 1.28.6

GenomicRanges • 1.1k views
ADD COMMENT
0
Entering edit mode

I am unable to currently reproduce this. Could you try doing a BiocManager::valid() to make sure all dependent packages are up-to-date and if necessary BiocManager::install() and if it asks to update packages choose a for update all. Please try again and see if this corrects the issue, else please comment back here and we will try to investigate further.

ADD REPLY
0
Entering edit mode

Thanks for your reply. Here is my BiocManager::valid() result

> BiocManager::valid()

* sessionInfo()

R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

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

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

other attached packages:
 [1] BSgenome.Mmusculus.UCSC.mm10_1.4.0        BSgenome.Athaliana.TAIR.TAIR9_1.3.1000   
 [3] BSgenome_1.52.0                           Biostrings_2.52.0                        
 [5] XVector_0.24.0                            rtracklayer_1.44.4                       
 [7] TxDb.Athaliana.BioMart.plantsmart28_3.2.2 magrittr_1.5                             
 [9] TxDb.Mmusculus.UCSC.mm10.ensGene_3.4.0    GenomicFeatures_1.36.4                   
[11] AnnotationDbi_1.46.1                      Biobase_2.44.0                           
[13] GenomicRanges_1.36.1                      GenomeInfoDb_1.20.0                      
[15] IRanges_2.18.2                            S4Vectors_0.22.0                         
[17] BiocGenerics_0.30.0                      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.2                  compiler_3.6.0              pillar_1.4.2               
 [4] BiocManager_1.30.4          prettyunits_1.0.2           bitops_1.0-6               
 [7] tools_3.6.0                 zlibbioc_1.30.0             progress_1.2.2             
[10] zeallot_0.1.0               biomaRt_2.40.4              digest_0.6.20              
[13] bit_1.1-14                  lattice_0.20-38             RSQLite_2.1.2              
[16] memoise_1.1.0               tibble_2.1.3                pkgconfig_2.0.2            
[19] rlang_0.4.0                 Matrix_1.2-17               DelayedArray_0.10.0        
[22] DBI_1.0.0                   rstudioapi_0.10             GenomeInfoDbData_1.2.1     
[25] httr_1.4.1                  stringr_1.4.0               vctrs_0.2.0                
[28] hms_0.5.1                   grid_3.6.0                  bit64_0.9-7                
[31] R6_2.4.0                    BiocParallel_1.18.1         XML_3.98-1.20              
[34] blob_1.2.0                  matrixStats_0.55.0          GenomicAlignments_1.20.1   
[37] Rsamtools_2.0.0             backports_1.1.4             SummarizedExperiment_1.14.1
[40] assertthat_0.2.1            stringi_1.4.3               RCurl_1.95-4.12            
[43] crayon_1.3.4               

Bioconductor version '3.9'

  * 1 packages out-of-date
  * 2 packages too new

create a valid installation with

  BiocManager::install(c(
    "kableExtra", "S4Vectors", "wesanderson"
  ), update = TRUE, ask = FALSE)

more details: BiocManager::valid()$too_new, BiocManager::valid()$out_of_date

Warning message:
1 packages out-of-date; 2 packages too new 

Then I run

  BiocManager::install(c(
    "kableExtra", "S4Vectors", "wesanderson"
  ), update = TRUE, ask = FALSE)

And now

> BiocManager::valid()
[1] TRUE

ADD REPLY
0
Entering edit mode

But I still get

> library(GenomicRanges)
Loading required package: stats4
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: ‘BiocGenerics’

The following objects are masked from ‘package:parallel’:

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ, clusterExport,
    clusterMap, parApply, parCapply, parLapply, parLapplyLB, parRapply,
    parSapply, parSapplyLB

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, which.max, which.min

Loading required package: S4Vectors

Attaching package: ‘S4Vectors’

The following object is masked from ‘package:base’:

    expand.grid

Loading required package: IRanges

Attaching package: ‘IRanges’

The following object is masked from ‘package:grDevices’:

    windows

Loading required package: GenomeInfoDb
Warning messages:
1: package ‘GenomicRanges’ was built under R version 3.6.1 
2: package ‘S4Vectors’ was built under R version 3.6.1 
3: package ‘IRanges’ was built under R version 3.6.1 
> gr1 <- GRanges(
+   seqnames = "chr2",
+   ranges = IRanges(103, 106),
+   strand = "+",
+   score = 5L, GC = 0.45)
> gr2 <- GRanges(
+   seqnames = c("chr1", "chr1"),
+   ranges = IRanges(c(107, 113), width = 3),
+   strand = c("+", "-"),
+   score = 3:4, GC = c(0.3, 0.5))
> grl <- GRangesList("txA" = gr1, "txB" = gr2)
> grl
GRangesList object of length 2:
$txA 
GRanges object with 1 range and 2 metadata columns:
      seqnames    ranges strand |     score        GC
         <Rle> <IRanges>  <Rle> | <integer> <numeric>
  [1]     chr2   103-106      + |         5      0.45

$txB 
GRanges object with 2 ranges and 2 metadata columns:
      seqnames  ranges strand | score  GC
  [1]     chr1 107-109      + |     3 0.3
  [2]     chr1 113-115      - |     4 0.5

-------
seqinfo: 2 sequences from an unspecified genome; no seqlengths
> seqnames(grl)
RleList of length 2
$txA
factor-Rle of length 1 with 1 run
Error in nchar(str[ind]) : invalid multibyte string, element 1
ADD REPLY
0
Entering edit mode

Wild guess, but does

Sys.setlocale("LC_ALL","C")

help? I don't have your issue, and changing my computer to Chinese (Simplified)_China.936 didn't cause the error, but it's worth a try.

ADD REPLY
0
Entering edit mode

Cool! It does work!

> Sys.setlocale("LC_ALL","C")
[1] "C"
> library(GenomicRanges)
> gr1 <- GRanges(
+      seqnames = "chr2",
+      ranges = IRanges(103, 106),
+      strand = "+",
+      score = 5L, GC = 0.45)
> gr2 <- GRanges(
+      seqnames = c("chr1", "chr1"),
+      ranges = IRanges(c(107, 113), width = 3),
+      strand = c("+", "-"),
+      score = 3:4, GC = c(0.3, 0.5))
> grl <- GRangesList("txA" = gr1, "txB" = gr2)
> seqnames(grl)
RleList of length 2
$txA
factor-Rle of length 1 with 1 run
  Lengths:    1
  Values : chr2
Levels(2): chr2 chr1

$txB
factor-Rle of length 2 with 1 run
  Lengths:    2
  Values : chr1
Levels(2): chr2 chr1
ADD REPLY

Login before adding your answer.

Traffic: 658 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