title | author | date | vignette | output | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DrS4: help in contemplating S4 class usage |
Vincent J. Carey, stvjc at channing.harvard.edu |
`r format(Sys.time(), '%B %d, %Y')` |
%\VignetteEngine{knitr::rmarkdown} %\VignetteIndexEntry{DrS4: help in contemplating S4 class usage} %\VignetteEncoding{UTF-8}
|
|
We are interested in the SingleCellExperiment class.
It is defined in a package.
suppressPackageStartupMessages({
library(SingleCellExperiment)
library(DrS4)
library(dplyr)
})
methods(class="SingleCellExperiment")
There are many methods listed, including '=='.
try(getMethod("==", "SingleCellExperiment"))
We can find the signatures for which '==' is defined:
showMethods("==")
DrS4 aims to provide clearer access to the methods actually defined for a class. This requires specifying a package where we look for the class and its methods. More work needs to be done in this domain. Specifically, the function 'defdMethods' currently only retrieves one method/signature for each generic method defined for the class.
library(DrS4)
require("SingleCellExperiment")
scem = defdMethods(cl="SingleCellExperiment",
pkg="SingleCellExperiment")
head(scem)
Here we'll list methods of coercing between classes involving SummarizedExperiment, RangedSummarizedExperiment, and SingleCellExperiment.
require("SummarizedExperiment")
se = defdMethods("SummarizedExperiment") # pkg has simple default
rse = defdMethods("RangedSummarizedExperiment", pkg="SummarizedExperiment")
cmb = try(rbind(scem,se,rse))
tmp = (cmb |> filter(method=="coerce"))
sl = (tmp |> select(sigs))[[1]]
names(sl) = tmp$cl
sl