From 283dfededb625bb29422dc3bbaeda70da1b2c324 Mon Sep 17 00:00:00 2001 From: plger Date: Mon, 6 Jan 2025 15:50:25 +0100 Subject: [PATCH] makes coercion only on individual samples --- R/misc.R | 4 ++-- R/scDblFinder.R | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/misc.R b/R/misc.R index 52326f1..e82bfa7 100644 --- a/R/misc.R +++ b/R/misc.R @@ -433,7 +433,7 @@ propHomotypic <- function(clusters){ rank=max(dims))$x[,seq_len(max(dims))] } -.checkSCE <- function(sce){ +.checkSCE <- function(sce, coerce=TRUE){ msg <- paste( "`sce` should be a SingleCellExperiment, a SummarizedExperiment, ", "or an array (i.e. matrix, sparse matric, etc.) of counts.") @@ -446,7 +446,7 @@ propHomotypic <- function(clusters){ } if( !("counts" %in% assayNames(sce)) ) stop("`sce` should have an assay named 'counts'") - if(!is(counts(sce),"DelayedMatrix")) + if(coerce || !is(counts(sce),"DelayedMatrix")) counts(sce) <- as(counts(sce),"CsparseMatrix") if(any(counts(sce)<0)) stop(msg, "\n", "The data contains negative counts!") diff --git a/R/scDblFinder.R b/R/scDblFinder.R index f77e35a..d14ce22 100644 --- a/R/scDblFinder.R +++ b/R/scDblFinder.R @@ -217,7 +217,7 @@ scDblFinder <- function( " works if `sce` is a SingleCellExperiment.\n", "Please pass the vector of labels.") } - sce <- .checkSCE(sce) + sce <- .checkSCE(sce, coerce=is.null(samples)) score <- match.arg(score) knownUse <- match.arg(knownUse) if(!is.null(clustCor)){