# dendextend v1.8.0

Monthly downloads

## Extending 'dendrogram' Functionality in R

Offers a set of functions for extending
'dendrogram' objects in R, letting you visualize and compare trees of
'hierarchical clusterings'. You can (1) Adjust a tree's graphical parameters
- the color, size, type, etc of its branches, nodes and labels. (2)
Visually and statistically compare different 'dendrograms' to one another.

## Readme

# dendextend

**Table of contents:**

- Introduction
- Motivation
- Installation
- Usage
- Share your dendrograms!
- How to cite the dendextend package
- Contact

## Introduction

Class "dendrogram" provides general functions for handling tree-like structures in R. It is intended as a replacement for similar functions in hierarchical clustering and classification/regression trees, such that all of these can use the same engine for plotting or cutting trees.

However, many basic features are still missing from the dendrogram class. This package aims at filling in some gaps.

## Motivation

Extending R core dendrogram functions.

## Installation

To install the stable version on CRAN:

```
install.packages('dendextend')
# install.packages('dendextendRcpp')
```

To install the GitHub version:

```
install.packages.2 <- function (pkg) if (!require(pkg)) install.packages(pkg);
install.packages.2('devtools')
# install.packages.2('Rcpp')
# make sure you have Rtools installed first! if not, then run:
#install.packages('installr'); install.Rtools()
devtools::install_github('talgalili/dendextend')
# devtools::install_github('talgalili/dendextendRcpp')
# Having colorspace is also useful, since it is used
# In various examples in the vignettes
install.packages.2('colorspace')
```

And then you may load the package using:

```
library("dendextend")
# library("dendextendRcpp") # dendextendRcpp is no longer supported (or available on CRAN). Still, dendextend is faster these days, in recent versions of R, thanks to some updates to labels.dendrogram and other modifications to R.
```

## Usage

Vignettes:

- Introduction to dendextend
- Frequently asked questions
- Hierarchical cluster analysis on famous data sets - enhanced with the dendextend package
- Introduction vignette (older) (older)

## Share your dendrograms!

If you have made interesting work using the dendextend package, I would LOVE to know about it. It can be a blog post, an academic paper, or just some plots you made for your work in the industry. Please contact me (see below) with what you have done, and I would also be happy to promote it in this page.

### Usages of dendextend

Packages:

## How to cite the dendextend package

The methods within the code package can be cited as:

```
Tal Galili (2015). dendextend: an R package for visualizing, adjusting, and comparing trees of
hierarchical clustering. Bioinformatics. DOI: 10.1093/bioinformatics/btv428
```

A BibTeX entry for LaTeX users is

```
@Article{,
author = {Tal Galili},
title = {dendextend: an R package for visualizing, adjusting, and comparing trees of hierarchical clustering},
journal = {Bioinformatics},
year = {2015},
doi = {10.1093/bioinformatics/btv428},
url = {https://academic.oup.com/bioinformatics/article/31/22/3718/240978/dendextend-an-R-package-for-visualizing-adjusting},
eprint = {https://academic.oup.com/bioinformatics/article-pdf/31/22/3718/17122682/btv428.pdf},
}
```

This free open-source software implements academic research by the authors and co-workers. If you use it, please support the project by citing the appropriate journal articles.

## Contact

You are welcome to:

- submit suggestions and bug-reports at: https://github.com/talgalili/dendextend/issues
- send a pull request on: https://github.com/talgalili/dendextend/
- compose a friendly e-mail to: tal.galili@gmail.com

## Latest news

You can see the most recent changes to the package in the NEWS.md file

## Code of conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

## Functions in dendextend

Name | Description | |

Bk_plot | Bk plot - ploting the Fowlkes-Mallows Index of two dendrogram for various k's | |

cor_FM_index | Correlation of FM_index for some k | |

cor.dendlist | Correlation matrix between a list of trees. | |

d3dendro_options | Get or set current defaults for d3dendrogram | |

d3dendrogram | Plot dendrogram to webpage and view. | |

dist.dendlist | Topological Distances Between Two dendrograms | |

dist_long | Turns a dist object to a "long" table | |

get_leaves_attr | Get/set attributes of dendrogram's leaves | |

get_leaves_branches_attr | Get an attribute of the branches of a dendrogram's leaves | |

get_subdendrograms | Extract a list of k subdendrograms from a given dendrogram object | |

ggdend | Creates dendrogram plot using ggplot. | |

khan | Microarray gene expression dataset from Khan et al., 2001. Subset of 306 genes. | |

labels<- | "label" assignment operator | |

nleaves | Counts the number of leaves in a tree | |

rank_branches | Rank branches' heights | |

nnodes | Counts the number of nodes (Vertices) in a tree | |

rank_order.dendrogram | Fix rank of leaves order values in a dendrogram | |

remove_branches_edgePar | Remove all edgePar values from a dendrogram's branches | |

remove_leaves_nodePar | Remove all nodePar values from a dendrogram's leaves | |

tanglegram | Tanglegram plot | |

theme_dendro | Creates completely blank theme in ggplot | |

untangle_step_rotate_2side | Stepwise untangle two trees one at a time | |

