IRanges: find containment and not just overlap
1
0
Entering edit mode
@elizabeth-purdom-2486
Last seen 3.0 years ago
USA/ Berkeley/UC Berkeley
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
IRanges IRanges • 1.2k views
ADD COMMENT
0
Entering edit mode
@michael-lawrence-2759
Last seen 10.3 years ago
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@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@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > [[alternative HTML version deleted]]
ADD COMMENT
0
Entering edit mode
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 > >
ADD REPLY
0
Entering edit mode
Yes that requires the development version of IRanges. Sorry for not specifying that. Michael On Fri, Feb 20, 2009 at 10:51 PM, Elizabeth Purdom < epurdom@stat.berkeley.edu> wrote: > 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@stat.berkeley.edu <mailto:epurdom@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@stat.math.ethz.ch <mailto:bioconductor@stat.math.ethz.ch> >> https://stat.ethz.ch/mailman/listinfo/bioconductor >> Search the archives: >> http://news.gmane.org/gmane.science.biology.informatics.conductor >> >> >> [[alternative HTML version deleted]]
ADD REPLY

Login before adding your answer.

Traffic: 594 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6