我阅读了关于轮廓面热图生成的整个文档,但我找不到任何方法来为 ete3 生成的热图添加标签。例如,在以下代码中,热图的 7 列具有名称“Marker1”到“Marker7”。有什么方法可以将这些名称添加到 ete3 生成的热图中,例如“BarChartFace”可用的“标签”选项?或者唯一的方法是将树移植到matplotlib并在那里添加标签?
from ete3 import Tree, TextFace, NodeStyle, TreeStyle, faces, AttrFace, ClusterTree, ProfileFace
PhenoDict={'a':1,'b':0,'c':1}
matrix = """
#Names\tmarker1\tmarker2\tmarker3\tmarker4\tmarker5\tmarker6\tmarker7
a\t1\t-1\t1\t-1\t-1\t-1\t1
b\t-1\t-1\t1\t1\t-1\t-1\t1
c\t1\t1\t1\t-1\t1\t1\t1
"""
t=ClusterTree( "((a,b),c);" , text_array=matrix)
#Defining a function to generate textFace for each node
def ColorCodedNode (node):
if node.is_leaf():
ColorCode=PhenoDict[node.name]
if ColorCode == 0:
faces.add_face_to_node(AttrFace('name',fsize=20,fgcolor='blue'), node, column=0,aligned=True)
column=1,position='aligned')
faces.add_face_to_node(ProfileFace(1, -1, 0, width=200, height=40, style='heatmap', colorscheme=2),node,column=1,position='aligned')
elif ColorCode == 1:
faces.add_face_to_node(AttrFace("name",fsize=20,fgcolor='red'), node, column=0,aligned=True)
faces.add_face_to_node(ProfileFace(1, -1, 0, width=200, height=40, style='heatmap', colorscheme=2),node,column=1,position='aligned')
ts = TreeStyle()
ts.layout_fn= ColorCodedNode
ts.show_scale = False
ts.show_leaf_name = False
ts.draw_guiding_lines=True
t.show(tree_style=ts)