all.equal.dendrogram | Global Comparison of two (or more) dendrograms | |

all_couple_rotations_at_k | Rotate tree branches for k | |

Bk | Bk - Calculating Fowlkes-Mallows Index for two dendrogram | |

which_leaf | Which node is a leaf? | |

Bk_permutations | Bk permutation - Calculating Fowlkes-Mallows Index for two dendrogram | |

as.dendlist | Try to coerce something into a dendlist | |

all_unique | Check if all the elements in a vector are unique | |

as.phylo.dendrogram | Convert a dendrogram into phylo | |

click_rotate | Interactively rotate a tree object | |

collapse_branch | Collapse branches under a tolerance level | |

cor_bakers_gamma | Baker's Gamma correlation coefficient | |

cor_common_nodes | Proportion of commong nodes between two trees | |

as_hclust_fixed | Convert dendrogram Objects to Class hclust | |

branches_attr_by_clusters | Change col/lwd/lty of branches based on clusters | |

dendlist | Creating a dendlist object from several dendrograms | |

branches_attr_by_labels | Change col/lwd/lty of branches matching labels condition | |

FM_index_profdpm | Calculating Fowlkes-Mallows index using the profdpm R package | |

FM_index_permutation | Calculating Fowlkes-Mallows Index under H0 | |

dendextend_labels.dendrogram | Labels of the Leaves in a Dendrogram | |

assign_values_to_leaves_nodePar | Assign values to nodePar of dendrogram's leaves | |

color_labels | Color dend's labels according to sub-clusters | |

dend_expend | Finds a "good" dendrogram for a dist | |

dendextend_options | Access to dendextend_options | |

color_branches | Color tree's branches according to sub-clusters | |

count_terminal_nodes | Counts the number of terminal nodes (merging 0 nodes!) | |

cor_cophenetic | Cophenetic correlation between two trees | |

assign_values_to_leaves_edgePar | Assign values to edgePar of dendrogram's leaves | |

colored_dots | Add colored dots beside a dendrogram | |

find_dendrogram | Search for the subdendrogram structure composed of indicated labels | |

get_branches_heights | Get height attributes from a dendrogram | |

common_subtrees_clusters | Find clusters of common subtrees | |

dend_diff | Plots two trees side by side, highlighting edges unique to each tree in red. | |

get_childrens_heights | Get height attributes from a dendrogram's children | |

min_depth | Find minimum/maximum depth of a dendrogram | |

find_k | Find the (estimated) number of clusters for a dendrogram using average silhouette width | |

fix_members_attr.dendrogram | Fix members attr in a dendrogram | |

entanglement | Measures entanglement between two trees | |

dendextend-package | Functions for extending dendrogram objects | |

get_leaves_edgePar | Get edgePar of dendrogram's leaves | |

get_leaves_branches_col | Get the colors of the branches of a dendrogram's leaves | |

hang.dendrogram | Hang dendrogram leaves | |

heights_per_k.dendrogram | Which height will result in which k for a dendrogram | |

highlight_branches_col | Highlight a dendrogram's branches heights via color and line-width | |

fac2num | Turns a factor into a number | |

has_component_in_attribute | Does a dendrogram has an edgePar/nodePar component? | |

ladderize | Ladderize a Tree | |

leaf_Colors | Return the leaf Colors of a dendrogram | |

labels_cex | Retrieve/assign cex to the labels of a dendrogram | |

order.hclust | Ordering of the Leaves in a hclust Dendrogram | |

get_leaves_nodePar | Get nodePar of dendrogram's leaves | |

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

get_nodes_attr | Get attributes of dendrogram's nodes | |

identify.dendrogram | Identify Clusters in a Dendrogram (not hclust) | |

is_null_list | Checks if the value is and empty list() | |

is_some_class | Is the object of some class | |

noded_with_condition | Find which nodes satisfies a condition | |

order.dendrogram<- | order.dendrogram<- assignment operator | |

labels_colors | Retrieve/assign colors to the labels of a dendrogram | |

partition_leaves | A list with labels for each subtree (edge) | |

pvrect2 | Draw Rectangles Around a Dendrogram's Clusters with High/Low P-values | |

lowest_common_branch | Find lowest common branch were the two items are shared | |

FM_index | Calculating Fowlkes-Mallows Index | |

match_order_by_labels | Adjust the order of one dendrogram based on another (using labels) | |

plot_horiz.dendrogram | Plotting a left-tip-adjusted horizontal dendrogram | |

