Question: (Closed) Any way coercing simple "list" to S4 "List" objects in R (with reproducible example)?
0
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

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/

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

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!