On 03/23/2011 05:00 PM, Dario Strbenac wrote: > mapply doesn't iterate over the GRangesList in an example I have that also uses other types of variables. Would it be possible for it to be more flexible in this usage ?
Hi Dario -- unfortunately mapply 'dispatches' on its '...' argument, and '...' dispatch only works when all relevant arguments are of the same type (e.g., mapply(function(x, y) print(x), grl, grl) would work). This is how S4 is implemented (see ?dotsMethods) so we're kind of stuck with this behavior. The workaround is along the lines of
lapply(seq_len(length(grl)), function(i, x, y, ...) print(x[[i]]), grl, 1:2) > mapply standardGeneric for "mapply" defined from package "IRanges" function (FUN, ..., MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE) standardGeneric("mapply") <bytecode: 0x207e200> <environment: 0x20a4cc0> Methods may be defined for arguments: ... Use showMethods("mapply") for currently available ones. Martin
Simple example: gr1<- GRanges("chr1", IRanges(seq(100, 600, 100), width = 100)) gr2<- GRanges("chr2", IRanges(seq(1000, 1600, 100), width = 100)) grl<- GRangesList(gr1, gr2) IRanges::mapply(function(x, y) { print(x) print(y) }, grl, 1:2, SIMPLIFY = FALSE) Result: It keeps using element 1 of grl. -------------------------------------- Dario Strbenac Research Assistant Cancer Epigenetics Garvan Institute of Medical Research Darlinghurst NSW 2010 Australia _______________________________________________ Bioc-sig-sequencing mailing list Bioc-sig-sequencing@r-project.org https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing
-- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793 _______________________________________________ Bioc-sig-sequencing mailing list Bioc-sig-sequencing@r-project.org https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing