[Bioc-devel] Pushing towards a better home for matrix generics

Aaron Lun |n||n|te@monkey@@w|th@keybo@rd@ @end|ng |rom gm@||@com
Sun Jan 27 22:45:46 CET 2019


This is a resurrection of some old threads:

https://stat.ethz.ch/pipermail/bioc-devel/2017-November/012273.html

https://github.com/Bioconductor/MatrixGenerics/issues

For those who are unfamiliar with this, the basic issue is that various
Matrix and BiocGenerics functions mask each other. This is mildly
frustrating in interactive sessions:

> library(Matrix)
> library(DelayedArray)
> x <- rsparsematrix(10, 10, 0.1)
> colSums(x) # fails
> Matrix::colSums(x) # okay

... but quite annoying during package development, requiring code like
this:

    if (is(x, "Matrix")) {
        z <- Matrix::colSums(x)
    } else {
        z <- colSums(x) # assuming DelayedArray does the masking.
    }

... which defeats the purpose of using S4 dispatch in the first place.

I have been encountering this issue with increasing frequency in my
packages, as a lot of my code base needs to be able to interface with
both Matrix and Bioconductor objects (e.g., DelayedMatrices) at the
same time. What needs to happen so that I can just write:

    z <- colSums(x)

... and everything will work for both Matrix and Bioconductor classes?
It seems that many of these function names are implicit generics
anyway, can BiocGenerics take advantage of that for the time being?

Best,

Aaron



More information about the Bioc-devel mailing list