I've built a tree image, see question.
Now I've some major groups.
One group has nodes with color green and brown, and has a 'B' and a 'A'. The second group has only pink nodes and 'T' and the last group has yellow, orange and blue, and the letters 'L', 'X' and 'H'. the colors refer to the colors of the nodes and the letters belong to the name. So I want to color the edge of the different groups.
#taken from draw_graphviz
def get_label_mapping(G, selection):
for node in G.nodes():
if (selection is None) or (node in selection):
try:
label = str(node)
if label not in (None, node.__class__.__name__):
yield (node, label)
except (LookupError, AttributeError, ValueError):
pass
labels = dict(get_label_mapping(G, None))
for label in labels.keys():
if str(label) != "Clade":
num = label.name.split('-')
if 'T' in num[0]:
node_colors.append('#CC6699')
elif 'X' in num[0]:
node_colors.append('r')
else:
node_colors.append('y')
so I've done a similar function to the above, instead of node, I changed to get_edge. and try this:
for edge in edges.keys():
if str(edge) != "Clade":
if 'T' in edge:
edge_colors.append('b')
where edge is:
(Clade(branch_length=-0.00193, name='T-7199-8'), Clade(branch_length=0.00494))
perhaps there's a way to say if T is in name, then color the edge. What to you think?
anyone knows how to do this?
Thank you