Go back to GRanges used as RaggedExperiment input
1
0
Entering edit mode
@vinicius-henrique-da-silva-6713
Last seen 10 months ago
Brazil

I am trying to get back to the input objects of a RaggedExperiment object. Using the example in the manual:

sample1 <- GRanges(
    c(A = "chr1:1-10:-", B = "chr1:8-14:+", C = "chr2:15-18:+"),
    score = 3:5)
sample2 <- GRanges(
    c(D = "chr1:1-10:-", E = "chr2:11-18:+"),
    score = 1:2)

colDat <- DataFrame(id = 1:2)

ragexp <- RaggedExperiment(sample1 = sample1,
                           sample2 = sample2,
                           colData = colDat)

Let's assume that I only have the ragexp object to explore. Therefore, I want to get a GRange list of containing sample1 and sample2 ranges. Thus, my intended output is:

output <- GRangesList(sample1, sample2)
names(output) <- c("sample1", "sample2")

Is there a function in the RaggedExperiment package to directly generate a similar output?

RaggedExperiment • 777 views
ADD COMMENT
2
Entering edit mode
@marcel-ramos-7325
Last seen 4 days ago
United States

Hi Vinicius!

The RaggedExperiment class is designed to facilitate matrix-like representation of ragged ranges from a GRangesList such as:

> assay(ragexp)
  sample1 sample2
A       3      NA
B       4      NA
C       5      NA
D      NA       1
E      NA       2

Because the class is based of a GRangesList representation, you can access the ranged data using:

> rowRanges(ragexp)
GRanges object with 5 ranges and 0 metadata columns:
    seqnames    ranges strand
       <Rle> <IRanges>  <Rle>
  A     chr1      1-10      -
  B     chr1      8-14      +
  C     chr2     15-18      +
  D     chr1      1-10      -
  E     chr2     11-18      +
  -------
  seqinfo: 2 sequences from an unspecified genome; no seqlengths

If you are only interested in the original GRangesList, you can use our coercion function:

> as(ragexp, "GRangesList")
GRangesList object of length 2:
$sample1 
GRanges object with 3 ranges and 1 metadata column:
    seqnames    ranges strand |     score
       <Rle> <IRanges>  <Rle> | <integer>
  A     chr1      1-10      - |         3
  B     chr1      8-14      + |         4
  C     chr2     15-18      + |         5

$sample2 
GRanges object with 2 ranges and 1 metadata column:
    seqnames ranges strand | score
  D     chr1   1-10      - |     1
  E     chr2  11-18      + |     2

-------
seqinfo: 2 sequences from an unspecified genome; no seqlengths

Best, Marcel

ADD COMMENT

Login before adding your answer.

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