2015 06-27 use-r2015_dendextend_tal_galili_01

85
Tal.Galili@gmail.c om user ! 2015 - The dendextend package

Upload: tal-galili

Post on 02-Aug-2015

4.887 views

Category:

Data & Analytics


1 download

TRANSCRIPT

Page 1: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

user!2015 - The dendextend package

Page 2: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Talk outline• Link to this presentation + dendextend

• 1 example

• The most useful functions

• Thanks!

Page 3: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Getting this presentation

Go to: www.R-statistics.comOr: just e-mail me:

Page 4: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Getting dendextend

Page 6: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Further reading

Page 7: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Further reading

(1 example - no code)

Page 8: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

The Iris dataset

Page 9: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

The Iris dataset

Page 10: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

The Iris dataset

Using heatmap.2 from gplots

Page 11: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Why is “complete” different?

Comparing 8 Clustering algorithms onThe Iris dataset

Using dendlist,cor.dendlist + The corrplot package

Page 12: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Why is “complete” different?

Page 13: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Back tobasics

Page 14: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Building a dendrogram

Page 15: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

hclust -> dend

Page 16: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

hclust -> dend

Page 17: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Useful functions• labels• labels_colors• cutree• color_branches• sort• tanglegram• set (!)

Page 27: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

2 useful connections

Page 30: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

https://plot.ly/~talgalili/6/y-vs-x/

Send a dendrogram to plot.ly

Page 31: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Send a dendrogram to d3heatmap

Joint work with Joe Cheng

Page 32: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Send a dendrogram to d3heatmap

http://asbcllc.com/blog/2015/june/nba_14_15_top_50_heatmap/index.html

Page 33: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

ONE more function

Page 34: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Using pipes%>%

(but first…)

Page 35: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

hclust -> dend

Page 36: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

hclust + pipes (via magrittr)

Page 37: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Changing a dendrogram

Page 38: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

The set functionset(dend, what, value)

One function to rule them all!

Page 39: 2015 06-27 use-r2015_dendextend_tal_galili_01

[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: 2015 06-27 use-r2015_dendextend_tal_galili_01

[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: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

A dend exmaple

Page 42: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Modify labels

Page 47: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Modify nodes (no code)

Page 48: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Modify nodes (no code)

Page 49: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Modify branches

Page 50: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Modify branches

Page 54: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Rotate branches

Page 55: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Rotate branches

Page 56: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Prune branches

Page 57: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Prune branches

Page 58: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Add rectangles

Page 59: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Add rectangles

Page 60: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

dendextendand other packages

Page 61: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Gplots: heatmap.2

Page 62: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

dynamicTreeCut

Page 63: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

pvclust

Page 64: 2015 06-27 use-r2015_dendextend_tal_galili_01

[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: 2015 06-27 use-r2015_dendextend_tal_galili_01

[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: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Credits!

Page 67: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

The dendextend package

Thank you!for the slides:

R-statistics.com

Page 68: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Exploring a dendrogram

Page 70: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

A dendrogram is a nested list of lists

Page 73: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Depth- FirstSearch

Page 74: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Depth- FirstSearch

Page 75: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Comparing dendrograms

Page 76: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

tanglegram + untangle

Page 77: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

tanglegram + untangle

Page 78: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

“Correlation” measures

Page 79: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

“Correlation” measures

Page 80: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

dendextendin the wild

Page 81: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Visually comparing two clustering methods

Page 82: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

A plot from a recent HBP meeting in Lausanne

DendrogramUsing 2 variables

DendrogramUsing all variables

Page 83: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Visually comparing two phylogenic trees

Page 84: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

Send a dendrogram to d3heatmap

http://asbcllc.com/blog/2015/june/nba_14_15_top_50_heatmap/index.html

Page 85: 2015 06-27 use-r2015_dendextend_tal_galili_01

[email protected]

The dendextend package

Thank you!for the slides:

R-statistics.com