[BioC] Looping over entries of a GRanges object

Julian Gehring julian.gehring at embl.de
Thu May 22 14:56:14 CEST 2014


Hi,

Is there a fast way of looping over/extracting the entries of a 
'GRanges' object individually?  Due to the complex structure of a 
GRanges object, a simple solution like

library(GenomicRanges)
n = 1e4
gr = GRanges(1, IRanges(1:n, width = 1))

for(i in seq_along(gr)) {
     x = gr[i]
     ## more complex code acting on 'x'
}

takes notably long.  Converting to a 'GRangesList' or 
'GenomicRangesList' does obviously not improve the situation.  I was 
wondering if there is some dedicated functionality which would allow 
this in a faster manner, in cases where simple vectorized operations are 
not applicable.

Best wishes
Julian



More information about the Bioconductor mailing list