The labels of my dendrogram contain too much unnecessary information, so I want to change them into shorter versions. Additionally, all the labels are colored by their group affiliation.
ward <- as.dendrogram(hclust(bc_dist, method = "ward.D2")) metad <- data.frame(phyloseq::sample_data(gps_rel_abund)) colorCode <- c(`1` = "cyan3", `2` = "tomato", `3` = "mediumorchid", `4` = "chartreuse4") labels_colors(ward) <- colorCode[metad$group][order.dendrogram(ward)] par(mar=c(7, 3, 1, 1)) plot(ward)
Now I want to have the labels without the first three and the last two numbers: 012.4A16 -> 4A. But without changing anything else (color, group affiliation) in the dendrogram.
I searched the web for instructions on how to do it, but or the code was too complex for me to understand it, or it changed my group-colors.
Could anyone of you please tell me if it is possible to make these changes and if so, how?
Thank you so much for your help!