I would like to return a dendrogram of the [pvclust] function as above without losing the information (height, au value, bp value and edge value).
To obtain this dendrogram with the information from the first dendrogram
I tried the following formulas but it didn't work:
Thanks
you need to modify the pvclust text function like here mytext
is the customized version (you can copy past it)
mytext=function (x, col = c(au = 2, bp = 3, edge = 8), print.num = TRUE,
float = 0.01, cex = NULL, font = NULL, ...)
{
if (length(col) == 3 && is.null(names(col)))
names(col) <- c("au", "bp", "edge")
axes <- pvclust:::hc2axes(x$hclust)
usr <- par()$usr
wid <- usr[4] - usr[3]
num_str <- lapply(x$edges[seq_len(which(names(x$edges) ==
"bp"))], function(p) round(p * 100))
for (i in names(num_str)) {
num_str[[i]][length(num_str[[i]])] <- i
}
if (print.num) {
num_str$edge <- as.character(row.names(x$edges))
num_str$edge[length(num_str$edge)] <- "edge #"
}
else {
col <- col[names(col) != "edge"]
}
if (length(col) <= 1) {
range <- 1
pos <- 1
y_offset <- 0
}
else if (length(col) <= 3) {
range <- seq_len(min(3, length(col)))
pos <- c(2, 4, 1)
y_offset <- float * wid * c(1, 1, 0)
}
else {
range <- 1:4
pos <- c(2, 4, 2, 4)
y_offset <- c(float, float, 0.01, 0.01) * wid * c(1,
1, -2, -2)
}
for (i in range) {
name <- names(col)[i]
text(x = axes[, 2], y = axes[, 1] + y_offset[i], num_str[[name]],
col = col[name], pos = pos[i], offset = 0.3, cex = cex,
font = font)
}
}
here a reproducible example :
library(pvclust)
data(Boston, package = "MASS")
boston.pv <- pvclust(Boston, nboot=100, parallel=FALSE)
plot(as.dendrogram(boston.pv$hclust),horiz=TRUE)
mytext(boston.pv) # we use the customized text function here