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
2
votes
1 answer

R: Color branches of dendrogram while preserving the color legend

Objective: Create a dendrogram with branches colored by a factor variable with the resultant plot containing a legend to translate the branch colors to each factor variable value. I have some data with factor variables followed by the numeric data…
C. John
  • 144
  • 1
  • 15
2
votes
1 answer

Adding node labels to dendrogram plot in dendextend

I have a dendrogram with leaf and node labels (class=phylo, read in using read.tree). After converting this to dendrogram class the node labels are not there anymore. However, I would like to plot the dendrogram by showing labels on top of some…
Liis Kolberg
  • 153
  • 12
2
votes
1 answer

Drawing rectangles around specified labels in a dendrogram with 'dendextend'

I'm currently constructing a dendrogram and I'm using 'dendextend' to tweak the look of it. I've been able to do everything I want to (labelling leaves and highlighting branches of my chosen clusters), except drawing rectangles around pre-defined…
IsoBar
  • 405
  • 3
  • 10
2
votes
1 answer

r dendrogram - groupLabels not match real labels (package dendextend)

Let's do a quick 3-clusters classification on the iris dataset with the FactoMineR package: library(FactoMineR) model <- HCPC(iris[,1:4], nb.clust = 3) summary(model$data.clust$clust) 1 2 3 50 62 38 We see that 50 observations are in cluster 1,…
demarsylvain
  • 2,103
  • 2
  • 14
  • 33
2
votes
1 answer

dendextend: color_branches not working for certain hclust methods

I am using R dendextend package to plot hclust tree objects generated by each hclust method from hclust{stats}: "ward.D", "ward.D2", "single", "complete", "average" (= UPGMA), "mcquitty" (= WPGMA), "median" (= WPGMC) or "centroid" (= UPGMC). I…
Zach Roe
  • 23
  • 4
2
votes
3 answers

Extract height from every dendrogram node using dendrapply

Probably very simple, I have a dendrogram: set.seed(1) my_mat <- matrix(rnorm(100),nrow=10,ncol=10) my_dend <- as.dendrogram(hclust(dist(my_mat))) and I want to use dendrapply to extract the height attribute from every node in my_dend, since it…
user1701545
  • 5,706
  • 14
  • 49
  • 80
2
votes
1 answer

rotating dendogram x axis label in R

I am giving the example data provided by hclust help: mds2 <- -cmdscale(UScitiesD) hcity.D <- hclust(UScitiesD, "ward.D") plot(hcity.D, hang=-1) When you plot this the site labels are vertical- which is appropriate for this example since they use…
Birdonawire
  • 199
  • 3
  • 10
2
votes
2 answers

Collapsing a dendrogram given a tolerance cutoff

I'd like to collapse branches of a dendrogram given a tolerance cutoff. I'm following dendextend's collapse_branch example. require(dendextend) dend <- iris[1:5,-5] %>% dist %>% hclust %>% as.dendrogram dend %>% ladderize %>% plot(horiz = TRUE);…
dan
  • 6,048
  • 10
  • 57
  • 125
2
votes
2 answers

Getting leave names under branches for a given depth cutoff

I'm wondering what's the way in which for a given depth cutoff in dendrogram I can get for each branch below that depth cutoff a list of the names of all the leaves which are its descendants. For example I create this dendrogram: set.seed(1) mat <-…
dan
  • 6,048
  • 10
  • 57
  • 125
2
votes
0 answers

Adjusting the y_scale/y_shift parameter in the colored_bars function of dendextend package in R?

I am trying to plot many attributes in color bars beneath a dendrogram and am having trouble getting the positioning right (i.e. how to adjust y_scale and/or y_shift). The default plots 5 out of 25 color bars and setting y_shift=0.7 does allow all…
Catalina
  • 171
  • 9
2
votes
1 answer

Dendrogram modification using dendextend in R

I am trying to modify and tweak cluster dendrogram using dendextend, using below codes: # prepare hierarchical cluster hc = hclust(dist(mtcars)) dend <- as.dendrogram(hc) dend %>% set("branches_lty", 3) %>% plot() Please how can i set…
aliocee
  • 730
  • 9
  • 25
2
votes
1 answer

Labelling Vertical and Horizontal Dendrograms

I am new to R, and I am trying to construct a horizontal and vertical labelled dendrogram using dist() and hclust(). I have constructed six different types but cannot seem to add labels. Thank you if anyone has any suggestions. I have tried many…
Alice Hobbs
  • 1,021
  • 1
  • 15
  • 31
2
votes
2 answers

R hclust height of final merge

When performing the hierarchical clustering in R with the hclust function. How do you know the height of the final merge? So to clarify with some R default data: hc <- hclust(dist(USArrests)) dendrogram1 = as.dendrogram(hc) plot(hc) Will result…
Sleenee
  • 594
  • 1
  • 8
  • 21
2
votes
2 answers

How can I highlight specific labels in a dendrogram?

I made a cluster analysis using simple following code hc2 = hclust(dist(geno.imp)) pdf(file="file.pdf", width=50) plot(hc2,cex=0.2) dev.off() I want to highlight some of the specific leaves (not the nodes). I have the list of those leaves in a…
2
votes
2 answers

Label and color leaf dendrogram (phylogeny) in R using ape package

Following a previous post (Label and color leaf dendrogram in r) I have a follow-up question. My questions are similar to the post mentioned but I wonder can it be done using ape (e.g., plot(as.phylo(fit), type="fan", labelCol) as it has more type…
elyraz
  • 473
  • 5
  • 18