Dear bioc-sig-sequencing list,

For several steps in our pipeline we've been saving GRanges objects into
Rdata files, load them later, and move on. Everything has been smooth so
far, yet with the new R Release and hence new GenomicRanges there is a
problem related to the print or show methods in GRanges objects.

The error is related to the new 'seqinfo' part of GRanges objects. The help
page for seqinfo didn't help us find out if there is a way to make 'old'
GRanges objects print correctly with the new GenomicRanges package.

With small GRanges objects, R prints an error after printing the head of the
GRanges object. With longer GRanges objects, only the error is printed. My
guess is that this is related to the show method for GRanges objects.

Ideally for us, 'old' GRanges objects should still print correctly with the
new GenomicRanges without having to modify them.

Thank you and greetings,
Leonardo


Case 1: small GRanges

Part 1: creating the object in an older version of R (in this case from
Ubuntu). The GRanges is the one from the first example of the GenomicRanges
vignette.

> library(GenomicRanges)
Loading required package: IRanges

Attaching package: 'IRanges'

The following object(s) are masked from 'package:base':

    cbind, eval, Map, mapply, order, paste, pmax, pmax.int, pmin,
    pmin.int, rbind, rep.int, table

> gr <- GRanges(seqnames =
+           Rle(c("chr1", "chr2", "chr1", "chr3"), c(1, 3, 2, 4)),
+           ranges =
+           IRanges(1:10, end = 7:16, names = head(letters, 10)),
+           strand =
+           Rle(strand(c("-", "+", "*", "+", "-")),
+               c(1, 2, 2, 3, 2)),
+           score = 1:10,
+           GC = seq(1, 0, length=10))
> gr
GRanges with 10 ranges and 2 elementMetadata values
  seqnames    ranges strand |     score        GC
     <Rle> <IRanges>  <Rle> | <integer> <numeric>
a     chr1  [ 1,  7]      - |         1 1.0000000
b     chr2  [ 2,  8]      + |         2 0.8888889
c     chr2  [ 3,  9]      + |         3 0.7777778
d     chr2  [ 4, 10]      * |         4 0.6666667
e     chr1  [ 5, 11]      * |         5 0.5555556
f     chr1  [ 6, 12]      + |         6 0.4444444
g     chr3  [ 7, 13]      + |         7 0.3333333
h     chr3  [ 8, 14]      + |         8 0.2222222
i     chr3  [ 9, 15]      - |         9 0.1111111
j     chr3  [10, 16]      - |        10 0.0000000

seqlengths
 chr1 chr2 chr3
   NA   NA   NA
> save(gr, file="gr.Rdata")
> sessionInfo()
R version 2.12.0 Under development (unstable) (2010-09-08 r52880)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
 [3] LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8
 [5] LC_MONETARY=C             LC_MESSAGES=en_US.utf8
 [7] LC_PAPER=en_US.utf8       LC_NAME=C
 [9] LC_ADDRESS=C              LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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

other attached packages:
[1] GenomicRanges_1.1.25 IRanges_1.7.34
>

Part 2:
Loading the GRanges object with R 2.11.1 (in this case from Windows). In
this case everything works fine :)

> load("gr.Rdata")
> gr
GRanges with 10 ranges and 2 elementMetadata values
  seqnames    ranges strand |     score        GC
     <Rle> <IRanges>  <Rle> | <integer> <numeric>
a     chr1  [ 1,  7]      - |         1 1.0000000
b     chr2  [ 2,  8]      + |         2 0.8888889
c     chr2  [ 3,  9]      + |         3 0.7777778
d     chr2  [ 4, 10]      * |         4 0.6666667
e     chr1  [ 5, 11]      * |         5 0.5555556
f     chr1  [ 6, 12]      + |         6 0.4444444
g     chr3  [ 7, 13]      + |         7 0.3333333
h     chr3  [ 8, 14]      + |         8 0.2222222
i     chr3  [ 9, 15]      - |         9 0.1111111
j     chr3  [10, 16]      - |        10 0.0000000

seqlengths
 chr1 chr2 chr3
   NA   NA   NA
> sessionInfo()
R version 2.11.1 (2010-05-31)
x86_64-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] GenomicRanges_1.0.6 IRanges_1.6.8
>


Part 3:
Loading the GRanges object into the new R (2.12.0) pops an error:

> library(GenomicRanges)
Loading required package: IRanges

Attaching package: 'IRanges'

The following object(s) are masked from 'package:base':

    cbind, eval, Map, mapply, order, paste, pmax, pmax.int, pmin,
    pmin.int, rbind, rep.int, table

> load("gr.Rdata")
> gr
GRanges with 10 ranges and 2 elementMetadata values
  seqnames    ranges strand |     score        GC
     <Rle> <IRanges>  <Rle> | <integer> <numeric>
a     chr1  [ 1,  7]      - |         1 1.0000000
b     chr2  [ 2,  8]      + |         2 0.8888889
c     chr2  [ 3,  9]      + |         3 0.7777778
d     chr2  [ 4, 10]      * |         4 0.6666667
e     chr1  [ 5, 11]      * |         5 0.5555556
f     chr1  [ 6, 12]      + |         6 0.4444444
g     chr3  [ 7, 13]      + |         7 0.3333333
h     chr3  [ 8, 14]      + |         8 0.2222222
i     chr3  [ 9, 15]      - |         9 0.1111111
j     chr3  [10, 16]      - |        10 0.0000000
Error in seqlengths(seqinfo(x)) :
  error in evaluating the argument 'x' in selecting a method for function
'seqlengths'
> sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] GenomicRanges_1.2.0 IRanges_1.8.0
>





Case 2: long GRanges object (longer 21 ranges)

Part 1: Creating the GRanges object in R 2.11.1

> library(GenomicRanges)
Loading required package: IRanges

Attaching package: 'IRanges'

The following object(s) are masked from 'package:base':

    cbind, Map, mapply, order, paste, pmax, pmax.int, pmin, pmin.int,
    rbind, rep.int, table

> longGR <- GRanges(seqnames=rep("chr", 100), ranges=IRanges(start=1:101,
width=10), strand=rep("*", 100))
Error in validObject(.Object) :
  invalid class "GRanges" object: slot lengths are not all equal
> length(1:101)
[1] 101
> longGR <- GRanges(seqnames=rep("chr", 100), ranges=IRanges(start=1:100,
width=10), strand=rep("*", 100))
>
>
> save(longGR, file="longGR.Rdata")
> sessionInfo()
R version 2.11.1 (2010-05-31)
x86_64-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] GenomicRanges_1.0.6 IRanges_1.6.8
>


Part 2: loading the file in R 2.12.0 pops an error:

> load("longGR.Rdata")
> longGR
GRanges with 100 ranges and 0 elementMetadata values
Error in validObject(.Object) :
  invalid class "GRanges" object: slots in class definition but not in
object: "seqinfo"
> sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] GenomicRanges_1.2.0 IRanges_1.8.0
>

	[[alternative HTML version deleted]]

