Skip to content

Commit

Permalink
chore: add initial join tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jiajic committed Aug 30, 2024
1 parent 52cf472 commit c60c130
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/testthat/test-networks.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 57 additions & 0 deletions tests/testthat/test_join.R
Original file line number Diff line number Diff line change
@@ -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
# })

0 comments on commit c60c130

Please sign in to comment.