Questions tagged [ggdendro]

ggdendro package is a set of tools for extracting dendrogram and tree diagram plot data for use with ggplot

ggdendro is a set of tools for extracting dendrogram and tree plot data so that dendrograms and tree plots can be plotted using the package . The ggplot philosophy is to separate clearly the data from the presentation. Unfortunately the plot method for dendrograms plots directly to a plot device without exposing the data. The package resolves this by making available functions that extract the dendrogram plot data.

The reference manual can be accessed from here.

36 questions
2
votes
1 answer

Creating Dendrogram with ggdendrogram

I'm doing cluster analysis and creating a dendrogram. I used ggdendrogram package and want to use its output in ggplot2. I wonder how get the same x-labels as the leaf-labels. Thanks D1 <- as.dist( matrix( data= c( 0, 9, 3, 6, 11 …
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
2
votes
1 answer

Flip ggdendrogram plot

I'm using a ggdendrogram to plot a dendrogram, but I want to have the labels on the left to make the graph more intuitive. How do I do this? Thanks!!! library(ggplot2) library(ggdendro) ### Data countries <- c("UK","AU","SA","CH") distmatrix <-…
MatAff
  • 1,250
  • 14
  • 26
1
vote
1 answer

For hclust1a-->dendrogram-->hclust1b in R, why plot for hclust1a and hclust1b differs?

I have a hclust object named hc1a. I convert it to a dendrogram object, which is in turn converted back to a hclust object and name it as hc1b: # Create hc1a and plot hc1a <- list() hc1a$merge <- matrix(c(-8, -9, -1, -2, …
Patrick
  • 1,057
  • 9
  • 23
1
vote
1 answer

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 the results of a hierarchical cluster analysis…
Robyn
  • 13
  • 3
1
vote
0 answers

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", "cat3", "cat1", "cat1") d1 <- data.frame(d1, cate) d2 <-…
KerryLee
  • 373
  • 2
  • 5
  • 13
1
vote
1 answer

how to extend the length of leaf node in dendrogram and add node labels

My task is to create a dendrogram, but the leaf nodes shows blunt edges. How would I extend the length of the leaf node, and add node labels? Please see the current and expected images below. Data: df1 <- data.frame( z1 = c(rep('P1', 5), rep('P2',…
Sathish
  • 12,453
  • 3
  • 41
  • 59
1
vote
1 answer

How to cut a dendrogram in r

Okay so I'm sure this has been asked before but I can't find a nice answer anywhere after many hours of searching. I have some data, I run a classification then I make a dendrogram. The problem has to do with aesthetics, specifically; (1) how to cut…
Tzac
  • 101
  • 2
  • 12
1
vote
1 answer

R: ggplot height adjustment for clustering dendrogram

The idea is to combine R packages ClustOfVar and ggdendro to give a visual summary of variable clustering. When there are few columns in the data, the result is pretty good except that there are areas not covered(as circled in the chart below).…
John
  • 1,779
  • 3
  • 25
  • 53
1
vote
0 answers

Colouring of leafs and branches according to k-cut clusters using gg dendro

I have generated a dendrogram using the ggdendro package of R but I am unable to colour the labels and branches. I want to colour it according to the value of k which is k=8 in my case. How can I do it? Below is the dendrogram I have generated: The…
1
vote
1 answer

Cutting out a cluster from dendrogram

I am using this link to plot a nice dendrogram with colored labels as per the categories. The second answer is what I am looking at in this link (Tree cut and Rectangles around clusters for a horizontal dendrogram in R )which uses the code below: d…
user45292
  • 45
  • 1
  • 9
1
vote
0 answers

ggdendrogram rotate with ggplot axis labels on right side for use in plotly

I am trying to generate a proper dendrogram in R with ggplot2 (more specifically ggdendro::ggdendrogram) because I would like to share it over plotly with my collaborators and currently I do not think it is possible with the api to generate a…
FM Kerckhof
  • 1,270
  • 1
  • 14
  • 31
1
vote
1 answer

How to get a good dendrogram using R

I am using R to do a hierarchical cluster analysis using the Ward's squared euclidean distance. I have a matrix of x columns(stations) and y rows(numbers in float), the first row contain the header(stations' names). I want to have a good dendrogram…
0
votes
1 answer

Labels in non-leaf nodes of dendrogram in R

I want to create a graph with the classification of several items (Name1, Name2, Name3, ...) according to several criteria (Column1, Column2, Column3) in the form of a dendrogram in R (I like the orthogonal esthetics of dendrograms to this end). I…
dreamco9
  • 3
  • 2
0
votes
1 answer

R (package superheat) - adding color (or rectangles) to the dendrograms

Minimal example and package documentation (https://rlbarter.github.io/superheat/): library(superheat) superheat(mtcars, # scale the matrix columns scale = TRUE, left.label = "none", # add row dendrogram …
Gustavo
  • 11
  • 2
0
votes
1 answer

Combine ggballoonplot with dendrogram in R

I have a simple balloonplot using the ggpballoonplot pacakge: ggballoonplot(X, x = "cluster", y = "marker", size = "Relative.Expression", fill = "Median.Intensity", ggtheme = theme_classic()) I wanted to know if it was…
startswithH
  • 309
  • 4
  • 14