if (FALSE) {
set.seed(23235)
ss <- sample(1:150, 10)
dend1 <- iris[ss, -5] %>%
dist() %>%
hclust("com") %>%
as.dendrogram()
dend2 <- iris[ss, -5] %>%
dist() %>%
hclust("sin") %>%
as.dendrogram()
dend12 <- dendlist(dend1, dend2)
dend12 %>% tanglegram()
tanglegram(dend1, dend2)
tanglegram(dend1, dend2, sort = TRUE)
tanglegram(dend1, dend2, remove_nodePar = TRUE)
tanglegram(dend1, dend2, k_labels = 6, k_branches = 4)
tanglegram(dend1, dend2,
lab.cex = 2, edge.lwd = 3,
margin_inner = 5, type = "t", center = TRUE
)
## works nicely:
tanglegram(dend1, dend2,
lab.cex = 2, edge.lwd = 3,
margin_inner = 3.5, type = "t", center = TRUE,
dLeaf = -0.1, xlim = c(7, 0),
k_branches = 3
)
# using rank_branches can make the comparison even easier
tanglegram(rank_branches(dend1), rank_branches(dend2),
lab.cex = 2, edge.lwd = 3,
margin_inner = 3.5, type = "t", center = TRUE,
dLeaf = -0.1, xlim = c(5.1, 0), columns_width = c(5, 1, 5),
k_branches = 3
)
########
## Nice example of some colored trees
# see the coloring of common sub trees:
set.seed(23235)
ss <- sample(1:150, 10)
dend1 <- iris[ss, -5] %>%
dist() %>%
hclust("com") %>%
as.dendrogram()
dend2 <- iris[ss, -5] %>%
dist() %>%
hclust("sin") %>%
as.dendrogram()
dend12 <- dendlist(dend1, dend2)
# dend12 %>% untangle %>% tanglegram
dend12 %>% tanglegram(common_subtrees_color_branches = TRUE)
set.seed(22133513)
ss <- sample(1:150, 10)
dend1 <- iris[ss, -5] %>%
dist() %>%
hclust("com") %>%
as.dendrogram()
dend2 <- iris[ss, -5] %>%
dist() %>%
hclust("sin") %>%
as.dendrogram()
dend12 <- dendlist(dend1, dend2)
# dend12 %>% untangle %>% tanglegram
dend12 %>% tanglegram(common_subtrees_color_branches = TRUE)
dend12 %>% tanglegram()
}
Run the code above in your browser using DataLab