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

branches_attr_by_labels

Change col/lwd/lty of branches matching labels condition


Description

The user supplies a dend, labels, and type of condition (all/any), and TF_values And the function returns a dendrogram with branches col/lwd/lty accordingly

Usage

branches_attr_by_labels(
  dend,
  labels,
  TF_values = c(2, Inf),
  attr = c("col", "lwd", "lty"),
  type = c("all", "any"),
  ...
)

Arguments

dend

a dendrogram dend

labels

a character vector of labels from the tree

TF_values

a two dimensional vector with the TF_values to use in case a branch fulfills the condition (TRUE) and in the case that it does not (FALSE). Defaults are 2/Inf for col, lwd and lty. (so it will insert the first value, and will not change all the FALSE cases)

attr

a character with one of the following values: col/lwd/lty

type

a character vector of either "all" or "any", indicating which of the branches should be painted: ones that all of their labels belong to the supplied labels, or also ones that even some of their labels are included in the labels vector.

...

ignored.

Value

A dendrogram with modified branches (col/lwd/lty).

See Also

Examples

## Not run: 

library(dendextend)

set.seed(23235)
ss <- sample(1:150, 10)

# Getting the dend dend
dend <- iris[ss, -5] %>%
  dist() %>%
  hclust() %>%
  as.dendrogram()
dend %>% plot()

dend %>%
  branches_attr_by_labels(c("123", "126", "23", "29")) %>%
  plot()
dend %>%
  branches_attr_by_labels(c("123", "126", "23", "29"), "all") %>%
  plot() # the same as above
dend %>%
  branches_attr_by_labels(c("123", "126", "23", "29"), "any") %>%
  plot()

dend %>%
  branches_attr_by_labels(
    c("123", "126", "23", "29"),
    "any", "col", c("blue", "red")
  ) %>%
  plot()
dend %>%
  branches_attr_by_labels(
    c("123", "126", "23", "29"),
    "any", "lwd", c(4, 1)
  ) %>%
  plot()
dend %>%
  branches_attr_by_labels(
    c("123", "126", "23", "29"),
    "any", "lty", c(2, 1)
  ) %>%
  plot()

## 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.