I recently learned how to make clustering plots in R, as detailed in my question found: here. So now I can make helpful plots, but there is one formatting feature that would really help... to be able to specify predefined groups of samples to be plotted in different colors.
For example, given the following very busy plot, I would like specific rows of the data matrix used to generate this plot to be plotted in specific colors, so I could see how well the dendrogram clustering fits my hypothesis regarding where the samples should be clustering.
Example plot without branches (samples) in predefined colors:
I made this plot with the following code:
un_exprs <- as.matrix(read.table("data.txt", header=TRUE, sep = "\t", row.names = 1, as.is=TRUE))
exprs <- t(un_exprs)
eucl_dist=dist(exprs,method = 'euclidean')
hie_clust=hclust(eucl_dist,method = 'complete')
plot(hie_clust)
All help is much appreciated!
UPDATE: My question is not the same as answered here: How to create a dendrogram with colored branches? That question sought to arbitrarily color the clusters/edges of a dendrogram. That is not what I want to do. I want every edge or label to be colored as determine by a predefined list, regardless of where on the dendrogram the edge appears.