RGLab / MAST

Tools and methods for analysis of single cell assay data in R
226 stars 57 forks source link

Combine dispatch problems #1

Closed amcdavid closed 11 years ago

amcdavid commented 12 years ago

doubleid <- data.frame(id1=1:3, id2=1:3, et=rep(3, 3), f1=rep('A', 3)) smallsc <- SingleCellAssay(doubleid, idvars='id1', geneid='f1', primerid='f1', measurement='et') spl <- split(smallsc, 'id1') c2 <- combine(spl[[1]], spl[[2]], spl[[3]]) #Works fine

c2 <- do.call(combine, spl@set)

cannot coerce type 'closure' to vector of type 'character' 1: do.call(combine, spl@set) 2: structure(function (x, y, ...) { if (length(list(...)) > 0L) { callGeneric(x, do.call(callGeneric, list(y, ...))) } else { standardGeneric("combine") } }, generic = structure("combine", package = "BiocGenerics"), package = "BiocGenerics", group = list(), valueClass = character(0), signature = c("x", "y"), default = \001NULL\001, skeleton = function (x, y, ...) stop("invalid call in method dispatch to \"combine\" (no default method)", domain = NA)(x, y, ...), class = structure("nonstandardGenericFunction", package = "methods"))(1 = <S4 object of class structure("SingleCellAssay", package = "SingleCellAssay")>, 2 = <S4 object of class structure("SingleCellAssay", package = "SingleCellAssay")>, 3 = <S4 object of class structure("SingleCellAssay", package = "SingleCellAssay")>) 3: callGeneric(x, do.call(callGeneric, list(y, ...))) 4: as.character(call[[1L]]) 5: as.character.default(call[[1L]])

amcdavid commented 12 years ago

Or as long as we can somehow dispatch combine on a variable number of SingleCellAssays, it doesn't really matter if it works through do.call.

This looks pretty hairy, since it has to do with how combine is being dispatched by BiocGenerics, I think.

gfinak commented 12 years ago

combine takes two argument, not more.. it's not suitable for enclosing within a do.call()


Greg Finak, Ph.D Staff Scientist Vaccine and Infectious Disease Division. Fred Hutchinson Cancer Research Center Seattle, WA (206)667-3116 gfinak@fhcrc.org

On 2012-10-04, at 12:09 PM, Andrew McDavid wrote:

Or as long as we can somehow dispatch combine on a variable number of SingleCellAssays, it doesn't really matter if it works through do.call.

This looks pretty hairy, since it has to do with how combine is being dispatched by BiocGenerics, I think.

— Reply to this email directly or view it on GitHub.

gfinak commented 12 years ago

The solution would be to write a wrapper that recursively calls combine, while maintaining the caller's environment so as not to pollute the stack, I think.


Greg Finak, Ph.D Staff Scientist Vaccine and Infectious Disease Division. Fred Hutchinson Cancer Research Center Seattle, WA (206)667-3116 gfinak@fhcrc.org

On 2012-10-04, at 12:09 PM, Andrew McDavid wrote:

Or as long as we can somehow dispatch combine on a variable number of SingleCellAssays, it doesn't really matter if it works through do.call.

This looks pretty hairy, since it has to do with how combine is being dispatched by BiocGenerics, I think.

— Reply to this email directly or view it on GitHub.

gfinak commented 12 years ago

This would be a suitable template (from reshape)

merge_recurse function (dfs, ...) { if (length(dfs) == 2) { merge(dfs[[1]], dfs[[2]], all = TRUE, sort = FALSE, ...) } else { merge(dfs[[1]], Recall(dfs[-1]), all = TRUE, sort = FALSE, ...) } }

Greg Finak, Ph.D Staff Scientist Vaccine and Infectious Disease Division. Fred Hutchinson Cancer Research Center Seattle, WA (206)667-3116 gfinak@fhcrc.org

On 2012-10-04, at 12:09 PM, Andrew McDavid wrote:

Or as long as we can somehow dispatch combine on a variable number of SingleCellAssays, it doesn't really matter if it works through do.call.

This looks pretty hairy, since it has to do with how combine is being dispatched by BiocGenerics, I think.

— Reply to this email directly or view it on GitHub.

amcdavid commented 12 years ago

It takes ... it appears? On Oct 4, 2012 12:39 PM, "Greg Finak" notifications@github.com wrote:

combine takes two argument, not more.. it's not suitable for enclosing within a do.call()


Greg Finak, Ph.D Staff Scientist Vaccine and Infectious Disease Division. Fred Hutchinson Cancer Research Center Seattle, WA (206)667-3116 gfinak@fhcrc.org

On 2012-10-04, at 12:09 PM, Andrew McDavid wrote:

Or as long as we can somehow dispatch combine on a variable number of SingleCellAssays, it doesn't really matter if it works through do.call.

This looks pretty hairy, since it has to do with how combine is being dispatched by BiocGenerics, I think.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHubhttps://github.com/RGLab/SingleCellAssay/issues/1#issuecomment-9154267.

gfinak commented 12 years ago

Well, you're right it should.. but it gives an error irrespective of the data type I'm passing to combine via do.call.

rbind and c and cbind all take (...) as the first argument.. may have something to do with it.


Greg Finak, Ph.D Staff Scientist Vaccine and Infectious Disease Division. Fred Hutchinson Cancer Research Center Seattle, WA (206)667-3116 gfinak@fhcrc.org

On 2012-10-04, at 1:39 PM, Andrew McDavid wrote:

It takes ... it appears? On Oct 4, 2012 12:39 PM, "Greg Finak" notifications@github.com wrote:

combine takes two argument, not more.. it's not suitable for enclosing within a do.call()


Greg Finak, Ph.D Staff Scientist Vaccine and Infectious Disease Division. Fred Hutchinson Cancer Research Center Seattle, WA (206)667-3116 gfinak@fhcrc.org

On 2012-10-04, at 12:09 PM, Andrew McDavid wrote:

Or as long as we can somehow dispatch combine on a variable number of SingleCellAssays, it doesn't really matter if it works through do.call.

This looks pretty hairy, since it has to do with how combine is being dispatched by BiocGenerics, I think.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHubhttps://github.com/RGLab/SingleCellAssay/issues/1#issuecomment-9154267.

— Reply to this email directly or view it on GitHub.

gfinak commented 11 years ago

I've written a combine_recurse method to handle this.