Skip to content

Commit

Permalink
quickCorrect returns all genes by default after correcting on HVGs.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Aug 11, 2021
1 parent 7d3d3ab commit ea09e98
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
6 changes: 5 additions & 1 deletion R/quickCorrect.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#' These genes will be used in the correction, though corrected values for all genes can be returned by setting \code{correct.all=TRUE}.
#' \item Applying the batch correction algorithm of choice with \code{\link{batchCorrect}}, as specified by \code{PARAM}.
#' }
#'
#' The default of \code{correct.all=TRUE} differs from that of other functions.
#' This is because the subsetting to HVGs is done internally here, and we avoid surprises by returning results for all genes in the input object(s).
#' In contrast, the other functions require explicit subsetting via \code{subset.row=} and it is expected that users will set \code{correct.all=} if all genes are desired.
#'
#' @return A list containing:
#' \itemize{
Expand Down Expand Up @@ -62,7 +66,7 @@
quickCorrect <- function(...,
batch=NULL,
restrict=NULL,
correct.all=FALSE,
correct.all=TRUE,
assay.type="counts",
PARAM=FastMnnParam(),
multi.norm.args=list(),
Expand Down
6 changes: 5 additions & 1 deletion man/quickCorrect.Rd

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

12 changes: 7 additions & 5 deletions tests/testthat/test-quick-correct.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ test_that("quickCorrect works with a single object", {
})

test_that("quickCorrect actually uses its HVGs", {
set.seed(0)
pre1 <- quickCorrect(sce1, sce2, hvg.args=list(n=20))
BPPARAM <- FastMnnParam(d=10) # avoid warnings

set.seed(0)
pre2 <- quickCorrect(sce1, sce2, hvg.args=list(n=100))
pre1 <- quickCorrect(sce1, sce2, PARAM=BPPARAM, hvg.args=list(n=50))
set.seed(0)
pre2 <- quickCorrect(sce1, sce2, PARAM=BPPARAM, hvg.args=list(n=100))

# Actually has an effect.
expect_false(identical(pre1, pre2))
})
expect_false(identical(pre1$corrected, pre2$corrected))
expect_identical(nrow(pre1$corrected), nrow(pre2$corrected)) # negative control
q})

0 comments on commit ea09e98

Please sign in to comment.