File: collapse_branch.Rd

package info (click to toggle)
r-cran-dendextend 1.14.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,888 kB
  • sloc: sh: 13; makefile: 2
file content (58 lines) | stat: -rw-r--r-- 1,352 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/unbranch.R
\name{collapse_branch}
\alias{collapse_branch}
\title{Collapse branches under a tolerance level}
\usage{
collapse_branch(dend, tol = 1e-08, lower = TRUE, ...)
}
\arguments{
\item{dend}{dendrogram object}

\item{tol}{a numeric value giving the tolerance to consider a branch length significantly greater than zero}

\item{lower}{logical (TRUE). collapse branches which are lower than tol?}

\item{...}{passed on (not used)}
}
\value{
A dendrogram with both of the root's branches of the same height
}
\description{
Collapse branches under a tolerance level
}
\examples{

# # 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")
}
\seealso{
\link[ape]{multi2di}
}