Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

highlight_distinct_edges

Highlight distint edges in a tree (compared to another one)


Description

Highlight distint edges in a tree (compared to another one) by changing the branches' color, line width, or line type.

This function enables this feature in dend_diff and tanglegram

Usage

highlight_distinct_edges(dend, ...)

## S3 method for class 'dendrogram'
highlight_distinct_edges(
  dend,
  dend2,
  value = 2,
  edgePar = c("col", "lty", "lwd"),
  ...
)

## S3 method for class 'dendlist'
highlight_distinct_edges(dend, ..., which = c(1L, 2L))

Arguments

dend

a dendrogram or dendlist to find unique edges in (to highlight)

...

Ignored.

dend2

a dendrogram to compare with

value

a new value scalar for the edgePar attribute.

edgePar

a character indicating the value inside edgePar to adjust. Can be either "col", "lty", or "lwd".

which

an integer vector indicating, in the case "dend" is a dendlist, on which of the trees should the modification be performed. If missing - the change will be performed on all of objects in the dendlist.

Value

A dendrogram with modified edges - the distinct ones are changed (color, line width, or line type)

See Also

Examples

x <- 1:5 %>%
  dist() %>%
  hclust() %>%
  as.dendrogram()
y <- set(x, "labels", 5:1)
distinct_edges(x, y)
distinct_edges(y, x)

par(mfrow = c(1, 2))
plot(highlight_distinct_edges(x, y))
plot(y)

# tanglegram(highlight_distinct_edges(x, y),y)
# dend_diff(x, y)
## Not run: 

# using  highlight_distinct_edges combined with dendlist and set
# to clearly highlight "stable" branches.
data(iris)
ss <- c(1:5, 51:55, 101:105)
iris1 <- iris[ss, -5] %>%
  dist() %>%
  hclust(method = "single") %>%
  as.dendrogram()
iris2 <- iris[ss, -5] %>%
  dist() %>%
  hclust(method = "complete") %>%
  as.dendrogram()
iris12 <- dendlist(iris1, iris2) %>%
  set("branches_k_color", k = 3) %>%
  set("branches_lwd", 3) %>%
  highlight_distinct_edges(value = 1, edgePar = "lwd")
iris12 %>%
  untangle(method = "step2side") %>%
  tanglegram(
    sub = "Iris dataset", main_left = "'single' clustering",
    main_right = "'complete' clustering"
  )

## End(Not run)

dendextend

Extending 'dendrogram' Functionality in R

v1.15.1
GPL-2 | GPL-3
Authors
Tal Galili [aut, cre, cph] (https://www.r-statistics.com), Yoav Benjamini [ths], Gavin Simpson [ctb], Gregory Jefferis [aut, ctb] (imported code from his dendroextras package), Marco Gallotta [ctb] (a.k.a: marcog), Johan Renaudie [ctb] (https://github.com/plannapus), The R Core Team [ctb] (Thanks for the Infastructure, and code in the examples), Kurt Hornik [ctb], Uwe Ligges [ctb], Andrej-Nikolai Spiess [ctb], Steve Horvath [ctb], Peter Langfelder [ctb], skullkey [ctb], Mark Van Der Loo [ctb] (https://github.com/markvanderloo d3dendrogram), Andrie de Vries [ctb] (ggdendro author), Zuguang Gu [ctb] (circlize author), Cath [ctb] (https://github.com/CathG), John Ma [ctb] (https://github.com/JohnMCMa), Krzysiek G [ctb] (https://github.com/storaged), Manuela Hummel [ctb] (https://github.com/hummelma), Chase Clark [ctb] (https://github.com/chasemc), Lucas Graybuck [ctb] (https://github.com/hypercompetent), jdetribol [ctb] (https://github.com/jdetribol), Ben Ho [ctb] (https://github.com/SplitInf), Samuel Perreault [ctb] (https://github.com/samperochkin), Christian Hennig [ctb] (http://www.homepages.ucl.ac.uk/~ucakche/), David Bradley [ctb] (https://github.com/DBradley27), Houyun Huang [ctb] (https://github.com/houyunhuang)
Initial release
2021-05-08

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.