[BioC] help with reduction operation using IRanges/GRanges

Kasper Daniel Hansen kasperdanielhansen at gmail.com
Wed Apr 25 00:43:16 CEST 2012


> ir <- IRanges(start = c(1,5), width = 3)
> ir
IRanges of length 2
    start end width
[1]     1   3     3
[2]     5   7     3
> reduce(ir)
IRanges of length 2
    start end width
[1]     1   3     3
[2]     5   7     3
> reduce(ir, min.gapwidth = 2)
IRanges of length 1
    start end width
[1]     1   7     7

As far as I understand, this is exactly what you want.  If you have
further questions, I suggest you read the help page.

Kasper


On Tue, Apr 24, 2012 at 3:18 PM, Abhishek Pratap <apratap at lbl.gov> wrote:
> Hi Kasper
>
> Thanks for a quick reply. I tried the following and I believe I would need a
> max.gapwidth parameter.
>
> ir <- IRanges(c(10,10,11,9,10,11), width=c(190,190,190,190,180,180))
>
> reduce(ir,min.gapwidth=1)
> IRanges of length 1
>     start end width
> [1]     9 200   192
>
>
> Although not sure why this one merges everything
>
>  reduce(ir,min.gapwidth=11)
> IRanges of length 1
>     start end width
> [1]     9 200   192
>
> -Abhi
>
>
>
>
>
> On Tue, Apr 24, 2012 at 2:54 PM, Kasper Daniel Hansen
> <kasperdanielhansen at gmail.com> wrote:
>>
>> Use the min.gapwidth argument to reduce, as explained in the help page.
>>
>> Kasper
>>
>> On Tue, Apr 24, 2012 at 2:47 PM, Abhishek Pratap <apratap at lbl.gov> wrote:
>> > Hi Guys
>> >
>> > I am trying to run a reduce operation on my genomic interval data.
>> >
>> > Sample Data and expected output pasted here :
>> > http://pastebin.com/cccZby2t
>> >
>> >
>> > Rows 1-5 from input have merged since the tiling distance between them
>> > is <
>> > 2 bp. Ideally I would like to define that distance.
>> > Rows 5-6 are merged separately as their distance is more than 2 bp from
>> > the
>> > above rows.
>> >
>> > I hope tiling is the right word above. In essence what I want to do is
>> > define a max merging width and merge all the intervals which are within
>> > this user defined threshold . The condition of tiling distance should be
>> > satisfied by both start and end.
>> >
>> > Hope this is clear.
>> >
>> > Thanks!
>> > -Abhi
>> >
>> >        [[alternative HTML version deleted]]
>> >
>> > _______________________________________________
>> > Bioconductor mailing list
>> > Bioconductor at r-project.org
>> > https://stat.ethz.ch/mailman/listinfo/bioconductor
>> > Search the archives:
>> > http://news.gmane.org/gmane.science.biology.informatics.conductor
>
>



More information about the Bioconductor mailing list