Open TuomasBorman opened 2 days ago
Hm... it's very unusual to have NA
in a single-cell count matrix. In fact, I don't think I've ever seen an NA
in any assay matrix for any technology I've worked on.
I suppose it's possible to add an na.rm=
option, but it's not a scenario that I've ever encountered, so I'm afraid it's not a high priority for me at the moment. If you want to give it a crack, I'm happy to consider a PR. Otherwise, you might consider some more expedient solutions:
NA
s, if they are going to be all-NA
rows.DelayedArray::rowsum
, which does have a na.rm=
option.NAs might occur, for instance, when datasets are merged. I think na.rm option would be good addition. I can create a PR, I will come back to you this week
From the discussions in #34, the best solution for now is probably to use rowsum()
:
y <- Matrix::rsparsematrix(10000, 5, density=0.1)
z <- sample(LETTERS[1:5], nrow(y), replace=TRUE)
y[1] <- NA
y2 <- DelayedArray::DelayedArray(y) # avoid copy of data on is.na(), type coercion.
is.okay <- !is.na(y2)
DelayedArray::type(is.okay) <- "integer"
DelayedArray::rowsum(y, z, na.rm=TRUE) / DelayedArray::rowsum(is.okay, z)
Make sure you use DelayedArray::rowsum
instead of base::rowsum
, as the latter won't be able to handle other matrix types.
Hi,
Functions like
mean()
,sum()
, and others typically include anna.rm
parameter, which allows you to control whetherNA
values should be excluded from calculations. However, it appears that aggregation functions inscuttle
do not provide an option for excludingNA
values. While one could convertNA
values to0
, this approach is not appropriate for calculating the mean.Could an
na.rm
option be added to handle this case?