Bioconductor / RaggedExperiment

Matrix-like representations of mutation and CN data
https://bioconductor.org/packages/RaggedExperiment
4 stars 3 forks source link

How to extract GRanges? #2

Closed lwaldron closed 7 years ago

lwaldron commented 7 years ago

I can't see any way to get at individual GRanges:

> example("RaggedExperiment")
> grl[[1]]
GRanges object with 2 ranges and 1 metadata column:
    seqnames    ranges strand |     score
       <Rle> <IRanges>  <Rle> | <integer>
  a     chr1  [ 1, 10]      - |         1
  b     chr1  [11, 18]      + |         2
  -------
  seqinfo: 2 sequences from an unspecified genome; no seqlengths
> grl$sample1
GRanges object with 2 ranges and 1 metadata column:
    seqnames    ranges strand |     score
       <Rle> <IRanges>  <Rle> | <integer>
  a     chr1  [ 1, 10]      - |         1
  b     chr1  [11, 18]      + |         2
  -------
  seqinfo: 2 sequences from an unspecified genome; no seqlengths
> re3[[1]]
Error in re3[[1]] : this S4 class is not subsettable
> re3$sample1
Error in re3$sample1 : $ operator not defined for this S4 class
> 
LiNk-NY commented 7 years ago

Hi Levi, @lwaldron The internal representation of the object is a GRangesList but the only way to get at the GRanges from the user level is via rowRanges. This will pool the ranges across all samples.

example("RaggedExperiment")
rowRanges(re3)
LiNk-NY commented 7 years ago

Update: you can now convert to GRangesList if necessary.

as(re3, "GRangesList")