I have a dendogram of 150 genes imported in R, and I have a data frame with the same labels of the dendogram with score values from 0 to 200, that are independent from the dendogram.
I would like to colour the labels of the dendogram with the score values from the table using a gradient of colours from blue to red for example. I have found answers to similar questions at the following links How to colour the labels of a dendrogram by an additional factor variable in R & How to color a dendrogram's labels according to defined groups? (in R)
But I have not been able to work out how to convert the example codes for my code because:
1) none of them match the dendogram with an external value linked by the labels and
2) I would like to assign a colour depending on the score and not a random colour.
Here is the data example of my code
library(ape)
library(dendextend)
# Load tree
MyTree <- read.tree("species_tree.ph")
((raccoon:19.19959,bear:6.80041):0.84600,((sea_lion:11.99700, seal:12.00300):7.52973,((monkey:100.85930,cat:47.14069):20.59201, weasel:18.87953):2.09460):3.87382,dog:25.46154);
MyTree$root.edge <- 0                                       # Root the tree
MyTree=root(MyTree,"monkey",resolve.root = TRUE)
utree <- chronos(MyTree, lambda = 0, model = "correlated")  # Convert to ultrametric
dend=as.dendrogram(utree)                                   # Make dendogram
plot(dend)
# Load data of scores
scores <- read.csv("Scores_species.csv", header = TRUE, sep ="\t")
    Species Score
1  raccoon    97
2     bear    78
3 sea_lion    46
4     seal    14
5   monkey    57
6      cat    89
7   weasel    88
8      dog    97
dend2 <- color_labels(dend, k=8, groupLabels = scores )     # Add colors to labels 
(here I would like to have the gradient of colours depending on score) This plot was generated with other tool but it is what I expect to generate with some gradients color tool in R
 
    