[Bioc-devel] SetMethod to dispatch on class in unattached package

Brendan Innes brend@n@|nne@ @end|ng |rom m@||@utoronto@c@
Wed Jan 30 03:27:23 CET 2019


Hi friendly Bioc gang! I'm struggling with what seems like a silly problem. I'm trying to write a simple wrapper S4 generic that accesses the data slot of various S4 objects (seurat and SingleCellExperiment objects). So the generic is:

setGeneric("getGE",function(x) standardGeneric("getGE"))


And the methods are:

setMethod("getGE","seurat",
          function(x) Seurat::GetAssayData(x))
setMethod("getGE","SingleCellExperiment",
          function(x) SingleCellExperiment::logcounts(x))


Problem is that when I install the package, I get the warning

> in method for �getGE� with signature �"seurat"�: no definition for class �seurat�


This isn't surprising, since Seurat isn't imported, but I don't want the user to have to import it if their data is in a SingleCellExperiment object. The function still seems to work fine if I attach Seurat and load a seurat object, so I'm tempted to just suppress the error (but darned if I know how to do that either). Before I do something so rash, does anyone have a suggestion for a less dumb way to do this?

Thanks so much!
Brendan



www.baderlab.org/BrendanInnes<http://www.baderlab.org/BrendanInnes>

	[[alternative HTML version deleted]]



More information about the Bioc-devel mailing list