Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generics and methods already in DelayedArray #33

Open
6 tasks
PeteHaitch opened this issue Oct 5, 2017 · 0 comments
Open
6 tasks

Generics and methods already in DelayedArray #33

PeteHaitch opened this issue Oct 5, 2017 · 0 comments

Comments

@PeteHaitch
Copy link
Owner

PeteHaitch commented Oct 5, 2017

There are several generics and methods already implemented in DelayedArray that 'belong' in DelayedMatrixStats; see https://github.com/PeteHaitch/DelayedMatrixStats/blob/master/README.md and note that I'm using 'belong' loosely here.

S4 generics

The simple ones

It makes sense to me to move the following generics (and methods) from DelayedArray to DelayedMatrixStats:

  • colMaxs()
  • colMins()
  • colRanges()
  • rowMaxs()
  • rowMins()

The obvious complication of moving these is that any users of these generics and methods would have to update their code accordingly (but I doubt there are many). It would, however, tidy things up somewhat and slightly simplify ongoing development.

The complicated one

The final generic is:

  • rowRanges()

This is more complicated because it is a generic that is serving 2 very distinct use cases:

  1. Get the row-ranges of a SummarizedExperiment-based object
  2. Compute the row-wise ranges of a matrix-like object

This is something we're stuck with. The S4 generic should remain where it is to avoid having SummarizedExperiment depend upon DelayedMatrixStats . It also must have a slightly different signature to the rest of the methods due to this dual role; compare rowRanges() to colRanges()

suppressPackageStartupMessages(library(DelayedMatrixStats))

rowRanges
#> standardGeneric for "rowRanges" defined from package "DelayedArray"
#> 
#> function (x, ...) 
#> standardGeneric("rowRanges")
#> <environment: 0x7fe2e9354958>
#> Methods may be defined for arguments: x
#> Use  showMethods("rowRanges")  for currently available ones.
colRanges
#> standardGeneric for "colRanges" defined from package "DelayedArray"
#> 
#> function (x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), 
#>     ...) 
#> standardGeneric("colRanges")
#> <environment: 0x7fe2e7e3ee00>
#> Methods may be defined for arguments: x
#> Use  showMethods("colRanges")  for currently available ones.

S4 methods

Each of these S4 generics from DelayedArray have a ANY-method implemented. This is in contrast to what I have elected to do for the generics defined in DelayedMatrixStats: I specifically implemented a matrix-method but no ANY-method. E.g., compare the following

suppressPackageStartupMessages(library(DelayedMatrixStats))

# Has an ANY-method
showMethods("colRanges")
#> Function: colRanges (package DelayedArray)
#> x="ANY"
#> x="DelayedMatrix"

# Has a matrix-method instead of an ANY-method
showMethods("colMedians")
#> Function: colMedians (package DelayedMatrixStats)
#> x="DelayedMatrix"
#> x="matrix"

The ANY-method of these generics are the correspondingly named matrixStats functions. Now, the matrixStats functions of the same names do check their inputs, so will error if given, say, a data frame. However, the real reason I took great pains to avoid introducing an ANY-method for the S4 generics defined in DelayedMatrixStats is because of the way I have implemented S4 dispatch based on the seed of the DelayedMatrix object - when an appropriate method does not exist for the seed, then the default 'block-processing' method is used. If an ANY-method exists, however, then there always exists a method for the seed but it is (erroneously) the corresponding function from matrixStats, which obviously only works with matrix objects.

Summary

I need to discuss these issues with members of the Bioconductor core team.

@PeteHaitch PeteHaitch changed the title Methods already in DelayedArray Generics and methods already in DelayedArray Oct 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant