[Bioc-devel] A question on IRanges package

Martin Morgan mtmorgan at fhcrc.org
Fri Apr 4 17:24:14 CEST 2014


On 04/03/2014 06:17 PM, Yuan Luo wrote:
> A side question, in the frame 3, what does .local mean? local environment? like
> if I go into frame 3, I'd be able to print out their values?

(I'm only the messenger) .local is a nested function created when a method adds 
arguments to the generic. After

     setGeneric("foo", function(x, ...) standardGeneric("foo"))
     setMethod("foo", "A", function(x, ...) x)
     setMethod("foo", "B", function(x, y, ...) { x })

compare

     > selectMethod("foo", "A")
     Method Definition:

     function (x, ...)
     x

     Signatures:
             x
     target  "A"
     defined "A"
     > selectMethod("foo", "B")
     Method Definition:

     function (x, ...)
     {
         .local <- function (x, y, ...)
         {
             x
         }
         .local(x, ...)
     }

     Signatures:
             x
     target  "B"
     defined "B"

so .local appears on the call stack (after the generic and method, so for 
findOverlaps(IRanges(), IRanges(), type="o") we have in part

3: .local(query, subject, maxgap, minoverlap, type, select, ...)
2: findOverlaps(IRanges(), IRanges(), type = "o")
1: findOverlaps(IRanges(), IRanges(), type = "o")

corresponding, in reverse order, to the generic, the method, and the nested 
function).


>
>
> On Thu, Apr 3, 2014 at 9:10 PM, Yuan Luo <yuan.hypnos.luo at gmail.com
> <mailto:yuan.hypnos.luo at gmail.com>> wrote:
>
>     I think that line at 4 points to the generic definition, at least on my
>     machine (and keep source works, thanks!).
>
>     Just found what was the culprit, there is a wrapper in
>     findOverlaps-GIntervalTree-methods.R#12. After updating that, it works.
>      > traceback()
>     5: stop(gettextf("'arg' should be one of %s", paste(dQuote(choices),
>             collapse = ", ")), domain = NA)
>     4: match.arg(type) at findOverlaps-GIntervalTree-methods.R#12
>     3: .local(query, subject, maxgap, minoverlap, type, select, ...)
>     2: findOverlaps(varanges, rna_tree, type = "o") at findOverlaps-methods.R#14
>     1: findOverlaps(varanges, rna_tree, type = "o")
>
>     Again, thank you both!
>
>     Best,
>     Yuan
>
>
>
>     On Thu, Apr 3, 2014 at 7:49 PM, Martin Morgan <mtmorgan at fhcrc.org
>     <mailto:mtmorgan at fhcrc.org>> wrote:
>
>         On 04/03/2014 04:42 PM, Michael Lawrence wrote:
>
>             I'll look at the code. As far as tracking line numbers, no, because the
>             code is bundled into a package -- there are no files anymore. In
>             principle,
>             that could be improved, but as far as I know, it hasn't been. If you're
>
>
>         I think there's an option, set in .Rprofile or as an environment
>         variable described in ?options,
>
>            options(keep.source.pkgs=TRUE)
>
>         that annotates the source of installed packages with line numbers, e.g.,
>         after doing this and then installing GenomicRanges (on my own version)
>
>          > library(GenomicRanges)
>          > findOverlaps(GRanges(), GRanges(), type="o")
>
>         Error in match.arg(type) :
>            'arg' should be one of "any", "start", "end", "within", "equal"
>          > traceback()
>         5: stop(gettextf("'arg' should be one of %s", paste(dQuote(choices),
>                 collapse = ", ")), domain = NA)
>         4: match.arg(type) at findOverlaps-methods.R#63
>
>         3: .local(query, subject, maxgap, minoverlap, type, select, ...)
>         2: findOverlaps(GRanges(), GRanges(), type = "o")
>         1: findOverlaps(GRanges(), GRanges(), type = "o")
>
>
>         I'm not really sure which lines are annotated with source information.
>
>         Martin
>
>
>             trying to figure out dispatch behavior, things like
>             selectMethod(findOverlaps, c("GRanges, "GRanges")) and
>             trace(findOverlaps,
>             browser, sig=c("GRanges", "GRanges")) are your friend.
>
>             Michael
>
>
>             On Thu, Apr 3, 2014 at 4:22 PM, Yuan Luo <yuan.hypnos.luo at gmail.com
>             <mailto:yuan.hypnos.luo at gmail.com>> wrote:
>
>                 At the moment I am using the package to tweak some design on
>                 interval tree
>                 algorithm, and much of my efforts are hack. So does the code
>                 suggest to you
>                 what I am doing wrong to get the match.arg failing error?
>                 Also, when you were developing the package, how do you tell the
>                 traceback
>                 to show line numbers and file names. My googling seems to
>                 suggest it's hard
>                 to do so in R, but I figured gurus may see better.
>
>                 Best,
>                 Yuan
>
>
>                 On Thu, Apr 3, 2014 at 6:05 PM, Michael Lawrence <
>                 lawrence.michael at gene.com <mailto:lawrence.michael at gene.com>> wrote:
>
>                     It looks like the only hits this will filter out are cases
>                     where the
>                     start of the query (X) is equal to the end of the subject
>                     (Y), but it seems
>                     like the "o" operation is different -- it requires that X
>                     start before Y
>                     starts and end before Y ends.
>
>                     We could add these relations to IRanges, but maybe
>                     findOverlaps is not
>                     the right place. Instead, we could have an %o% operator,
>                     plus operators for
>                     the rest of the algebra. But maybe it would help to hear
>                     your use case.
>
>                     Michael
>
>
>
>                     On Thu, Apr 3, 2014 at 1:13 PM, Yuan Luo
>                     <yuan.hypnos.luo at gmail.com
>                     <mailto:yuan.hypnos.luo at gmail.com>>__wrote:
>
>                         Hi Michael,
>                         Thanks for your reply! I covered setGeneric as well,
>                         attached is the
>                         modified code.
>                         My change is pretty simple, I want to support the o
>                         relation in Allen's
>                         Interval algebra
>                         (http://en.wikipedia.org/wiki/__Allen's_interval_algebra
>                         <http://en.wikipedia.org/wiki/Allen's_interval_algebra>)
>                         So I added one more filter option
>                               } else if (type == "o") {
>                                   m <- m[start(query)[m[,1L]] <
>                         end(subject)[m[,2L]], , drop=FALSE]
>                               }
>
>                           From the stack trace, I suspect the method
>                         definition setMethod("findOverlaps", c("RangesList",
>                         "IntervalForest"),
>                         is not called upon, and the error happens before that,
>                         but since the
>                         stack trace doesn't tell me in which file and which line
>                         each frame is, I
>                         am a bit clueless. Is there anyway to reveal that
>                         information?
>
>                         Best,
>                         Yuan
>
>
>                         On Thu, Apr 3, 2014 at 3:57 PM, Michael Lawrence <
>                         lawrence.michael at gene.com
>                         <mailto:lawrence.michael at gene.com>> wrote:
>
>
>
>
>                             On Thu, Apr 3, 2014 at 11:33 AM, Yuan Luo
>                             <yuan.hypnos.luo at gmail.com
>                             <mailto:yuan.hypnos.luo at gmail.com>>__wrote:
>
>                                 Hi All,
>                                 Sorry for possible spam, but I am trying to
>                                 customize IRanges package
>                                 locally. For what I am doing, I introduced
>                                 another option to type
>                                 parameters to the findOverlaps method. In the file
>                                 findOverlaps-methods.R,
>                                 I modified every instance of
>                                 type = c("any", "start", "end", "within", "equal"),
>                                 into
>                                 type = c("any", "start", "end", "within",
>                                 "equal", "o"),
>
>
>                             I'm curious as to what "o" is supposed to do and
>                             wonder whether you
>                             really need to be making this modification. Tough to
>                             help without seeing
>                             any of your code. Probably, you just missed one,
>                             maybe the generic itself?
>
>                             Michael
>
>
>                                 But when I call
>                                 h = findOverlaps(varanges, rna_tree, type="o")
>
>                                 I got the error
>
>                                     h = findOverlaps(varanges, rna_tree, type="o")
>
>                                 Error in match.arg(type) :
>                                     'arg' should be one of "any", "start",
>                                 "end", "within", "equal"
>                                 with the following traceback information
>
>                                     traceback()
>
>                                 5: stop(gettextf("'arg' should be one of %s",
>                                 paste(dQuote(choices),
>                                          collapse = ", ")), domain = NA)
>                                 4: match.arg(type)
>                                 3: .local(query, subject, maxgap, minoverlap,
>                                 type, select, ...)
>                                 2: findOverlaps(varanges, rna_tree, type = "o")
>                                 1: findOverlaps(varanges, rna_tree, type = "o")
>
>                                 Is there any place that I missed where there is
>                                 a default type vector
>                                 specification?
>                                 Also, how do you guys get R to display filename
>                                 and line numbers for
>                                 the
>                                 methods in the traceback stack?
>
>                                 Best,
>                                 Yuan
>
>                                           [[alternative HTML version deleted]]
>
>                                 _________________________________________________
>                                 Bioc-devel at r-project.org
>                                 <mailto:Bioc-devel at r-project.org> mailing list
>                                 https://stat.ethz.ch/mailman/__listinfo/bioc-devel
>                                 <https://stat.ethz.ch/mailman/listinfo/bioc-devel>
>
>
>
>
>
>
>
>                      [[alternative HTML version deleted]]
>
>             _________________________________________________
>             Bioc-devel at r-project.org <mailto:Bioc-devel at r-project.org> mailing list
>             https://stat.ethz.ch/mailman/__listinfo/bioc-devel
>             <https://stat.ethz.ch/mailman/listinfo/bioc-devel>
>
>
>
>         --
>         Computational Biology / Fred Hutchinson Cancer Research Center
>         1100 Fairview Ave. N.
>         PO Box 19024 Seattle, WA 98109
>
>         Location: Arnold Building M1 B861
>         Phone: (206) 667-2793 <tel:%28206%29%20667-2793>
>
>
>


-- 
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793



More information about the Bioc-devel mailing list