Skip to content

Commit

Permalink
Add test case for image.type to test_load_10X.R
Browse files Browse the repository at this point in the history
  • Loading branch information
dcollins15 committed Dec 20, 2024
1 parent 2885752 commit f966fc3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/testthat/test_load_10X.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,31 @@ test_that("Read10X_Image works as expected", {
)
# the size of the two images should be different
expect_false(all(dim(image.hires) == dim(image.lowres)))

# `VisiumV1` image
image.v1 <- Read10X_Image(
path.to.image,
image.name = "tissue_lowres_image.png",
image.type = "VisiumV1"
)
coordinates <- GetTissueCoordinates(image.v1, scale = "lowres")
spot.radius <- Radius(image.v1, scale = "lowres")
scale.factors <- ScaleFactors(image.v1)
# check that the scale factors were read in as expected
expect_true(identical(scale.factors, scale.factors.expected))
# check that `coordinates` contains values scaled for the low resolution PNG
# also make sure that it has the expected column names
coordinates.expected.v1 <- coordinates.expected
colnames(coordinates.expected.v1) <- c("imagerow", "imagecol")
expect_equal(
coordinates[, c("imagerow", "imagecol")] / scale.factors[["lowres"]],
coordinates.expected.v1
)
# check that the spot size is similarly scaled
expect_equal(
(spot.radius / scale.factors[["lowres"]] * max(dim(image.lowres))),
scale.factors.expected[["spot"]],
)
}
})

Expand Down

0 comments on commit f966fc3

Please sign in to comment.