Page 1
[email protected]
user!2015 - The dendextend package
Page 2
[email protected]
Talk outline• Link to this presentation + dendextend
• 1 example
• The most useful functions
• Thanks!
Page 3
[email protected]
Getting this presentation
Go to: www.R-statistics.comOr: just e-mail me:
Page 4
[email protected]
Getting dendextend
Page 6
[email protected]
Further reading
Page 7
[email protected]
Further reading
(1 example - no code)
Page 8
[email protected]
The Iris dataset
Page 9
[email protected]
The Iris dataset
Page 10
[email protected]
The Iris dataset
Using heatmap.2 from gplots
Page 11
[email protected]
Why is “complete” different?
Comparing 8 Clustering algorithms onThe Iris dataset
Using dendlist,cor.dendlist + The corrplot package
Page 12
[email protected]
Why is “complete” different?
Page 13
[email protected]
Back tobasics
Page 14
[email protected]
Building a dendrogram
Page 15
[email protected]
hclust -> dend
Page 16
[email protected]
hclust -> dend
Page 17
[email protected]
Useful functions• labels• labels_colors• cutree• color_branches• sort• tanglegram• set (!)
Page 27
[email protected]
2 useful connections
Page 30
[email protected]
https://plot.ly/~talgalili/6/y-vs-x/
Send a dendrogram to plot.ly
Page 31
[email protected]
Send a dendrogram to d3heatmap
Joint work with Joe Cheng
Page 32
[email protected]
Send a dendrogram to d3heatmap
http://asbcllc.com/blog/2015/june/nba_14_15_top_50_heatmap/index.html
Page 33
[email protected]
ONE more function
Page 34
[email protected]
Using pipes%>%
(but first…)
Page 35
[email protected]
hclust -> dend
Page 36
[email protected]
hclust + pipes (via magrittr)
Page 37
[email protected]
Changing a dendrogram
Page 38
[email protected]
The set functionset(dend, what, value)
One function to rule them all!
Page 39
[email protected]
The set functionset(dend, what, value)
• dend a dendrogram• what the property to update• value new values to set in the
tree
Page 40
[email protected]
The set functionset(dend, what, value)
Type “what"Labels labels, labels_to_character, labels_colors,
labels_cex, labels_to_characterLeaves leaves_pch, leaves_col, leaves_cex, hang_leavesNodes nodes_pch, nodes_col, nodes_cex
Branches branches_lty, branches_col, branches_lwd, branches_k_color, by_labels_branches_lty,
by_labels_branches_col, by_labels_branches_lwd
Page 41
[email protected]
A dend exmaple
Page 42
[email protected]
Modify labels
Page 47
[email protected]
Modify nodes (no code)
Page 48
[email protected]
Modify nodes (no code)
Page 49
[email protected]
Modify branches
Page 50
[email protected]
Modify branches
Page 54
[email protected]
Rotate branches
Page 55
[email protected]
Rotate branches
Page 56
[email protected]
Prune branches
Page 57
[email protected]
Prune branches
Page 58
[email protected]
Add rectangles
Page 59
[email protected]
Add rectangles
Page 60
[email protected]
dendextendand other packages
Page 61
[email protected]
Gplots: heatmap.2
Page 62
[email protected]
dynamicTreeCut
Page 64
[email protected]
Take-home messages:• hclust – is good for creating hierarchical
clustering, but limited for plotting• dendrogram object• a nested list of lists• with attributes!• should be modified step by step before
plotting• Dendrograms can be compared• Use dendextendRcpp for (“free”) speed
Page 65
[email protected]
Credits!
dendextend
This work was supported in part by the European Research Council under EC–EP7 European Research Council grant PSARPS-297519, and also by the HBP project.
Page 66
[email protected]
Credits!
Page 67
[email protected]
The dendextend package
Thank you!for the slides:
R-statistics.com
Page 68
[email protected]
Exploring a dendrogram
Page 70
[email protected]
A dendrogram is a nested list of lists
Page 73
[email protected]
Depth- FirstSearch
Page 74
[email protected]
Depth- FirstSearch
Page 75
[email protected]
Comparing dendrograms
Page 76
[email protected]
tanglegram + untangle
Page 77
[email protected]
tanglegram + untangle
Page 78
[email protected]
“Correlation” measures
Page 79
[email protected]
“Correlation” measures
Page 80
[email protected]
dendextendin the wild
Page 81
[email protected]
Visually comparing two clustering methods
Page 82
[email protected]
A plot from a recent HBP meeting in Lausanne
DendrogramUsing 2 variables
DendrogramUsing all variables
Page 83
[email protected]
Visually comparing two phylogenic trees
Page 84
[email protected]
Send a dendrogram to d3heatmap
http://asbcllc.com/blog/2015/june/nba_14_15_top_50_heatmap/index.html
Page 85
[email protected]
The dendextend package
Thank you!for the slides:
R-statistics.com