README.md

title: "DrS4: help in contemplating S4 class usage" author: "Vincent J. Carey, stvjc at channing.harvard.edu" date: "r format(Sys.time(), '%B %d, %Y')" vignette: > %\VignetteEngine{knitr::rmarkdown} %\VignetteIndexEntry{DrS4: help in contemplating S4 class usage} %\VignetteEncoding{UTF-8} output: BiocStyle::html_document: highlight: pygments number_sections: yes theme: united toc: yes

Observation: methods may report more than we need

We are interested in the SingleCellExperiment class.

It is defined in a package.

```{r dosce} suppressPackageStartupMessages({ library(SingleCellExperiment) library(DrS4) library(dplyr) }) methods(class="SingleCellExperiment")


There are many methods listed, including '=='.

```{r chk1}
try(getMethod("==", "SingleCellExperiment"))

We can find the signatures for which '==' is defined: ```{r lksm} showMethods("==")


# Finding methods defined in a package

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.

## Example

```{r useDrS4}
library(DrS4)
require("SingleCellExperiment")
scem = defdMethods(cl="SingleCellExperiment",
          pkg="SingleCellExperiment")
head(scem)

Listing available coercion methods

Here we'll list methods of coercing between classes involving SummarizedExperiment, RangedSummarizedExperiment, and SingleCellExperiment. {r doex} 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



vjcitn/DrS4 documentation built on Oct. 4, 2021, 10:13 p.m.