[BioC] help with reduction operation using IRanges/GRanges

Steve Lianoglou mailinglist.honeypot at gmail.com
Thu Apr 26 00:08:16 CEST 2012


Hi,

On Wed, Apr 25, 2012 at 5:21 PM, Abhishek Pratap <apratap at lbl.gov> wrote:
> Hi Michael
>
> SessionInfo copied below. My versions could be one older to current one.  I
> am still wondering how I can get this information in a format that can be
> digested by connectedComp or something similar. I think we are close to a
> solution.

Step 1: Upgrade R ;-)

It's not necessary for the approach I'm going to suggest, but it'll
probably make it easier for Michael to help you w/ his solution, which
is probably going to be more robust than the
duct-tape-and-elmer's-glue snippet I'm going to try:

R> library(GenomicRanges)
R> ir <- IRanges(c(10,10,11,9,10,11), width=c(190,190,190,190,180,180))
R> starts <- reduce(resize(ir, width=1, fix='start'), min.gapwidth=2)
R> ends <- reduce(resize(ir, width=1, fix='end'), min.gapwidth=2)
R> sc <- countOverlaps(ir, starts)
R> ec <- countOverlaps(ir, ends)

... and ... good morning:

R> split(ir, (paste(sc,ec,sep=":")))
CompressedIRangesList of length 2
$`1:1`
IRanges of length 2
    start end width
[1]    10 189   180
[2]    11 190   180

$`1:2`
IRanges of length 4
    start end width
[1]    10 199   190
[2]    10 199   190
[3]    11 200   190
[4]     9 198   190

HTH,
-steve
-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact



More information about the Bioconductor mailing list