alanocallaghan / scater

Clone of the Bioconductor repository for the scater package.
https://bioconductor.org/packages/devel/bioc/html/scater.html
95 stars 40 forks source link

Handling genes with zero expression when using `scale = TRUE` in `plotDots()` #167

Closed ycl6 closed 2 years ago

ycl6 commented 2 years ago

When using scale = TRUE in plotDots(), including genes that are not expressed in any of the cells will cause an error in .heatmap_scale().

Error in seq.default(zlim[1], zlim[2], length.out = length(color) + 1L) : 
  'from' must be a finite number

Maybe adding additional checks in plotDots() to remove such genes if scale = TRUE?

alanocallaghan commented 2 years ago

I don't really want to automagically remove features so will probably just add an informative error message, something like this:

library("scater")

counts <- matrix(rpois(100, 5), ncol = 10)
counts[1:5, ] <- 0
sce <- SingleCellExperiment(assays = list(counts = counts))
sce <- logNormCounts(sce)

plotDots(sce, features=1:10, scale = TRUE)
#> Error in .heatmap_scale(ave, center = center, scale = scale, color = color, : Cannot include non-expressed genes when scale=TRUE.
ycl6 commented 2 years ago

Hi @Alanocallaghan That's a good idea, users will know they have to make the necessary changes to their inputs.

alanocallaghan commented 2 years ago

I count this as fixed now, feel free to reopen if not though