Questions tagged [dendextend]
Questions on the R package dendextend
156
questions
0
votes
1
answer
28
views
dendextend get_subdendrograms in R: changing label names causes subdendrograms to be NULL
I am trying to create subdendrograms using dendextend, this works until I change the names of the labels of the leaves in the dendrogram. I want the labels to be 'Y' or 'B' based on a column in my ...
1
vote
0
answers
25
views
How to find the highest node per k-group on a dendrogram in R?
I am using dendextend to work with dendrograms in R. I want to only draw nodes that sit at the highest height within each cluster, which is determined by a tree cut @ k value. I wonder, if there is a ...
0
votes
0
answers
7
views
R rect.dendrogram() and problem with h parameter
Is it a bug or an intended behavior of rect.dendrogram() function in dendextend? Below is a demonstration code. First build a very simple dendrogram:
library(dendextend)
dend <- 1:5 %>% dist %&...
2
votes
1
answer
147
views
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 ...
1
vote
1
answer
34
views
Dendogram different colours by label name
Hope you are all doing good.
I use a dendogram:
d <-
dist(Correlation_Test)
hc <-
hclust(d, "ave")
plot(hc)
It works fine and shows at the End the dendogram. Dendogram has ...
2
votes
1
answer
125
views
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 ...
0
votes
0
answers
38
views
Rotating dendogram branches when you have thousands of them
I have been working with the R package dendextend for producing a dendogram while being able to rotate some of its branches.
What I have is a dendrogram with more than 8000 branches. I want to flip ...
1
vote
1
answer
69
views
Adding group information to pvclust dendrogram instead of sample name
This is what I'm doing
mat <- read.table("Model_pvclust/Model18_FAB_M5_vs_M0_MAP_TF.txt",sep = "\t",strip.white = FALSE,check.names = FALSE,header=TRUE,row.names=1)
drop <- ...
1
vote
0
answers
77
views
R: circlize_dendrogram(): ERROR - Not all labels are unique. Therefore, we pad the labels with a running number, so to be able to produce the plot
Issue
I want to produce a "fan" shaped dendrogram using the function circlize_dendrogram() in the package circlize. I would like to cluster the branches and tips by dolphin whistle subtypes (...
1
vote
1
answer
92
views
Changing the Tip Labels on a Dendrogram "Type = Fan" Based on a Defined Group in R Using the Ape Package
Issue:
I have a data frame called Sub_Whistle_Count (see below). I'm trying to do a hierarchical analysis using hclust(), but I can't customise the right label names Whistle_Type_Sub (28 different ...
0
votes
1
answer
426
views
specifying three cluster groups, but dendrogram clusters into four
I'm having a frustrating problem that I can't reproduce (I wish I could). I've generated dendrograms with three ecological datasets, using the same code but unique objects for each. Each leaf in the ...
0
votes
0
answers
59
views
Get the final order of the branches/ nodes after rotation by the dendextend r package
It has been mentioned in the vignette of dendextend R package:
It is also worth noting that some order are impossible to achieve for
a given tree’s topology. In such cases, the function will do its
“...
0
votes
0
answers
75
views
How to add colorbars to multiple dendrograms in R using dendextend
I want to plot multiple dendrograms in one window and add a colorbar to each plot using the dendextend package. How can this be achieved?
Following the dendextend documentation I can for example ...
0
votes
1
answer
137
views
Error in .rect_dendrogram(dend, k = k, palette = rect_border, rect_fill = rect_fill, : k must be between 2 and 97
I am trying to estimate a cluster dendrogram in R for a structural topic model I produced with 98 topics.
I first ran the following which worked well:
res.hc <- eclust(scale(out_corr$cor), "...
0
votes
1
answer
91
views
Ordering colors on colored bar for dendrogram in R
The vignette for the R package dendextend (https://cran.r-project.org/web/packages/dendextend/vignettes/dendextend.html) gives an example of using the colored_bars function with cutreeDynamic from ...
4
votes
1
answer
282
views
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 "...
2
votes
1
answer
230
views
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 ...
1
vote
1
answer
538
views
Saving dendrograms modified with dendextend in R
I want to rotate the order of several groups in a dendrogram and managed to do it with dendextend. However, when I try to save the plot with ggsave I end up with the original dendrogram, unrotated. Is ...
1
vote
1
answer
262
views
best way to convert dendrogram to ggplot?
I have build up a dendrogram and colored its branches according to their "purity" (whether they only include subjects with a particular value in a factor variable) using the set("...
2
votes
1
answer
312
views
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")
...
0
votes
1
answer
82
views
Add labels in dendogram in R
I am trying to apply Hierarchical Clustering for Time Series in order to identify the states with similar behaviors in the time series for residential_percent_change_from_baseline. I get the ...
0
votes
1
answer
90
views
groupLabels not shown when using dendextend colour_branches
The workflow I want to implement is:
dm <- dist(data)
dend <- hclust(dm)
k <- stats::cutree(dend, k = 10)
data$clusters <- k
plot(hclust, colorBranchees = k) #???? What I can use here.
So ...
1
vote
1
answer
556
views
How to rotate ylab labels in dendrogram in R?
df <- scale(mtcars) # Standardize the data
library("factoextra")
library("cluster")
dist <- dist(df, method = "euclidean") # df = standardized data
hc <- ...
0
votes
1
answer
124
views
How to label just one observation in hierarchical clustering tree with dendextend?
I'd like to create a hierarchical clustering tree of a relatively large dataset (>3000 obs). Unfortunately, by including so many labels at the terminal nodes, the tree looks very cluttered and ...
1
vote
1
answer
406
views
Positioning tip labels next to the tips in the dendrogram
I read in a tree (.nex), convert it to dendro class, and plot it using ggdendrogram from ggplot2. How can I position the tip labels next to the tips in the dendrogram and not at the bottom?
mytree <...
1
vote
1
answer
260
views
How do I plot dendrogram leaves by a given value (depth in a sediment core) rather than in sequential order?
I am working with ecological data (the percentage abundance of different diatom species present at different depths in a sediment core) and want to plot the results alongside a dendrogram representing ...
0
votes
1
answer
445
views
Is it possible to change the order of columns in heatmaply?
I have created a dendrogram with heatmaply with a dendrogram object from the dendextend package. I was wondering if there is a way to change the order of the columns: vs, am, carb, wt, drat, gear, etc....
1
vote
2
answers
1k
views
How can I create a large tanglegram in R that is readable and can be saved
I am using cophyloplot to create a tanglegram of two phylogenetic trees. The method works well with small trees but as the trees get larger the output image remains the same size and I can't find a ...
1
vote
0
answers
442
views
How to use Dendextend read Newick phylogenetic tree for tree compare?
I am trying to use Dendextend to draw a tanglegram (tangle tree) to interpret the segment-virus reassortment. The newick trees,which I get from other phylogenetic software (like Mrbayes/Raxml),as the ...
1
vote
0
answers
254
views
pvrect() rectangles in horizontal dendrogram (R)
I am trying to draw rectangles around clusters in a horizontal dendrogram.
This works fine as long as I only cut the tree manually, e.g.
dend<-as.dendrogram(hc)
plot(dend, horiz=T)
rect....
2
votes
1
answer
676
views
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 ...
0
votes
1
answer
141
views
Zoom and plot only specific node for a given dendogram
Hi suppose I generated a dendogram as such:
library(dendextend)
library(tidyverse)
mtcars %>%
select(mpg, cyl, disp) %>%
dist() %>%
hclust() %>%
as.dendrogram() -> ...
0
votes
1
answer
185
views
untangle error labels do not match in both trees
I have two dendrograms that I'm trying to calculate the entanglement of as follows:
dend12 <- dendlist(dend1, dend2)
x <- dend12 %>% untangle(method = "step2side")
These dendrograms ...
1
vote
0
answers
43
views
How to get individually made dendrograms from dendextend to consesnus tree analysis?
I am pretty new to R so I am struggling with the following:
I have a dataset where I am clustering several organ`s expresion values per patient. Like this I build 10 individual dendrograms. NOW, I ...
2
votes
1
answer
750
views
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'...
1
vote
1
answer
1k
views
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:
# ...
2
votes
0
answers
156
views
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 ...
2
votes
1
answer
630
views
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 ...
3
votes
1
answer
329
views
Combining a ggdend tree with a geom_scatterpie
I have a phylogenetic tree:
my.tree <- ape::read.tree(text = "((rat:0.06290316531,mouse:0.06094803666):0.05175420892,human:0.09883650566);")
which I then convert to a ggdend object:
library(...
1
vote
1
answer
1k
views
R rect.hclust: rectangles too high in dendogram
I asked a number of different experts to sort 92 objects based on their similarity. Based on their answers, I constructed a 92 x 92 dissimilarity matrix. in R, I examined this matrix using the ...
2
votes
0
answers
245
views
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 <- ...
0
votes
1
answer
398
views
How to zoom a circular dendrogram in R?
I have this circular dendrogram in R and I want to zoom it. How can I proceed?
Here it is:
The following code was used:
library(dendextend)
library(circlize)
load(file = "hc1.rda")
#out1 <- ...
2
votes
0
answers
630
views
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(...
1
vote
0
answers
68
views
color node based on category in tanglegram
I am trying to build a tanglegram using dendextra and ggdendro but I can't color nodes based on the category column in tanglegram. Please advise.
d1 <- c(1:5)
cate <- c("cat1", "cat2", "...
1
vote
1
answer
164
views
How do I add string variables to a dendrogram with labels coloured by factor level?
One of the answers to this question colour codes the labels of a dendogram for a subset of the iris dataset. What I would like to do is retain the string names for the labels so that they'd say setosa,...
0
votes
1
answer
25
views
Dragging a column to the leftmost
I am a newbie on R and my question may be too simple. I am trying to draw a hierarchical cluster. I use readxl to read the data from a xlsx file. The dendextend package also includes the year column ...
1
vote
1
answer
317
views
Adding y label to dendextend dendrogram
How can I add a y label to a dendrogram produced by dendextend? This may be used to label "Pairwise Distance", for example.
What about for horizontal (ggplot(horiz = T)) dendrograms?
1
vote
1
answer
607
views
Make dendextend assign colors to branches where I preset colors for leaves
I want to set the color of the branches of my dendrogram, given manually-assigned groups of my leaves. So I know in advance I want to color e.g. leaves A-C in red and all branches which only lead to ...
1
vote
1
answer
449
views
How to measure similarity between two clustering trees that are produced by hierarchical clustering?
I want to apply a hierarchical clustering method (i.e., agglomerative clustering) over different data sets. I would like to compare the resulted clustering trees. Is there any solution to this? Thanks ...
0
votes
0
answers
304
views
How to make dendrograms with legends on left side with dendextend package?
Good Afternoon
I have SNP genotypying dataset with 469 individuals in 1st column and their population information in 2nd column and rest of the columns is marker data. Now i want to make dendrogram ...