Questions tagged [dendrogram]

A dendrogram (or tree diagram) is a graph used to represent relationships in hierarchical clustering.

Tag usage

Questions on tag should be about implementation and programming problems, not about the statistical or theoretical properties of the technique.
Consider whether your question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis.

586 questions
58
votes
5 answers

scipy linkage format

I have written my own clustering routine and would like to produce a dendrogram. The easiest way to do this would be to use scipy dendrogram function. However, this requires the input to be in the same format that the scipy linkage function…
geo_pythoncl
  • 927
  • 1
  • 7
  • 13
54
votes
2 answers

plotting results of hierarchical clustering on top of a matrix of data

How can I plot a dendrogram right on top of a matrix of values, reordered appropriately to reflect the clustering, in Python? An example is the following figure: This is Figure 6 from: A panel of induced pluripotent stem cells from chimpanzees: a…
user248237
46
votes
5 answers

Plot dendrogram using sklearn.AgglomerativeClustering

I'm trying to build a dendrogram using the children_ attribute provided by AgglomerativeClustering, but so far I'm out of luck. I can't use scipy.cluster since agglomerative clustering provided in scipy lacks some options that are important to me…
Shukhrat Khannanov
  • 461
  • 1
  • 4
  • 4
45
votes
2 answers

how to plot and annotate hierarchical clustering dendrograms in scipy/matplotlib

I'm using dendrogram from scipy to plot hierarchical clustering using matplotlib as follows: mat = array([[1, 0.5, 0.9], [0.5, 1, -0.5], [0.9, -0.5, 1]]) plt.subplot(1,2,1) plt.title("mat") dist_mat = mat linkage_matrix =…
user248237
37
votes
5 answers

sklearn agglomerative clustering linkage matrix

I'm trying to draw a complete-link scipy.cluster.hierarchy.dendrogram, and I found that scipy.cluster.hierarchy.linkage is slower than sklearn.AgglomerativeClustering. However, sklearn.AgglomerativeClustering doesn't return the distance between…
Presian Abarov
  • 373
  • 1
  • 3
  • 7
35
votes
2 answers

Extracting clusters from seaborn clustermap

I am using the seaborn clustermap to create clusters and visually it works great (this example produces very similar results). However I am having trouble figuring out how to programmatically extract the clusters. For instance, in the example link,…
sedavidw
  • 11,116
  • 13
  • 61
  • 95
31
votes
1 answer

How can I produce plots like this?

I have come across this kind of a plot that performs hierarchical clustering over a given set of timeseries data. Can someone tell me how to draw such plots? I am open to implementations in R or Javascript, especially using d3.js.
Legend
  • 113,822
  • 119
  • 272
  • 400
31
votes
3 answers

How to build a dendrogram from a directory tree?

Given a root absolute directory path. How do I generate a dendrogram object of all path's below it so that I can visualize the directory tree with R? Suppose the following call returned the following leaf nodes. list.files(path, full.names = TRUE,…
wdkrnls
  • 4,548
  • 7
  • 36
  • 64
27
votes
2 answers

Joining a dendrogram and a heatmap

I have a heatmap (gene expression from a set of samples): set.seed(10) mat <- matrix(rnorm(24*10,mean=1,sd=2),nrow=24,ncol=10,dimnames=list(paste("g",1:24,sep=""),paste("sample",1:10,sep=""))) dend <- as.dendrogram(hclust(dist(mat))) row.ord <-…
dan
  • 6,048
  • 10
  • 57
  • 125
26
votes
2 answers

How to plot dendrograms with large datasets?

I am using ape (Analysis of Phylogenetics and Evolution) package in R that has dendrogram drawing functionality. I use following commands to read the data in Newick format, and draw a dendrogram using the plot function: library("ape") gcPhylo…
Burcu
  • 375
  • 2
  • 5
  • 9
24
votes
6 answers

How do you compare the "similarity" between two dendrograms (in R)?

I have two dendrograms which I wish to compare to each other in order to find out how "similar" they are. But I don't know of any method to do so (let alone a code to implement it, say, in R). Any leads ? UPDATE (2014-09-13): Since asking this…
Tal Galili
  • 24,605
  • 44
  • 129
  • 187
23
votes
2 answers

Smooth transitioning between tree, cluster, radial tree, and radial cluster layouts

For a project, I need to interactively change hierarchical data layout of a visualization - without any change of the underlying data whatsoever. The layouts capable of switching between themselves should be tree, cluster, radial tree, and radial…
VividD
  • 10,456
  • 6
  • 64
  • 111
23
votes
2 answers

horizontal dendrogram in R with labels

I am trying to draw a dendrogram from the hclust function output. I hope the dendrogram is horizontally arranged instead of the default, which can be obtain by (for example) require(graphics) hc <- hclust(dist(USArrests), "ave") plot(hc) I tried to…
alittleboy
  • 10,616
  • 23
  • 67
  • 107
20
votes
1 answer

How to adjust branch lengths of dendrogram in matplotlib (like in astrodendro)? [Python]

Here is my resulting plot below but I would like it to look like the truncated dendrograms in astrodendro such as this: There is also a really cool looking dendrogram from this paper that I would like to recreate in matplotlib. Below is the code…
O.rka
  • 29,847
  • 68
  • 194
  • 309
19
votes
4 answers

Custom cluster colors of SciPy dendrogram in Python (link_color_func?)

I want to color my clusters with a color map that I made in the form of a dictionary (i.e. {leaf: color}). I've tried following https://joernhees.de/blog/2015/08/26/scipy-hierarchical-clustering-and-dendrogram-tutorial/ but the colors get messed…
O.rka
  • 29,847
  • 68
  • 194
  • 309
1
2 3
39 40