Questions tagged [dendextend]

Questions on the R package dendextend

The dendextend R package includes functions and methods for extending dendrogram objects in R (visualization, manipulation and comparison).

158 questions
5
votes
3 answers

Stacked bar plot with hierarchical clustering (dendrogram)

I am trying to get something like this but unfortunately, I could not find any package that could enable me to plot stacked bar plot with dendrogram like the one shown below: Does anyone know how to do it?
Lu Pan
  • 51
  • 1
  • 3
5
votes
1 answer

Rotate labels for ggplot dendrogram

I am trying to create a dendrogram using the package dendextend. It creates really nice gg dendrograms but unfortunately when you turn it into a "circle", the labels do not keep up. I'll provide an example below. My distance object is here:…
Brandon
  • 1,722
  • 1
  • 19
  • 32
5
votes
1 answer

Extract distances from hclust (hierarchical clustering) object

I would like to calculate how good the fit of my cluster analysis solution for the actual distance scores is. To do that, I need to extract the distance between the stimuli I am clustering. I know that when looking at the dendrogram I can extract…
Esther
  • 441
  • 2
  • 15
5
votes
1 answer

Cutting a dendrogram in R

I am trying to cut this dendrogram into 3 groups: (T24, T1, T17, etc.), (T12, T15, T6, etc.) and (T2, T8, T3, T9) I have tried using cutree(hc, k=3, h=400) , but it continues to make the same groups. Any help is greatly appreciated. Here is my…
derp4herps
  • 51
  • 1
  • 3
5
votes
1 answer

Extract the hierarchical structure of the nodes in a dendrogram or cluster

I would like to extract the hierarchical structure of the nodes of a dendrogram or cluster. For example in the next example: library(dendextend) dend15 <- c(1:5) %>% dist %>% hclust(method = "average") %>% as.dendrogram dend15 %>% plot The nodes…
Ruben
  • 493
  • 4
  • 18
5
votes
3 answers

How to color a dendrogram's labels according to defined groups? (in R)

I have a numeric matrix in R with 24 rows and 10,000 columns. The row names of this matrix are basically file names from which I have read the data corresponding to each of the 24 rows. Apart from this I have a separate factor list with 24 entires,…
novicegeek
  • 773
  • 2
  • 9
  • 29
5
votes
2 answers

Plot horizontal dendrogram with hanging leaves? (R)

I would like to create a dendrogram plot with horizontal labels, but having the leaves hang according to their height, instead of just drop to the edge of the plot. Example: par(mfrow = c(1,2)) hc <- hclust(dist(USArrests), "ave") plot(hc) # a plot…
Tal Galili
  • 24,605
  • 44
  • 129
  • 187
4
votes
3 answers

How do I label the terminal nodes of a cut dendrogram?

I used the following code to cut the dendrogram at a particular height.The problem I'm having is that when I cut a dendrogram, I can't figure out how to add labels to the nodes.How can I cut a dendrogram with labels using R…
akash
  • 41
  • 1
  • 3
4
votes
1 answer

Problem with margins using plot function with as.dendrogram object

I'm trying to customize a clustering plot using both base R functions and the package "dendextend". Firstly I generate a cluster with the common hclust() function. Then I'm using "dendextend" to color the branches defined by k=groups. Then I'm using…
4
votes
1 answer

How to label colored bars in a dendrogram

How could I add a label for some colored bars I've added in a dendrogram plot? The code bellow will show the two attempts I've done for aiming task, which is linking the value 1 to the color red and value 0 to color white in a label for the colored…
Gilgamesh
  • 589
  • 1
  • 6
  • 20
4
votes
3 answers

R getting subtrees from dendrogram based on cutree labels

I have clustered a large dataset and found 6 clusters I am interested in analyzing more in depth. I found the clusters using hclust with "ward.D" method, and I would like to know whether there is a way to get "sub-trees" from hclust/dendrogram…
lucacerone
  • 9,859
  • 13
  • 52
  • 80
4
votes
2 answers

Dendextend: Regarding how to color a dendrogram’s labels according to defined groups

I'm trying to use an awesome R-package named dendextend, to plot a dendrogram and color its branches & labels according to a set of previously defined groups. I've read your answers in Stack Overflow, and the FAQs of dendextend vignette, but I'm…
JLLavin
  • 91
  • 9
4
votes
1 answer

making plotly dendrogram in javascript

Want to make https://plot.ly/python/dendrogram/ with plotly.js. Is it possible? Has anyone implemented dendrogram in javascript?
mei
  • 67
  • 9
4
votes
2 answers

How to change node labels of dendrogram plot

I did a hierarchical cluster for a project. I have 300 observations each of 20 variables. I indexed all the variables so that each variable is between 0 and 1, a larger value being better. I used the following code to create a cluster plot. d_data…
4
votes
0 answers

How to adjust lines length in dendrogram?

Using this code in R, library("dendextend") library("dendextendRcpp") dist2 <- read.csv("distanceMatrix.csv",sep=";",header=TRUE) mat <- as.matrix(dist2) # using piping to get the dend dend <- dist2 %>% dist %>% hclust %>% as.dendrogram %>%…
Prpaa
  • 247
  • 6
  • 13
1
2
3
10 11