Question: (Closed) Any way coercing simple "list" to S4 "List" objects in R (with reproducible example)?
0
gravatar for Jurat Shahidin
4.4 years ago by
Chicago, IL, USA
Jurat Shahidin80 wrote:

Hi everyone: Is there any way to coerce simple list-like object to S4 "List" objects? I need to do some vectorization on my data. Apparently, I used nested-lapply on my functions, and I checked its return type as "list". I want "List" like objects. How can I do that? Thanks.

Here is the reproducible example to clarify the issue:

data

foo <- GRanges(
  seqnames=Rle(c("chr1", "chr2", "chr3", "chr4"), c(3, 2, 1, 2)),
  ranges=IRanges(seq(1, by=9, len=8), seq(7, by=9, len=8)),
  rangeName=letters[seq(1:8)], score=sample(1:20, 8, replace = FALSE))

bar <- GRanges(
  seqnames=Rle(c("chr1", "chr2", "chr3","chr4"), c(4, 3, 1, 1)),
  ranges=IRanges(seq(2, by=5, len=9), seq(4, by=5, len=9)),
  rangeName=letters[seq(1:9)], score=sample(1:20, 9, replace = FALSE))

moo <- GRanges(
  seqnames=Rle(c("chr1", "chr2", "chr3","chr4"), c(3, 4, 2,1)),
  ranges=IRanges(seq(5, by=7, len=10), seq(8, by=7, len=10)),
  rangeName=letters[seq(1:10)], score=sample(1:20, 10, replace = FALSE))

I need let res_rm_multi_overlap as S4 "List" objects? Is that possible to do such coercion in R ? Any possible approach, solution, or idea are appreciated. Thanks

Best regards: Jurat

ADD COMMENTlink modified 4.0 years ago • written 4.4 years ago by Jurat Shahidin80
1

I recommend you this course on Bioconductor. There are a few videos about S4 classes towards the end, but while you are at it, you should go through the whole course: http://kasperdanielhansen.github.io/genbioconductor/

ADD REPLYlink written 4.4 years ago by Giovanni M Dall'Olio27k

Why exactly do you want the results as an S4 object? What do you need to do with the results that requires that?

ADD REPLYlink written 4.4 years ago by Devon Ryan97k

Hello Jurat Shahidin!

We believe that this post does not fit the main topic of this site.

No longer relevant.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

ADD REPLYlink written 4.0 years ago by Michael Dondrup48k
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1011 users visited in the last hour