From c60c130637f94b8b2babb107b253fe392c75d69c Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:45:13 -0400 Subject: [PATCH] chore: add initial join tests --- tests/testthat/test-networks.R | 2 +- tests/testthat/test_join.R | 57 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tests/testthat/test_join.R diff --git a/tests/testthat/test-networks.R b/tests/testthat/test-networks.R index 100e4aed..560c37da 100644 --- a/tests/testthat/test-networks.R +++ b/tests/testthat/test-networks.R @@ -3,7 +3,7 @@ lifecycle_opt <- getOption("lifecycle_verbosity") options("lifecycle_verbosity" = "quiet") # ignore conda -options("giotto.has_conda" = FALSE) +options("giotto.use_conda" = FALSE) # load data to test diff --git a/tests/testthat/test_join.R b/tests/testthat/test_join.R new file mode 100644 index 00000000..4dcf98e1 --- /dev/null +++ b/tests/testthat/test_join.R @@ -0,0 +1,57 @@ +options("giotto.use_conda" = FALSE) +g <- GiottoData::loadGiottoMini("vis") +nobs <- nrow(pDataDT(g)) +nvar <- nrow(fDataDT(g)) + +test_that("visium can join", { + # remove to avoid warning about incorrect networks after spatloc edits + g@spatial_network <- NULL + + j <- joinGiottoObjects( + gobject_list = list(g, g, g), + gobject_names = letters[seq_len(3)] + ) + + checkmate::expect_class(j, "giotto") + expect_equal(nrow(pDataDT(j)), nobs * 3) + expect_equal(nrow(fDataDT(j)), nvar) + + # TODO check spatial +}) + +test_that("expression and spatloc join", { + gtest <- suppressWarnings(giotto()) + gtest <- setGiotto(gtest, getExpression(g), verbose = FALSE) + gtest <- setGiotto(gtest, getSpatialLocations(g), verbose = FALSE) + + j <- joinGiottoObjects( + gobject_list = list(gtest, gtest, gtest), + gobject_names = letters[seq_len(3)] + ) + + checkmate::expect_class(j, "giotto") + expect_equal(nrow(pDataDT(j)), nobs * 3) + expect_equal(nrow(fDataDT(j)), nvar) + + # TODO check spatial +}) + +# test_that("poly and spatloc join", { +# gtest <- suppressWarnings(giotto()) +# gtest <- setGiotto(gtest, getPolygonInfo(g, +# return_giottoPolygon = TRUE), +# verbose = FALSE +# ) +# gtest <- setGiotto(gtest, getSpatialLocations(g), verbose = FALSE) +# +# j <- joinGiottoObjects( +# gobject_list = list(gtest, gtest, gtest), +# gobject_names = letters[seq_len(3)] +# ) +# +# checkmate::expect_class(j, "giotto") +# expect_equal(nrow(pDataDT(j)), nobs * 3) +# expect_equal(nrow(fDataDT(j)), nvar) +# +# # TODO check spatial +# })