[Bioc-devel] Hunting for the subset generic definition?

Hervé Pagès hpages at fredhutch.org
Wed Jul 29 20:00:03 CEST 2015

Hi Steve,

On 07/29/2015 10:40 AM, Steve Lianoglou wrote:
> Hi folks,
> I'm looking to define a `subset` method on an S4 class of mine, but
> can't find where to import the generic from.

That's because subset() is an implicit generic, that is, there is no
setGeneric statement for it, only setMethod statements. And so it's
automatically turned into a generic the first time a package with
a setMethod statement is loaded. More precisely, everything happens
as if setGeneric("subset") was called right before the first time
setMethod("subset", ...) is called.

> I can't seem to find it anywhere in:
>    * BiocGenerics
>    * S4Vectors
>    * XVector (
> Even though S4Vectors has a:
>    setMethod("subset", "DataTable", ...)
> It's not clear to me where it pulled the appropriate
> `setGeneric("subset", ...)` from.

I believe that you need to import it from S4Vectors. But things are
going to be much clearer/cleaner if we make subset() an explicit
generic by adding setGeneric("subset") to BiocGenerics. Which I'm
going to do right now. Then you'll be able to import the subset()
generic from BiocGenerics.


> Can anyone provide a pointer?
> Thanks,
> -steve

Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319

More information about the Bioc-devel mailing list