Bioconductor / GenomicRanges

Representation and manipulation of genomic intervals
https://bioconductor.org/packages/GenomicRanges
41 stars 17 forks source link

Easy access to inner metadata of a GRangesList #6

Open LTLA opened 6 years ago

LTLA commented 6 years ago

I was playing around with the grl GRangesList object from example(GRangesList), and it wasn't clear to me how to access the inner metadata. The best I could find was:

relist(unlist(grl)$score, grl)

... which does what I want (extracting the metadata while it is still grouped by the grl) but was not particularly obvious to me. I'm surprised that there is no inner.mcols function, or an inner=TRUE argument to mcols, or something more convenient, given that accessing inner metadata seems like a fairly common operation. Of course, it's entirely possible that I've just missed it.

lawremi commented 6 years ago

You did miss it:

mcols(grl, level="within")

I guess the real issue is that it's so hard to find...

LTLA commented 6 years ago

Thanks Mike, mcols(grl, level="within")[,"score"] gets me what I want.

That was... very well hidden, ?GRangesList doesn't give any hint about it.

hpages commented 6 years ago

Is this actually documented somewhere? Can't find it (except by looking at the code in R/GRangesList-class.R. I think this has been around for at least 8 years or more. BTW the names chosen to refer to the outer and inner mcols ("between" and "within", respectively) are not intuitive. Also there is no reason why only GRangesList and GAlignmentsList objects would support this. So I'm going to revisit this a little bit.

lawremi commented 6 years ago

@hpages OK, I thought it was your thing. I guess it was Patrick's. I found it by accident a couple years ago.

hpages commented 6 years ago

@lawremi Since we got your attention here, can you please take a look at https://github.com/Bioconductor/S4Vectors/issues/10 ? Thanks!

mtmorgan commented 6 years ago

Is this issue ready to be closed?

hpages commented 4 years ago

Not sure why this was closed.