dendextend (version 1.8.0)

collapse_branch: Collapse branches under a tolerance level

Description

Collapse branches under a tolerance level

Usage

collapse_branch(dend, tol = 1e-08, lower = TRUE, ...)

Arguments

dend

dendrogram object

tol

a numeric value giving the tolerance to consider a branch length significantly greater than zero

lower

logical (TRUE). collapse branches which are lower than tol?

...

passed on (not used)

Value

A dendrogram with both of the root's branches of the same height

See Also

multi2di

Examples

Run this code
# NOT RUN {
# # ladderize is like sort(..., type = "node")
dend <- iris[1:5,-5] %>% dist %>% hclust %>% as.dendrogram 
par(mfrow = c(1,3))
dend %>% ladderize %>% plot(horiz = TRUE); abline(v = .2, col = 2, lty = 2)
dend %>% collapse_branch(tol = 0.2) %>% ladderize %>% plot(horiz = TRUE)
dend %>% collapse_branch(tol = 0.2) %>% ladderize %>% 
      hang.dendrogram(hang = 0) %>% plot(horiz = TRUE)

par(mfrow = c(1,2))
dend %>% collapse_branch(tol = 0.2, lower = FALSE) %>% plot(horiz = TRUE, main = "dendrogram")
library(ape)
dend %>% as.phylo %>% di2multi(tol = 0.2) %>% plot(main = "phylo")
# }

Run the code above in your browser using DataCamp Workspace