Build data and AI skills | 50% off

Last chance! 50% off unlimited learning

Sale ends in


⚠️There's a newer version (1.18.1) of this package.Take me there.

dendextend

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.

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")

Usage

Vignettes:

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:

Contact

You are welcome to:

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

70,257

Version

1.3.0

License

GPL-2 | GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Tal Galili

Last Published

August 27th, 2016

Functions in dendextend (1.3.0)

as.phylo.dendrogram

Convert a dendrogram into phylo
click_rotate

Interactively rotate a tree object
collapse_branch

Collapse branches under a tolerance level
bakers_gamma_for_2_k_matrix

Bakers Gamma for two k matrices
Bk

Bk - Calculating Fowlkes-Mallows Index for two dendrogram
branches_attr_by_clusters

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

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

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

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

Assign values to nodePar of dendrogram's nodes
circlize_dendrogram

Plot a circlized dendrograms
cor_FM_index

Correlation of FM_index for some k
cor_cophenetic

Cophenetic correlation between two trees
cor_bakers_gamma

Baker's Gamma correlation coefficient
common_subtrees_clusters

Find clusters of common subtrees
color_labels

Color dend's labels according to sub-clusters
colored_bars

Add colored bars to a dendrogram
color_unique_labels

Color unique labels in a dendrogram
cor.dendlist

Correlation matrix between a list of trees.
color_branches

Color tree's branches according to sub-clusters
cor_common_nodes

Proportion of commong nodes between two trees
d3dendrogram

Plot dendrogram to webpage and view.
dendextend_labels.dendrogram

Labels of the Leaves in a Dendrogram
d3dendro_options

Get or set current defaults for d3dendrogram
dend_diff

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

Cut a Tree (Dendrogram/hclust/phylo) into Groups of Data
cutree_1h.dendrogram

cutree for dendrogram (by 1 height only!)
dendextend_options

Access to dendextend_options
count_terminal_nodes

Counts the number of terminal nodes (merging 0 nodes!)
cutree_1k.dendrogram

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

Cut a dendrogram - and run a function on the output
dendextend-package

Functions for extending dendrogram objects
dendlist

Creating a dendlist object from several dendrograms
duplicate_leaf

Duplicate a leaf X times
distinct_edges

Finds distinct edges in one tree compared to another
dist.dendlist

Topological Distances Between Two dendrograms
entanglement

Measures entanglement between two trees
fac2num

Turns a factor into a number
find_k

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

Tries to run DendSer on a dendrogram
dist_long

Turns a dist object to a "long" table
flip_leaves

Flip leaves
FM_index

Calculating Fowlkes-Mallows Index
FM_index_permutation

Calculating Fowlkes-Mallows Index under H0
get_branches_heights

Get height attributes from a dendrogram
fix_members_attr.dendrogram

Fix members attr in a dendrogram
FM_index_profdpm

Calculating Fowlkes-Mallows index using the profdpm R package
FM_index_R

Calculating Fowlkes-Mallows index in R
get_childrens_heights

Get height attributes from a dendrogram's children
get_leaves_attr

Get/set attributes of dendrogram's leaves
get_leaves_edgePar

Get edgePar of dendrogram's leaves
get_leaves_nodePar

Get nodePar of dendrogram's leaves
is.dendlist

Checks if an object is of class dendlist
match_order_by_labels

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

Find lowest common branch were the two items are shared
is.dendrogram

Is the object of class dendrogram
nnodes

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

Counts the number of leaves in a tree
remove_leaves_nodePar

Remove all nodePar values from a dendrogram's leaves
remove_branches_edgePar

Remove all edgePar values from a dendrogram's branches
flatten.dendrogram

Flatten the branches of a dendrogram's root
get_nodes_attr

Get attributes of dendrogram's nodes
get_nodes_xy

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

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

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

Identify Clusters in a Dendrogram (not hclust)
labels<-

"label" assignment operator
order.dendrogram<-

order.dendrogram<- assignment operator
pvclust_show_signif_gradient

Significance gradient of branches in a dendrogram (via pvclust)
noded_with_condition

Find which nodes satisfies a condition
as.dendlist

Try to coerce something into a dendlist
intersect_trees

Intersect trees
ggdend

Creates dendrogram plot using ggplot.
get_root_branches_attr

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

Retrieve/assign cex to the labels of a dendrogram
is_null_list

Checks if the value is and empty list()
khan

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

A list with labels for each subtree (edge)
order.hclust

Ordering of the Leaves in a hclust Dendrogram
rect.dendrogram

Draw Rectangles Around a Dendrogram's Clusters
assign_values_to_leaves_edgePar

Assign values to edgePar of dendrogram's leaves
heights_per_k.dendrogram

Which height will result in which k for a dendrogram
hang.dendrogram

Hang dendrogram leaves
assign_values_to_leaves_nodePar

Assign values to nodePar of dendrogram's leaves
is.hclust

Is the object of class hclust
is.dist

Checks if an object is of class dist
ladderize

Ladderize a Tree
prune

Prunes a tree (using leaves' labels)
prune_leaf

Trims one leaf from a dendrogram
leaf_Colors

Return the leaf Colors of a dendrogram
reexports

Objects exported from other packages
rotate

Rotate a tree object
tanglegram

Tanglegram plot
rotate_DendSer

Rotates dend based on DendSer
sample.dendrogram

Sample a tree
theme_dendro

Creates completely blank theme in ggplot
seriate_dendrogram

Rotates a dendrogram based on a seriation of a distance matrix
untangle_step_rotate_1side

Stepwise untangle one tree compared to another
untangle

untangle dendrograms
untangle_step_rotate_2side

Stepwise untangle two trees one at a time
which_leaf

Which node is a leaf?
all.equal.dendrogram

Global Comparison of two (or more) dendrograms
remove_nodes_nodePar

Remove all nodePar values from a dendrogram's nodes
rllply

recursivly apply a function on a list
sort_levels_values

Sort the values level in a vector
sort_dist_mat

Sorts a distance matrix by rows and columns names
as_hclust_fixed

Convert dendrogram Objects to Class hclust
all_unique

Check if all the elements in a vector are unique
all_couple_rotations_at_k

Rotate tree branches for k
get_leaves_branches_attr

Get an attribute of the branches of a dendrogram's leaves
get_leaves_branches_col

Get the colors of the branches of a dendrogram's leaves
is.natural.number

Check if numbers are natural
is.phylo

Is the object of class phylo
pvclust_show_signif

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

Rank a vector based on clusters
rank_order.dendrogram

Fix rank of leaves order values in a dendrogram
shuffle

Random rotation of trees
untangle_random_search

Untangle - random search
untangle_DendSer

Tries to run DendSer on a dendrogram
sort_2_clusters_vectors

Sorts two clusters vector by their names
assign_dendextend_options

Populates dendextend functions into dendextend_options
assign_values_to_branches_edgePar

Assign values to edgePar of dendrogram's branches
plot_horiz.dendrogram

Plotting a left-tip-adjusted horizontal dendrogram
match_order_dendrogram_by_old_order

Adjust the order of one dendrogram based on another (using order)
prune_common_subtrees.dendlist

Prune trees to their common subtrees
na_locf

Last Observation Carried Forward
raise.dendrogram

Raise the height of a dendrogram tree
set_labels

Set/place new labels in a dendrogram
rank_branches

Rank branches' heights
unbranch

unbranch trees
set

Set (/update) features to a dendrogram
unclass_dend

unclass an entire dendrogram tree
which_node

Which node id is common to a group of labels