Learn R Programming

dendextend

dendextend website (built using pkgdown)

Table of contents:

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.

The dendextend package extending R core dendrogram functions.

Installation

To install and load dendextend, simply use:

install.packages('dendextend') # stable CRAN version
library("dendextend") # load the package

Usage

Vignettes:

Also ceck out the dendextend tag in stackoverflow for more examples.

A notable sister package for dendextend is heatmaply for creating interactive cluster heatmaps using R (combining dendextend and plotly).

Getting help

Please post your question to stackoverflow using the tags: dendextend and r.

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://doi.org/10.1093/bioinformatics/btv428},
   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.

Submitting bug reports and patches

You are welcome to:

Before reporting bugs, please make sure you're using the latest version from github:

install.packages.2 <- function (pkg) {
   if (!require(pkg, character.only = TRUE)) 
   install.packages(pkg, character.only = TRUE)
   }
install.packages('remotes')
remotes::install_github('talgalili/dendextend')

# Having colorspace is also useful, since it is used
# In various examples in the vignettes
install.packages.2('colorspace')

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.

Copy Link

Version

Install

install.packages('dendextend')

Monthly Downloads

101,127

Version

1.18.1

License

GPL-2 | GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

October 13th, 2024

Functions in dendextend (1.18.1)

assign_values_to_leaves_nodePar

Assign values to nodePar of dendrogram's leaves
assign_values_to_nodes_nodePar

Assign values to nodePar of dendrogram's nodes
circlize_dendrogram

Plot a circlized dendrograms
branches_attr_by_lists

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

Change col/lwd/lty of branches matching labels condition
click_rotate

Interactively rotate a tree object
collapse_branch

Collapse branches under a tolerance level
collapse_labels

Collapse a sub dendrogram of adjacent labels within a dend
colored_bars

Add colored bars to a dendrogram
color_unique_labels

Color unique labels in a dendrogram
cor_bakers_gamma

Baker's Gamma correlation coefficient
color_branches

Color tree's branches according to sub-clusters
cutree

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

Add colored dots beside a dendrogram
color_labels

Color dend's labels according to sub-clusters
cut_lower_fun

Cut a dendrogram - and run a function on the output
cor.dendlist

Correlation matrix between a list of trees.
cor_FM_index

Correlation of FM_index for some k
count_terminal_nodes

Counts the number of terminal nodes (merging 0 nodes!)
cor_cophenetic

Cophenetic correlation between two trees
distinct_edges

Finds distinct edges in one tree compared to another
cor_common_nodes

Proportion of commong nodes between two trees
dist_long

Turns a dist object to a "long" table
common_subtrees_clusters

Find clusters of common subtrees
dendextend-package

Functions for extending dendrogram objects
dendextend_options

Access to dendextend_options
dend_diff

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

Find minimum/maximum depth of a dendrogram
dist.dendlist

Topological Distances Between Two dendrograms
dendlist

Creating a dendlist object from several dendrograms
fix_members_attr.dendrogram

Fix members attr in a dendrogram
flatten.dendrogram

Flatten the branches of a dendrogram's root
dend_expend

Finds a "good" dendrogram for a dist
fac2num

Turns a factor into a number
find_dendrogram

Search for the sub-dendrogram structure composed of selected labels
entanglement

Measures entanglement between two trees
duplicate_leaf

Duplicate a leaf X times
get_root_branches_attr

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

Extract a list of k subdendrograms from a given dendrogram object
get_leaves_nodePar

Get nodePar of dendrogram's leaves
flip_leaves

Flip leaves
get_branches_heights

Get height attributes from a dendrogram
get_leaves_edgePar

Get edgePar of dendrogram's leaves
get_childrens_heights

Get height attributes from a dendrogram's children
get_leaves_attr

Get/set attributes of dendrogram's leaves
has_component_in_attribute

Does a dendrogram has an edgePar/nodePar component?
heights_per_k.dendrogram

Which height will result in which k for a dendrogram
is.natural.number

Check if numbers are natural
highlight_branches_col

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

Get the colors of the branches of a dendrogram's leaves
cutree_1h.dendrogram

cutree for dendrogram (by 1 height only!)
get_leaves_branches_attr

Get an attribute of the branches of a dendrogram's leaves
labels<-

"label" assignment operator
highlight_distinct_edges

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

cutree for dendrogram (by 1 k value only!)
ladderize

Ladderize a Tree
labels_colors

Retrieve/assign colors to the labels of a dendrogram
identify.dendrogram

Identify Clusters in a Dendrogram (not hclust)
labels_cex

