[BioC] looking for GRanges ggply like ddply
Steve Lianoglou
lianoglou.steve at gene.com
Fri Mar 21 20:11:35 CET 2014
On Fri, Mar 21, 2014 at 11:33 AM, Michael Lawrence
<lawrence.michael at gene.com> wrote:
> On Fri, Mar 21, 2014 at 11:05 AM, Steve Lianoglou
> <lianoglou.steve at gene.com>wrote:
>
>> Howdy,
>>
>> On Fri, Mar 21, 2014 at 9:12 AM, Michael Lawrence
>> <lawrence.michael at gene.com> wrote:
>> > Not really sure how ddply works (the "." syntax seems a bit weird) but I
>> > think you want something like:
>> >
>> > do.call(c, tapply(gr, list(gr$transcript_id, gr$type), function(tt) {
>> > }, simplify=FALSE))
>>
>> Clever -- somehow I never realized we had specialized versions of more
>> than just lapply, and mapply ... maybe it's because I've never been a
>> fan of `tapply` (I mean, what does the `t` mean, anyway?)
>>
>>
> I'm pretty sure it originates from its use in generating contingency
> /t/ables, see example(tapply).
>
>
>> Anyway, the OP's `ggply` function would be neat -- perhaps a `bioplyr`
>> package could interesting/fun for somebody whose got some time for a
>> little yak shaving ... ;-)
>>
>>
>
> I was thinking to achieve something close to the convenience of ddply
> without moving too far from the R API would be:
>
> aggregate(~ transcript_id + type, gr, function(tt) {
> })
`aggregate` ... Ack! My eyes!
To my detriment (and embarrassment!), my eyes always begin to
gloss-over when I try to parse that syntax[1] when it's used for
things outside of linear modeling, and have always steered clear
(although I am trying to make a more concerted effort of dealing with
it in reshap-ing and stuff more recently).
I know it's a base R thing ... but ugh ... I guess it should have
clicked by now, but I've never given it its due, hence my love of plyr
and data.table for (at least) these types of summary tasks.
[1] Heaven forbid there be a call to `substitute` or `quote` in close
proximity to a strange formula-like looking `aggregate` or `xtabs`
call -- I may start seeing dead people.
-steve
--
Steve Lianoglou
Computational Biologist
Genentech
More information about the Bioconductor
mailing list