Skip to content
Prev 3210 / 21312 Next

[Bioc-devel] mapping between original and reduced ranges

Hi reducers,

I agree it "feels wrong" to use findOverlaps() to extract the mapping
from original to reduced ranges. Even if it can be computed very easily
with:

   findOverlaps(gr, reduce(gr), select="first")

(Note that using 'queryHits(findOverlaps(reduce(gr), gr))' only produces
the correct result if 'gr' is already sorted by increasing order.)

I think it would be easy for reduce() internal code to produce this
mapping. The question is: how do we give it back to the user?

Is it OK to use an attribute for this? reduce() already uses this
for returning some extra information about the reduction:

   > ir
   IRanges of length 5
       start end width
   [1]     1   5     5
   [2]     6  10     5
   [3]    12  16     5
   [4]    24  28     5
   [5]    27  31     5
   > ir2 <- reduce(ir, with.inframe.attrib=TRUE)
   > ir2
   IRanges of length 3
       start end width
   [1]     1  10    10
   [2]    12  16     5
   [3]    24  31     8
   > attr(ir2, "inframe")
   IRanges of length 5
       start end width
   [1]     1   5     5
   [2]     6  10     5
   [3]    11  15     5
   [4]    16  20     5
   [5]    19  23     5

We could to the same thing for the mapping from original to reduced
ranges with e.g. an argument called 'with.mapping.attrib'.
Would that work?

Cheers,
H.
On 03/15/2012 05:44 AM, Kasper Daniel Hansen wrote: