Re: [Bioc-devel] GenomicRanges List subclass and apply

2018-05-14 Thread Jack Fu
Thanks all -> I definitely see the appeal of vectorization. I'm going to take a few pokes to do just that. Best, Jack Hervé Pagès wrote: Hi Jack, You can use sapply(seq_along(gr), function(i) print(gr[i])) instead of sapply(gr, print) But yes, as Michael noted, looping on a GRanges or

Re: [Bioc-devel] GenomicRanges List subclass and apply

2018-05-14 Thread Hervé Pagès
Hi Jack, You can use sapply(seq_along(gr), function(i) print(gr[i])) instead of sapply(gr, print) But yes, as Michael noted, looping on a GRanges or IRanges object is generally not efficient and should be avoided. There is almost always a "vectorized" solution and it's generally much fast

Re: [Bioc-devel] GenomicRanges List subclass and apply

2018-05-14 Thread Michael Lawrence
It's possible that you could vectorize this code. Maybe open an issue on the support site. On Mon, May 14, 2018 at 7:56 AM, Jack Fu wrote: > Hi Michael, > > Mostly for sending each element of the GRanges object to a custom function > that runs an identical analysis on each element. > I have some

Re: [Bioc-devel] GenomicRanges List subclass and apply

2018-05-14 Thread Jack Fu
Hi Michael, Mostly for sending each element of the GRanges object to a custom function that runs an identical analysis on each element. I have some functions that take as input a single range -> calculate number of reads that overlap the range -> subset the range into K number of segments based

Re: [Bioc-devel] GenomicRanges List subclass and apply

2018-05-14 Thread Michael Lawrence
Just out of curiosity, why are you looping over a GRanges in the first place? On Mon, May 14, 2018 at 7:28 AM, Jack Fu wrote: > Hey all, > > I think some of the recent changes to GRanges has affected using the > apply class functions with GRanges objects: > > o GenomicRanges now is a List subcl