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
3
votes
2 answers

Color branches of dendrogram using an existing column

I have a data frame which I am trying to cluster. I am using hclust right now. In my data frame, there is a FLAG column which I would like to color the dendrogram by. By the resulting picture, I am trying to figure out similarities among various…
Patthebug
  • 4,647
  • 11
  • 50
  • 91
2
votes
1 answer

How to set a label for a cluster in a dendrogram in R?

I want to insert a label in a box and in each cluster as shown in here: But, What I obtained is: Where the name of the cluster is in the specie label, not into the corresponding cluster as shown in the first figure. My data…
Another.Chemist
  • 2,386
  • 3
  • 29
  • 43
2
votes
1 answer

Displaying hierarchical clusters at cluster level (without cases)

I am interested in visualizing the results of a hierarchical cluster analysis. Is it possible to use a dendrogram to display the names or labels of clusters (and subclusters) without displaying the original cases that went into the cluster…
2
votes
1 answer

dendrogram from pre-made linkage matrix

the problem: in R, I need to plot a dendrogram + cut the associated tree from a linkage matrix created in a different language. based on the nature of the dataset, the prior processing is only available with this other language. so I need to be able…
wiscoYogi
  • 305
  • 2
  • 10
2
votes
1 answer

ggdendrogram : adding colored rectangles for each cluster

I am not able to add colored rectangles around the chosen clusters. library(lattice) library(permute) library(vegan) library("ggplot2") library("ggdendro") library("dendextend") data(dune) d <- vegdist(dune) csin <-…
jammah
  • 25
  • 5
2
votes
1 answer

Dendrogram plot remove tree labels at end of the branches

Using the example located here https://www.datacamp.com/community/tutorials/hierarchical-clustering-R and the data located https://archive.ics.uci.edu/ml/datasets/seeds# i am trying to remove the labels at the bottom of the dendrogram when using the…
HaydenC
  • 107
  • 4
2
votes
1 answer

How to associate cluster labels and dendrogram in the same order on a plot

I'm trying to associate my cluster labels to the corresponding dendrogram, the problem is that the dendrogram does not use the order i want, it's ordering the cluster from the left to the right... I've seen some other post like this one which is a…
D Prat
  • 352
  • 4
  • 16
2
votes
1 answer

How to find the number of clusters when cutting a tree at a certain height in R

I want to find the number of clusters when cutting a tree at given heights. The tree is of class "dendrogram" in R and so I have been using the package dendextend to explore this. Example: # Create a dend: dend <- 1:5 %>% dist %>% hclust %>%…
2
votes
0 answers

Adding scatterpie to a dendextend::ggdend phylogenetic tree

I'm trying to plot a phylogenetic tree (in the form of a dendextend::ggdend object) along with scatterpie representing ancestral states in the internal nodes of the tree. Here is the phylogenetic species tree: species.tree <-…
dan
  • 6,048
  • 10
  • 57
  • 125
2
votes
1 answer

Color branches of a dendrogram based on column in dataframe

I want to color the branches of a dendrogram based on the value in a column of a dataframe used in the hclust function. Before you mark this question as duplicate as was done in this question, which links to this question. Note that this was…
Matthew Snyder
  • 383
  • 2
  • 11
2
votes
0 answers

R cutree on dendrogram with "centroid" and "median" methods yields more clusters than expected

I want to test the hierarchical clustering with "centroid" and "median" methods. I have the following R code: library(dendextend) iris <- datasets::iris iris2 <- iris[,-5] species_labels <- iris[,5] d_iris <- dist(iris2) hc_iris <- hclust(d_iris,…
zaig
  • 391
  • 1
  • 11
2
votes
0 answers

How to fix overlapping labels in a circular dendrogram?

I run this code in order to have a circular dendrogram but the thing is that the labels are overlapping and all black. This is the code I used to generate the figure: library(dendextend) library(circlize) load(file = "hc1.rda") #out1 <-…
Marilou
  • 31
  • 8
2
votes
2 answers

Cluster labels are cut off on horizontal hclust dendrogram

I used hclust and as.dendogram to make a dendrogram, but when I rotate it to a horizontal orientation, the model names are cut off. How can I make sure that the plot shows the entire model names?
2
votes
2 answers

Label R dendrogram branches with correct group number

I am trying to draw a dendrogram so that the labels on the branches match the group number from my cluster analysis. Currently the branches are simply labelled from left to right in the order that they appear, not the actual group number. Here is my…
Damian M
  • 41
  • 6
2
votes
2 answers

FactoMineR/factoextra visualize all the clusters in the dendrogram

I performed a hierarchical clustering on a dataframe using the HCPC function of the package FactoMineR. Problem is, I cannot visualize the number of clusters I asked when I draw the dendrogram using factoextra. Here is below a reproducible example…
ePoQ
  • 434
  • 3
  • 18