-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
181 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file is part of the standard setup for testthat. | ||
# It is recommended that you do not modify it. | ||
# | ||
# Where should you do additional test configuration? | ||
# Learn more about the roles of various files in: | ||
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview | ||
# * https://testthat.r-lib.org/articles/special-files.html | ||
|
||
library(testthat) | ||
library(ggheat) | ||
|
||
test_check("ggheat") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
testthat::test_that("`activate and deactivate work well`", { | ||
p <- ggheat(1:10) | ||
expect_identical(get_context(p), NULL) | ||
for (position in GGHEAT_ELEMENTS) { | ||
expect_no_error(p2 <- activate(p, position)) | ||
expect_identical(get_context(p2), position) | ||
} | ||
expect_error(activate(p, NULL)) | ||
expect_identical(deactivate(p2), p) | ||
}) | ||
|
||
testthat::test_that("`active` adding works well", { | ||
p <- ggheat(1:10) | ||
for (position in GGHEAT_ELEMENTS) { | ||
expect_no_error(p2 <- p + active(position)) | ||
expect_identical(unclass(get_context(p2)), position) | ||
} | ||
expect_identical(p2 + active(), p) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
testthat::test_that("`ggheat` works well", { | ||
expect_snapshot_file(save_png(ggheat(1:10)), "numeric.png") | ||
expect_identical(ncol(ggheat(1:10)@matrix), 1L) | ||
expect_snapshot_file(save_png(ggheat(letters)), "character.png") | ||
expect_identical(ncol(ggheat(letters)@matrix), 1L) | ||
expect_snapshot_file(save_png(ggheat(matrix(1:9, nrow = 3L))), "matrix.png") | ||
expect_snapshot_file(save_png(ggheat(data.frame(1:10))), "data_rame.png") | ||
expect_error(ggheat(NULL)) | ||
}) | ||
|
||
testthat::test_that("`ggheat_build` works well", { | ||
p <- ggheat(1:10) | ||
expect_s3_class(ggheat_build(p), "patchwork") | ||
}) | ||
|
||
testthat::test_that("`ggplot` method works well", { | ||
p <- ggheat(1:10) | ||
expect_no_error(ggplot2::ggplot_build(p)) | ||
expect_no_error(ggplot2::ggsave(tempfile(fileext = ".png"), plot = p)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
testthat::test_that("`htanno_group` works well", { | ||
set.seed(1L) | ||
p <- ggheat(matrix(stats::rnorm(72L), nrow = 9L)) | ||
row_group <- sample(letters[1:3], 9, replace = TRUE) | ||
column_group <- sample(letters[1:3], 8, replace = TRUE) | ||
expect_error(p + htanno_group(column_group)) | ||
expect_error(p + htanno_group(1:4, "t")) | ||
expect_error(p + htanno_group(row_group, "t")) | ||
|
||
expect_snapshot_file( | ||
save_png(p + htanno_group(column_group, "t")), "group_top.png" | ||
) | ||
expect_snapshot_file( | ||
save_png(p + htanno_group(column_group, "b")), "group_bottom.png" | ||
) | ||
expect_snapshot_file( | ||
save_png(p + htanno_group(row_group, "l")), "group_left.png" | ||
) | ||
expect_snapshot_file( | ||
save_png(p + htanno_group(row_group, "r")), "group_right.png" | ||
) | ||
# cannot do sub-group | ||
expect_error(p + htanno_group(row_group, "t") + htanno_group(row_group)) | ||
}) | ||
|
||
testthat::test_that("`htanno_reorder` works well", { | ||
set.seed(1L) | ||
p <- ggheat(matrix(stats::rnorm(72L), nrow = 9L)) | ||
row_group <- sample(letters[1:3], 9, replace = TRUE) | ||
column_group <- sample(letters[1:3], 8, replace = TRUE) | ||
expect_snapshot_file( | ||
save_png(p + htanno_reorder(position = "t")), "reorder_top.png" | ||
) | ||
expect_snapshot_file( | ||
save_png(p + htanno_reorder(position = "b")), "reorder_bottom.png" | ||
) | ||
expect_snapshot_file( | ||
save_png(p + htanno_reorder(position = "l")), "reorder_left.png" | ||
) | ||
expect_snapshot_file( | ||
save_png(p + htanno_reorder(position = "r")), "reorder_right.png" | ||
) | ||
expect_error(p + htanno_group(column_group, "t") + htanno_reorder()) | ||
expect_snapshot_file( | ||
save_png(p + htanno_group(column_group, "t") + | ||
htanno_reorder(strict = FALSE)), | ||
"reorder_top_within_group.png" | ||
) | ||
expect_snapshot_file( | ||
save_png(p + htanno_reorder(position = "t", decreasing = TRUE)), | ||
"reorder_top_decreasing.png" | ||
) | ||
expect_snapshot_file( | ||
save_png(p + htanno_reorder(position = "l", decreasing = TRUE)), | ||
"reorder_left_decreasing.png" | ||
) | ||
}) | ||
|
||
testthat::test_that("`htanno_kmeans` works well", { | ||
set.seed(1L) | ||
p <- ggheat(matrix(stats::rnorm(72L), nrow = 9L)) | ||
row_group <- sample(letters[1:3], 9, replace = TRUE) | ||
column_group <- sample(letters[1:3], 8, replace = TRUE) | ||
expect_snapshot_file( | ||
save_png(p + htanno_kmeans(3L, position = "t")), "kmeans_top.png" | ||
) | ||
expect_snapshot_file( | ||
save_png(p + htanno_kmeans(5L, position = "b")), "kmeans_bottom.png" | ||
) | ||
expect_snapshot_file( | ||
save_png(p + htanno_kmeans(4L, position = "l")), "kmeans_left.png" | ||
) | ||
expect_snapshot_file( | ||
save_png(p + htanno_kmeans(2L, position = "r")), "kmeans_right.png" | ||
) | ||
expect_error(p + htanno_group(column_group, "t") + htanno_kmeans(3L)) | ||
expect_error(p + htanno_group(row_group, "l") + htanno_kmeans(3L)) | ||
}) | ||
|
||
testthat::test_that("`htanno_dendro` works well", { | ||
set.seed(1L) | ||
p <- ggheat(matrix(stats::rnorm(72L), nrow = 9L)) | ||
row_group <- sample(letters[1:3], 9, replace = TRUE) | ||
column_group <- sample(letters[1:3], 8, replace = TRUE) | ||
expect_snapshot_file( | ||
save_png(p + htanno_dendro(position = "t")), "dendro.png" | ||
) | ||
expect_snapshot_file( | ||
save_png(p + htanno_dendro(k = 3L, position = "t")), "dendro_cutree.png" | ||
) | ||
expect_error(p + htanno_group(column_group, "t") + htanno_dendro(k = 3L)) | ||
expect_error(p + htanno_group(column_group, "t") + htanno_dendro(h = 3L)) | ||
expect_snapshot_file( | ||
save_png(p + htanno_group(column_group, "t") + htanno_dendro()), | ||
"dendro_top_between_group.png" | ||
) | ||
expect_snapshot_file( | ||
save_png(p + htanno_group(row_group, "l") + | ||
htanno_dendro(reorder_group = TRUE)), | ||
"dendro_left_between_group_reorder.png" | ||
) | ||
}) |