prune | Prunes a tree (using leaves' labels) | |

raise.dendrogram | Raise the height of a dendrogram tree | |

rotate_DendSer | Rotates dend based on DendSer | |

reexports | Objects exported from other packages | |

rotate | Rotate a tree object | |

prune_common_subtrees.dendlist | Prune trees to their common subtrees | |

FM_index_R | Calculating Fowlkes-Mallows index in R | |

assign_values_to_nodes_nodePar | Assign values to nodePar of dendrogram's nodes | |

sort_dist_mat | Sorts a distance matrix by rows and columns names | |

bakers_gamma_for_2_k_matrix | Bakers Gamma for two k matrices | |

prune_leaf | Trims one leaf from a dendrogram | |

color_unique_labels | Color unique labels in a dendrogram | |

reindex_dend | Reindexing a pruned dendrogram | |

rank_values_with_clusters | Rank a vector based on clusters | |

colored_bars | Add colored bars to a dendrogram | |

rect.dendrogram | Draw Rectangles Around a Dendrogram's Clusters | |

sort_levels_values | Sort the values level in a vector | |

untangle | untangle dendrograms | |

sort_2_clusters_vectors | Sorts two clusters vector by their names | |

untangle_DendSer | Tries to run DendSer on a dendrogram | |

unbranch | unbranch trees | |

shuffle | Random rotation of trees | |

cut_lower_fun | Cut a dendrogram - and run a function on the output | |

unclass_dend | unclass an entire dendrogram tree | |

cutree | Cut a Tree (Dendrogram/hclust/phylo) into Groups of Data | |

cutree_1h.dendrogram | cutree for dendrogram (by 1 height only!) | |

set_labels | Set/place new labels in a dendrogram | |

cutree_1k.dendrogram | cutree for dendrogram (by 1 k value only!) | |

set | Set (/update) features to a dendrogram | |

duplicate_leaf | Duplicate a leaf X times | |

distinct_edges | Finds distinct edges in one tree compared to another | |

untangle_random_search | Untangle - random search | |

flatten.dendrogram | Flatten the branches of a dendrogram's root | |

untangle_step_rotate_1side | Stepwise untangle one tree compared to another | |

flip_leaves | Flip leaves | |

get_root_branches_attr | get attributes from the dendrogram's root(!) branches | |

get_nodes_xy | Get the x-y coordinates of a dendrogram's nodes | |

intersect_trees | Intersect trees | |

is.natural.number | Check if numbers are natural | |

match_order_dendrogram_by_old_order | Adjust the order of one dendrogram based on another (using order) | |

na_locf | Last Observation Carried Forward | |

pvclust_show_signif | The significant branches in a dendrogram, based on a pvclust object | |

pvclust_show_signif_gradient | Significance gradient of branches in a dendrogram (via pvclust) | |

remove_nodes_nodePar | Remove all nodePar values from a dendrogram's nodes | |

rllply | recursivly apply a function on a list | |

sample.dendrogram | Sample a tree | |

seriate_dendrogram | Rotates a dendrogram based on a seriation of a distance matrix | |

which_node | Which node id is common to a group of labels | |

branches_attr_by_lists | Change col/lwd/lty of branches from the root down to clusters defined by list of labels of respective members | |

circlize_dendrogram | Plot a circlized dendrograms | |

assign_dendextend_options | Populates dendextend functions into dendextend_options | |

assign_values_to_branches_edgePar | Assign values to edgePar of dendrogram's branches | |

DendSer.dendrogram | Tries to run DendSer on a dendrogram | |

No Results! |

## Vignettes of dendextend

Name | ||

disabled/dendextend-tutorial.rnw | ||

Cluster_Analysis.Rmd | ||

FAQ.Rmd | ||

Quick_Introduction.Rmd | ||

introduction.Rmd | ||

No Results! |

## Last month downloads

## Details

Type | Package |

Date | 2018-04-28 |

VignetteBuilder | knitr |

LazyData | true |

License | GPL-2 | GPL-3 |

URL | https://github.com/talgalili/dendextend/, https://cran.r-project.org/package=dendextend, https://www.r-statistics.com/tag/dendextend/, https://academic.oup.com/bioinformatics/article/31/22/3718/240978/dendextend-an-R-package-for-visualizing-adjusting |

BugReports | https://github.com/talgalili/dendextend/issues |

RoxygenNote | 6.0.1 |

NeedsCompilation | no |

Packaged | 2018-05-02 06:23:53 UTC; junior |

Repository | CRAN |

Date/Publication | 2018-05-03 11:02:48 UTC |

suggests | ape , circlize (>= 0.2.5) , cluster , colorspace , corrplot , covr , d3heatmap , DendSer , dynamicTreeCut , gplots , heatmaply , knitr , MASS , microbenchmark , plyr , profdpm , pvclust , rmarkdown , seriation , testthat |

enhances | data.table , dendroextras , ggdendro , Hmisc , rpart |

imports | datasets , fpc , ggplot2 , magrittr (>= 1.0.1) , stats , utils , viridis , whisker |

depends | R (>= 3.0.0) |

Contributors | skullkey, Gavin Simpson, Manuela Hummel, Steve Horvath, Peter Langfelder, Gregory Jefferis, Mark der Loo, the R Core Team, Kurt Hornik, Uwe Ligges, Andrie Vries, Marco Gallotta, Johan Renaudie, Andrej-Nikolai Spiess, Zuguang Gu, Yoav Benjamini, Cath , John Ma, Krzysiek G, Chase Clark |

#### Include our badge in your README

```
[![Rdoc](http://www.rdocumentation.org/badges/version/dendextend)](http://www.rdocumentation.org/packages/dendextend)
```