Skip to content

Commit

Permalink
Added a separate check.missing.test= option that defaults to FALSE.
Browse files Browse the repository at this point in the history
This avoids an unnecessary NA check for the test dataset, where it would be
very usual to have missing values. After all, the only purpose of this category
of arguments is to deal with NAs in the celldex references.
  • Loading branch information
LTLA committed Dec 15, 2024
1 parent 407e3b6 commit 80b9923
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 7 additions & 3 deletions R/SingleR.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#' if \code{test} is a \linkS4class{SummarizedExperiment} object.
#' @param assay.type.ref An integer scalar or string specifying the assay of \code{ref} containing the relevant expression matrix,
#' if \code{ref} is a \linkS4class{SummarizedExperiment} object (or is a list that contains one or more such objects).
#' @param check.missing Logical scalar indicating whether rows should be checked for missing values (and if found, removed).
#' @param check.missing.test Logical scalar indicating whether rows of \code{test} should be checked for missing values (and if found, removed).
#' @param check.missing.ref Logical scalar indicating whether rows of \code{ref} should be checked for missing values (and if found, removed).
#' @param check.missing Deprecated, use \code{check.missing.test} and \code{check.missing.ref} instead.
#' @param num.threads Integer scalar specifying the number of threads to use for index building and classification.
#' @param BNPARAM Deprecated and ignored.
#' @param BPPARAM A \linkS4class{BiocParallelParam} object specifying how parallelization should be performed in other steps,
Expand Down Expand Up @@ -93,6 +95,8 @@ SingleR <- function(
prune=TRUE,
assay.type.test = "logcounts",
assay.type.ref="logcounts",
check.missing.test=FALSE,
check.missing.ref=check.missing,
check.missing=TRUE,
num.threads = bpnworkers(BPPARAM),
BNPARAM = NULL,
Expand All @@ -105,7 +109,7 @@ SingleR <- function(

# We have to do all this row-subsetting at the start before trainSingleR,
# otherwise 'test.genes' won't match up to the filtered 'test'.
test <- .to_clean_matrix(test, assay.type.test, check.missing, msg="test", BPPARAM=BPPARAM)
test <- .to_clean_matrix(test, assay.type.test, check.missing.test, msg="test", BPPARAM=BPPARAM)

tmp.ref <- ref
if (!is.list(tmp.ref) || is.data.frame(tmp.ref)) {
Expand Down Expand Up @@ -134,7 +138,7 @@ SingleR <- function(
recompute=recompute,
restrict = restrict,
test.genes=rownames(test),
check.missing=check.missing,
check.missing=check.missing.ref,
BNPARAM=BNPARAM,
num.threads = num.threads,
BPPARAM=BPPARAM
Expand Down
8 changes: 7 additions & 1 deletion man/SingleR.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 80b9923

Please sign in to comment.