invalid class GRanges object: 1: 'x@seqnames' is not parallel to 'x
1
1
Entering edit mode
rqmm9rrsd690 ▴ 10
@rqmm9rrsd690-20372
Last seen 5.7 years ago

This simple code:

library(GenomicRanges)

GRanges(c("chr1", "chr1", "chr1"), c(109810200, 109810201, 109810544))

fails with rather cryptic exception:

> Error in validObject(.Object) : invalid class “GRanges” object: 1:
> 'x@seqnames' is not parallel to 'x' invalid class “GRanges” object: 2:
> 'x@strand' is not parallel to 'x'

Additionally when I try to provide seqlengths:

GRanges(
  c("chr1", "chr1", "chr1"), 
  c(109810200, 109810201, 109810544),
  seqlengths=c(1, 1, 1))

I get:

>    Error in .normargSeqlengths(seqlengths, seqnames) : length of supplied 'seqlengths' must equal the number of sequences

which suggests that some data is dropped in the process. But I cannot figure out why it happens.

I'd be grateful for any insights into what's going on here.

Environment:

> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux buster/sid

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] 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   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] GenomicRanges_1.34.0 GenomeInfoDb_1.18.2  IRanges_2.16.0      
[4] S4Vectors_0.20.1     BiocGenerics_0.28.0 

loaded via a namespace (and not attached):
[1] zlibbioc_1.28.0        compiler_3.5.2         XVector_0.22.0        
[4] GenomeInfoDbData_1.2.0 RCurl_1.95-4.12        bitops_1.0-6
genomicranges • 2.3k views
ADD COMMENT
2
Entering edit mode
@hauken_heyken-13992
Last seen 2.2 years ago
Bergen

Funny thing is that if you switch the second number by +1, it works: Try:

GRanges(c("chr1", "chr1", "chr1"), c(109810200, 109810202, 109810544)) # 202, instead of 201

If you write ?GRanges, you see the ranges argument if defined as:

IRanges, or single integer range, where integer values next to each other are merged. i.g c(1,2,3), is one range from 1 to 3

To fix your statement do:

GRanges(seqnames = "chr1", ranges =  IRanges(c(109810200, 109810201, 109810544), width = 1))

One funny thing with GRanges is that if you give this:

GRanges(seqnames = "chr1", ranges =  IRanges(c(1,2,3), width = 1))

You get:

GRanges object with 3 ranges and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1         1      *
  [2]     chr1         2      *
  [3]     chr1         3      *
  -------

But if you give this:

GRanges(seqnames = "chr1", ranges =  c(1,2,3))

GRanges object with 1 range and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1       1-3      *
  -------

And even cooler I would say, this:

GRanges(seqnames = "chr1", ranges =  c(1,2,3, 5))

Gives you:

GRanges object with 2 ranges and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1       1-3      *
  [2]     chr1         5      *
  -------
ADD COMMENT
0
Entering edit mode

Thanks, very helpful! :-)

ADD REPLY

Login before adding your answer.

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