Skip to content

Commit

Permalink
Merge pull request satijalab#898 from satijalab/fix/test_integration
Browse files Browse the repository at this point in the history
Improve tests for IntegrateLayers
  • Loading branch information
dcollins15 authored Feb 14, 2024
2 parents 150a85b + 120265e commit 942766a
Show file tree
Hide file tree
Showing 3 changed files with 353 additions and 98 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: Seurat
Version: 5.0.1.9006
Date: 2024-02-07
Version: 5.0.1.9007
Date: 2024-02-13
Title: Tools for Single Cell Genomics
Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) <doi:10.1038/nbt.3192>, Macosko E, Basu A, Satija R, et al (2015) <doi:10.1016/j.cell.2015.05.002>, Stuart T, Butler A, et al (2019) <doi:10.1016/j.cell.2019.05.031>, and Hao, Hao, et al (2020) <doi:10.1101/2020.10.12.335331> for more details.
Authors@R: c(
Expand Down
97 changes: 1 addition & 96 deletions tests/testthat/test_integratedata.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,99 +111,4 @@ test_that("Input validates correctly ", {
skip_on_cran()
#expect_warning(IntegrateData(anchorset = anchors2, k.weight = 50, features = c(rownames(ref), "BAD")))
#expect_warning(IntegrateData(anchorset = anchors2, k.weight = 50, dims = 1:1000))
})

# Tests for IntegrateLayers
# ------------------------------------------------------------------------------
context("IntegrateLayers")
pbmc_small[['RNAv5']] <- CreateAssay5Object(counts = LayerData(pbmc_small[['RNA']], layer = "counts"))

pbmc_small[["RNAv5"]] <- split(pbmc_small[["RNAv5"]], f = pbmc_small$groups)
DefaultAssay(pbmc_small) <- "RNAv5"
pbmc_small <- NormalizeData(pbmc_small)
pbmc_small <- FindVariableFeatures(pbmc_small)
pbmc_small <- ScaleData(pbmc_small)
pbmc_small <- suppressMessages(suppressWarnings(RunPCA(pbmc_small)))


test_that("IntegrateLayers does not work on a v3 assay ", {
expect_error(IntegrateLayers(object = pbmc_small, method = CCAIntegration,
orig.reduction = "pca",
assay = "RNA",
new.reduction = "integrated.cca"))
})

test_that("IntegrateLayers errors out if incorrect input ", {
expect_error(IntegrateLayers(object = pbmc_small, method = CCAIntegration,
orig.reduction = "pca",
assay = "DNA",
new.reduction = "integrated.cca"))
expect_error(IntegrateLayers(object = pbmc_small, method = CCAIntegration,
orig.reduction = "lda",
new.reduction = "integrated.cca"))
})

#itegration methods
int_cca <- suppressMessages(suppressWarnings(IntegrateLayers(
object = pbmc_small, method = CCAIntegration,
orig.reduction = "pca", new.reduction = "integrated.cca",
k.weight=25,
verbose = FALSE
)))
int_rpca <- suppressMessages(suppressWarnings(IntegrateLayers(
object = pbmc_small, method = RPCAIntegration,
orig.reduction = "pca", new.reduction = "integrated.rpca",
dims = 1:10,
k.anchor = 10,
k.weight=10,
verbose = FALSE
)))

# int_mnn <- suppressMessages(suppressWarnings(IntegrateLayers(
# object = pbmc_small, method = FastMNNIntegration,
# new.reduction = "integrated.mnn",
# k.weight=25,
# verbose = FALSE
# )))


test_that("IntegrateLayers returns embeddings with correct dimensions ", {
expect_equal(dim(int_cca[["integrated.cca"]]), c(80, 50))
expect_equal(dim(int_rpca[["integrated.rpca"]]), c(80, 50))

int_rpca
expect_equal(int_cca[["integrated.cca"]]@assay.used, "RNAv5")
#expect_equal(int_cca[['integrated.cca']]@cell.embeddings, c(3, 4, 5))
})

test_that("IntegrateLayers works with harmony", {
skip_on_cran()
skip_if_not_installed("harmony")
int_harmony <- suppressMessages(suppressWarnings(IntegrateLayers(
object = pbmc_small, method = HarmonyIntegration,
orig.reduction = "pca", new.reduction = "harmony",
k.weight=25,
verbose = FALSE
)))
expect_equal(dim(int_harmony[["harmony"]]), c(80, 50))


})

test_that("group.by ", {
expect_equal(dim(int_cca[["integrated.cca"]]), c(80, 50))
expect_equal(int_cca[["integrated.cca"]]@assay.used, "RNAv5")
})


#Harmony integration
# int_2 <- IntegrateLayers(object = pbmc_small, method = CCAIntegration,
# group.by = "letter.idents",
# orig.reduction = "pca",
# assay = "RNAv5",
# k.weight = 20,
# new.reduction = "integrated.cca")
#
# head(int_2[['integrated.cca']]@cell.embeddings[1:5,1:5])
# head(int_cca[['integrated.cca']]@cell.embeddings[1:5,1:5])

})
Loading

0 comments on commit 942766a

Please sign in to comment.