[BioC] IRanges: find containment and not just overlap

Elizabeth Purdom epurdom at stat.berkeley.edu
Sat Feb 21 07:51:33 CET 2009


Do I need a development version to have the function 'ranges' defined 
for the output of overlap? I get an error when I try to do this myself.
Thanks,
Elizabeth


 > isContained<-function(a,b){#a,b, ranges
+     require(IRanges)
+     ol<-overlap(a,b)
+     m<-as.matrix(ol)
+     contained<-m[width(ranges(ol)) == width(b[m[,1]]),]
+     return(contained)
+ }
 > a<-IRanges(c(1,2,3),c(4,5,6))
 > b<-IRanges(c(1,2,3),c(3,6,6))
 > isContained(a,b)
Error in function (classes, fdef, mtable)  :
   unable to find an inherited method for function "ranges", for 
signature "RangesMatching"
Error in width(ranges(ol)) :
   error in evaluating the argument 'x' in selecting a method for 
function 'width'
 > sessionInfo()
R version 2.8.1 (2008-12-22)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] IRanges_1.0.11

loaded via a namespace (and not attached):
[1] grid_2.8.1         lattice_0.17-17    Matrix_0.999375-17 tools_2.8.1 

 >


Michael Lawrence wrote:
> How about this:
> 
> Find ranges in 'b' completely contained within ranges in 'a':
> 
> ol <- overlap(a, b)
> m <- as.matrix(ol)
> contained <- m[width(ranges(ol)) == width(b[m[,1]]),]
> 
> So 'contained' is the overlap matrix, filtered by whether the 
> intersection of the overlap (ranges(ol)) has the same width as the query 
> range.
> 
> On Fri, Feb 20, 2009 at 4:53 PM, Elizabeth Purdom 
> <epurdom at stat.berkeley.edu <mailto:epurdom at stat.berkeley.edu>> wrote:
> 
>     Hi,
>     I'm very happy with the efficiency of the overlap function and I was
>     wondering if there is a fast way in IRanges to find which of the
>     ranges in one set are completely contained by one or more ranges in
>     another set (i.e. the same idea as overlap, but more restrictive
>     criteria than any overlap)? I don't want to assume anything about my
>     two set of ranges (e.g. that they are 'normal').
>     Thanks very much,
>     Elizabeth Purdom
>     UC, Berkeley
> 
>     _______________________________________________
>     Bioconductor mailing list
>     Bioconductor at stat.math.ethz.ch <mailto:Bioconductor at stat.math.ethz.ch>
>     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