transformGamPoi
transformGamPoi copied to clipboard
estimate_size_factors with poscounts fails for dgCMatrix
Hi Constantin,
since there is no colMedians() method for dgeMatrix objects, I get the following error from MatrixGenerics
Error in MatrixGenerics:::.load_next_suggested_package_to_search(x) :
Failed to find a colMedians() method for dgeMatrix objects.
Casting to matrix somewhere around
https://github.com/const-ae/transformGamPoi/blob/d408b11e728fa44805a52ad9aa059b54f6b195a4/R/helpers.R#L126-L131
should fix the issue.
Best, Christoph
Reproducible example:
set.seed(42)
counts <- scales::squish(x = rpois(n = 200, lambda = 3) - 3, range = c(0, Inf))
counts <- Matrix::Matrix(data = counts, nrow = 10, ncol = 20)
sf <- transformGamPoi:::estimate_size_factors(Y = counts, method = 'poscounts')
Hi Christoph,
thanks for the report. Yes, you are right, adding an as.matrix() somewhere should fix the issue.
However, the deeper issue is that MatrixGenerics apparently doesn't yet realize that it should treat dgeMatrix objects as matrix objects, which would be the more elegant solution. I will try and see if I can fix the problem :)