Question: invalid class GRanges object: 1: 'x@seqnames' is not parallel to 'x
1
gravatar for rqmm9rrsd690
5 months ago by
rqmm9rrsd69010
rqmm9rrsd69010 wrote:

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 • 382 views
ADD COMMENTlink modified 5 months ago by hauken_heyken60 • written 5 months ago by rqmm9rrsd69010
Answer: invalid class GRanges object: 1: 'x@seqnames' is not parallel to 'x
2
gravatar for hauken_heyken
5 months ago by
hauken_heyken60 wrote:

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 COMMENTlink modified 5 months ago • written 5 months ago by hauken_heyken60

Thanks, very helpful! :-)

ADD REPLYlink written 4 months ago by z.shaik0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 279 users visited in the last hour