I have plotted two phylogenetic trees face-to-face using cophylo
function in phytools
, and would like to colour the nodes and tip labels according to their label.
plot(cophylo(T1RnB,T2RnB,assoc=assoc))
Example of tip labels:
A|A.han
A|D.ehr
D|M.gem
F|P.pri
F|P.sig
_
> write.tree(T1RnB)
(((A|A.han,A|D.ehr)7,D|M.gem)1,(F|P.sig,F|P.pri)67)6;
> write.tree(T2RnB)
(((A|A.han,A|D.ehr)40,(F|P.sig,F|P.pri)100)46,D|M.gem)9;
> assoc
1 A|A.han A|A.han
2 A|D.ehr A|D.ehr
3 D|M.gem D|M.gem
4 F|P.pri F|P.pri
5 F|P.sig F|P.sig
I would like to colour the node & tip label according to the first alphabet. For example, green color node & tip label for those started with "A", blue for those started with "D" and yellow for those started with "F", etc.
The closest example I found was colouring the node according to its branch length or bootstrap (using colour gradient).
Is colouring according to the tip label possible? Or perhaps add colour label manually for each node in the association file and colour them accordingly?
Thanks!