The support.bioconductor.org editor has been updated to markdown! Please see more info at: Tutorial: Updated Support Site Editor

Question: From RleList to RleArray
2
gravatar for davide risso
15 months ago by
davide risso810
Weill Cornell Medicine
davide risso810 wrote:

Hi all,

is there a way to transform an RleList (or a list of Rle's) into a RleArray / RleMatrix?

My use case is that I have a loop / lapply that returns a list of Rle objects that I would like to store as a RleMatrix (each column as an Rle).

Minimal example:

x <- Rle(10:1, 1:10)
rl <- RleList(x, x)

Ideally, something like

rm <- RleArray(rl, dim=c(length(x), length(r1))

or

rm <- as(rl, "RleArray")

The more realistic (but not reproducible at this moment example):

idx <- c(50, 100)
rleBinCovList <- lapply(idx, function(win) {
        runsum(chrCovRle, k=win, endrule="constant")
    })

Or perhaps is there a way to create directly a RleArray?

Thanks! Davide

rle rlelist delayedarray • 448 views
ADD COMMENTlink modified 15 months ago by Peter Hickey440 • written 15 months ago by davide risso810
Answer: From RleList to RleArray
4
gravatar for Peter Hickey
15 months ago by
Peter Hickey440
Walter and Eliza Hall Institute of Medical Research, Melbourne, Australia
Peter Hickey440 wrote:

rm <- RleArray(unlist(rl), c(lengths(rl)[1], length(rl))) will give you what you want (the unlist() is cheap because of how an RleList is defined). With some checks added, this could become the as(rl, "RleArray") method.

ADD COMMENTlink written 15 months ago by Peter Hickey440

Thanks Pete!

I knew you could help! I almost just wrote directly to you ;)

ADD REPLYlink written 15 months ago by davide risso810
1

Will try to write a PR to add this to DelayedArray over the next few days

ADD REPLYlink written 15 months ago by Peter Hickey440

Thanks for the PR Pete. I just merged it.  H.

ADD REPLYlink written 15 months ago by Hervé Pagès ♦♦ 13k
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: 332 users visited in the last hour