Skip to content

Commit

Permalink
fixes for updated v0.3 sctransform
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewwbutler committed Sep 21, 2020
1 parent b7e7ffe commit 815834f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Imports:
rsvd,
Rtsne,
scales,
sctransform (>= 0.2.0),
sctransform (>= 0.3.0),
shiny,
spatstat,
stats,
Expand Down
2 changes: 1 addition & 1 deletion R/preprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -3313,7 +3313,7 @@ GetResidualVstOut <- function(
umi = umi,
residual_type = "pearson",
res_clip_range = c(clip.min, clip.max),
show_progress = verbose
verbosity = verbose
)
new_residual <- as.matrix(x = new_residual)
# centered data
Expand Down
15 changes: 8 additions & 7 deletions tests/testthat/test_objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# ------------------------------------------------------------------------------
context("Metadata")

pbmc_small <- suppressWarnings(suppressMessages(UpdateSeuratObject(pbmc_small)))
cluster_letters <- LETTERS[Idents(object = pbmc_small)]
names(cluster_letters) <- colnames(x = pbmc_small)
cluster_letters_shuffled <- sample(x = cluster_letters)
Expand Down Expand Up @@ -205,9 +206,9 @@ context("Neighbor")
# converting to Graph and back

n.rann.ob <- NNHelper(
data = Embeddings(object = pbmc_small[["pca"]]),
query = Embeddings(object = pbmc_small[["pca"]]),
k = 10,
data = Embeddings(object = pbmc_small[["pca"]]),
query = Embeddings(object = pbmc_small[["pca"]]),
k = 10,
method = "rann")

test_that("Neighbor object methods work", {
Expand All @@ -230,12 +231,12 @@ test_that("Neighbor object methods work", {
expect_true(inherits(x = nro2, what = "Neighbor"))
expect_equal(Distances(object = n.rann.ob)[2, 3], Distances(object = nro2)[2, 3])
expect_equal(Indices(object = n.rann.ob)[1, 6], Indices(object = nro2)[1, 6])
})
})

n.annoy.ob <- NNHelper(
data = Embeddings(object = pbmc_small[["pca"]]),
query = Embeddings(object = pbmc_small[["pca"]]),
k = 10,
data = Embeddings(object = pbmc_small[["pca"]]),
query = Embeddings(object = pbmc_small[["pca"]]),
k = 10,
method = "annoy",
cache.index = TRUE)
idx.file <- tempfile()
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test_preprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ object <- suppressWarnings(SCTransform(object = object, verbose = FALSE))

test_that("SCTransform wrapper works as expected", {
expect_true("SCT" %in% names(object))
expect_equal(as.numeric(colSums(GetAssayData(object = object[["SCT"]], slot = "scale.data"))[1]), 13.33038640)
expect_equal(as.numeric(colSums(GetAssayData(object = object[["SCT"]], slot = "scale.data"))[1]), 11.40288448)
expect_equal(as.numeric(rowSums(GetAssayData(object = object[["SCT"]], slot = "scale.data"))[5]), 0)
expect_equal(as.numeric(colSums(GetAssayData(object = object[["SCT"]], slot = "data"))[1]), 55.29678, tolerance = 1e6)
expect_equal(as.numeric(rowSums(GetAssayData(object = object[["SCT"]], slot = "data"))[5]), 11.74404, tolerance = 1e6)
expect_equal(as.numeric(colSums(GetAssayData(object = object[["SCT"]], slot = "counts"))[1]), 123)
expect_equal(as.numeric(colSums(GetAssayData(object = object[["SCT"]], slot = "counts"))[1]), 129)
expect_equal(as.numeric(rowSums(GetAssayData(object = object[["SCT"]], slot = "counts"))[5]), 28)
expect_equal(length(VariableFeatures(object[["SCT"]])), 220)
expect_equal(object[["SCT"]][[]]["MS4A1", "sct.detection_rate"], 0.15)
Expand All @@ -309,12 +309,12 @@ test_that("SCTransform wrapper works as expected", {
object <- suppressWarnings(SCTransform(object = object, ncells = 40, verbose = FALSE))
test_that("SCTransform ncells param works", {
expect_true("SCT" %in% names(object))
expect_equal(as.numeric(colSums(GetAssayData(object = object[["SCT"]], slot = "scale.data"))[1]), 11.834969847)
expect_equal(as.numeric(colSums(GetAssayData(object = object[["SCT"]], slot = "scale.data"))[1]), 9.411835306)
expect_equal(as.numeric(rowSums(GetAssayData(object = object[["SCT"]], slot = "scale.data"))[5]), 0)
expect_equal(as.numeric(colSums(GetAssayData(object = object[["SCT"]], slot = "data"))[1]), 55.29678, tolerance = 1e6)
expect_equal(as.numeric(rowSums(GetAssayData(object = object[["SCT"]], slot = "data"))[5]), 11.74404, tolerance = 1e6)
expect_equal(as.numeric(colSums(GetAssayData(object = object[["SCT"]], slot = "counts"))[1]), 121)
expect_equal(as.numeric(rowSums(GetAssayData(object = object[["SCT"]], slot = "counts"))[5]), 25)
expect_equal(as.numeric(colSums(GetAssayData(object = object[["SCT"]], slot = "counts"))[1]), 119)
expect_equal(as.numeric(rowSums(GetAssayData(object = object[["SCT"]], slot = "counts"))[5]), 26)
expect_equal(length(VariableFeatures(object[["SCT"]])), 220)
expect_equal(object[["SCT"]][[]]["MS4A1", "sct.detection_rate"], 0.15)
expect_equal(object[["SCT"]][[]]["MS4A1", "sct.gmean"], 0.2027364, tolerance = 1e6)
Expand Down

0 comments on commit 815834f

Please sign in to comment.