Retrieve/assign cex to the labels of a dendrogram
ggdend

Creates dendrogram plot using ggplot.
is_some_class

Is the object of some class
khan

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

Intersect trees
lowest_common_branch

Find lowest common branch were the two items are shared
is_null_list

Checks if the value is and empty list()
leaf_Colors

Return the leaf Colors of a dendrogram
order.dendrogram<-

order.dendrogram<- assignment operator
order.hclust

Ordering of the Leaves in a hclust Dendrogram
na_locf

Last Observation Carried Forward
hang.dendrogram

Hang dendrogram leaves
rank_values_with_clusters

Rank a vector based on clusters
prune_leaf

Trims one leaf from a dendrogram
pvclust_edges

Get Pvclust Edges Information
reexports

Objects exported from other packages
reindex_dend

Reindexing a pruned dendrogram
rect.dendrogram

Draw Rectangles Around a Dendrogram's Clusters
get_nodes_attr

Get attributes of dendrogram's nodes
match_order_by_labels

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

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

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

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

Counts the number of nodes (Vertices) in a tree
noded_with_condition

Find which nodes satisfies a condition
nleaves

Counts the number of leaves in a tree
pvclust_show_signif

The significant branches in a dendrogram, based on a pvclust object
prune

Prunes a tree (using leaves' labels)
pvclust_show_signif_gradient

Significance gradient of branches in a dendrogram (via pvclust)
prune_common_subtrees.dendlist

Prune trees to their common subtrees
rotate_DendSer

Rotates dend based on DendSer
rotate

Rotate a tree object
pvrect2

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

Rotates a dendrogram based on a seriation of a distance matrix
sample.dendrogram

Sample a tree
set

Set (/update) features to a dendrogram
tanglegram

Tanglegram plot
set_labels

Set/place new labels in a dendrogram
theme_dendro

Creates completely blank theme in ggplot
remove_branches_edgePar

Remove all edgePar values from a dendrogram's branches
remove_leaves_nodePar

Remove all nodePar values from a dendrogram's leaves
raise.dendrogram

Raise the height of a dendrogram tree
untangle_DendSer

Tries to run DendSer on a dendrogram
sort_dist_mat

Sorts a distance matrix by rows and columns names
which_leaf

Which node is a leaf?
untangle

untangle dendrograms
sort_levels_values

Sort the values level in a vector
which_node

Which node id is common to a group of labels
partition_leaves

A list with labels for each subtree (edge)
plot_horiz.dendrogram

Plotting a left-tip-adjusted horizontal dendrogram
rank_branches

Rank branches' heights
rank_order.dendrogram

Fix rank of leaves order values in a dendrogram
shuffle

Random rotation of trees
remove_nodes_nodePar

Remove all nodePar values from a dendrogram's nodes
rllply

recursivly apply a function on a list
sort_2_clusters_vectors

Sorts two clusters vector by their names
untangle_step_rotate_2side

Stepwise untangle two trees one at a time
unclass_dend

unclass an entire dendrogram tree
unbranch

unbranch trees
untangle_step_rotate_both_side

Stepwise untangle two trees at the same time
untangle_random_search

Untangle - random search
untangle_step_rotate_1side

Stepwise untangle one tree compared to another
FM_index

Calculating Fowlkes-Mallows Index
FM_index_permutation

Calculating Fowlkes-Mallows Index under H0
Bk_plot

Bk plot - ploting the Fowlkes-Mallows Index of two dendrogram for various k's
all.equal.dendrogram

Global Comparison of two (or more) dendrograms
DendSer.dendrogram

Tries to run DendSer on a dendrogram
all_unique

Check if all the elements in a vector are unique
Bk

Bk - Calculating Fowlkes-Mallows Index for two dendrogram
all_couple_rotations_at_k

Rotate tree branches for k
Bk_permutations

Bk permutation - Calculating Fowlkes-Mallows Index for two dendrogram
FM_index_R

Calculating Fowlkes-Mallows index in R
branches_attr_by_clusters

Change col/lwd/lty of branches based on clusters
assign_values_to_leaves_edgePar

Assign values to edgePar of dendrogram's leaves
assign_values_to_branches_edgePar

Assign values to edgePar of dendrogram's branches
as.phylo.dendrogram

Convert a dendrogram into phylo
as.dendlist

Try to coerce something into a dendlist
as_hclust_fixed

Convert dendrogram Objects to Class hclust
bakers_gamma_for_2_k_matrix

Bakers Gamma for two k matrices
assign_dendextend_options

Populates dendextend functions into dendextend_options