The function does not appear to draw the height axis for some reason. I have neither seen much examples of it online - all circular dendrograms appear to omit it. So, I embarked on a task to add it myself.
The following code appears to do it:
mat <- matrix(abs(rnorm(100)),10,10)
dimnames(mat) <- list(letters[1:10],letters[1:10])
ma2 <- as.dist(mat)
hc <- hclust(ma2)
dend <- as.dendrogram(hc)
par(mfrow=c(1,2))
plot(dend)
require(circlize)
require(dendextend)
#Get the heights for each branch
heights <- round(get_branches_heights(dend, sort=FALSE), 1)
#Get max height
maxHeight= max(heights)
#Set label and dendrogram height for circular dendrogram
labelHeight=0.1
dendHeight=0.8
#Draw the circular dendrogram
circlize_dendrogram(dend,
facing = "outside",
labels = TRUE,
labels_track_height = labelHeight,
dend_track_height = dendHeight)
# Create tick co-ordinates and values for the new axis
# We have to ensure that we don't overlap the label plot region
# (height specified by labelHeight), nor the central region of the
# plot (1-(dendHeight+labelHeight))
ticks <- seq(from = (1-(dendHeight+labelHeight)),
to = (1-labelHeight), length.out=5)
values <- round(rev(seq(from=0, to=maxHeight, length.out=5)), 1)
#Add the new axis
require(plotrix)
ablineclip(h=0, v=ticks, col="black",
x1=1-(dendHeight+labelHeight),
x2=1-labelHeight,
y1=0,
y2=0.04,
lwd=1.5)
text(ticks, 0+0.08, values, cex=0.8)
text(
(1-labelHeight)-(((1-labelHeight)-(1-(dendHeight+labelHeight)))/2),
0+0.14,
"Height", cex=0.8)
What a wonderful solution! Thank you very much!
You're welcome! - thanks.