Debian Codegraph @

tests/testthat/test-highlight_branches.R

raw
1 # library(testthat)
2
3 context("highlight_branches")
4
5
6 test_that("highlight_branches can be run", {
7 dat <- iris[1:3, -5]
8 hca <- hclust(dist(dat))
9 dend <- as.dendrogram(hca)
10 dend2 <- dend %>% highlight_branches()
11 # plot(dend2)
12
13 # dput(dend2)
14 dend_expected <- structure(list(
15 structure(1L, members = 1L, height = 0, label = "1", leaf = TRUE, edgePar = structure(list(
16 col = "#BBDF27FF", lwd = 1
17 ), .Names = c("col", "lwd"))),
18 structure(list(
19 structure(2L, label = "2", members = 1L, height = 0, leaf = TRUE, edgePar = structure(list(
20 col = "#BBDF27FF", lwd = 1
21 ), .Names = c("col", "lwd"))),
22 structure(3L, label = "3", members = 1L, height = 0, leaf = TRUE, edgePar = structure(list(
23 col = "#BBDF27FF", lwd = 1
24 ), .Names = c("col", "lwd")))
25 ), members = 2L, midpoint = 0.5, height = 0.3, edgePar = structure(list(
26 col = "#2A788EFF", lwd = 6.01801801801802
27 ), .Names = c(
28 "col",
29 "lwd"
30 )))
31 ), members = 3L, midpoint = 0.75, height = 0.53851648071345, edgePar = structure(list(
32 col = "#440154FF", lwd = 10
33 ), .Names = c("col", "lwd")), class = "dendrogram")
34
35
36 expect_equal(dend2, dend_expected)
37 # expect_identical(dend2, dend_expected)
38
39 # if non dendrogram object is passed in
40 expect_error(
41 highlight_branches(hca)
42 )
43
44 })