Skip to content
/ DrS4 Public

DrS4 is a small package with some helper functions for learning about S4

Notifications You must be signed in to change notification settings

vjcitn/DrS4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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}
BiocStyle::html_document
highlight number_sections theme toc
pygments
true
united
true

Observation: methods may report more than we need

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("==")

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

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.

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

About

DrS4 is a small package with some helper functions for learning about S4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages