Question: Go back to GRanges used as RaggedExperiment input
0
gravatar for Vinicius Henrique da Silva
9 months ago by
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 • 198 views
ADD COMMENTlink modified 9 months ago by Marcel Ramos ♦♦ 410 • written 9 months ago by Vinicius Henrique da Silva40
Answer: Go back to GRanges used as RaggedExperiment input
2
gravatar for Marcel Ramos
9 months ago by
Marcel Ramos ♦♦ 410
United States
Marcel Ramos ♦♦ 410 wrote:

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 COMMENTlink written 9 months ago by Marcel Ramos ♦♦ 410
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: 230 users visited in the last hour