简体   繁体   English

在ete2中作为NodeStyle形状的矩形

[英]Rectangle as NodeStyle shape in ete2

I would like to create my own layout for dendrogram in ete2. 我想在ete2中为树状图创建自己的布局。 I have very specific needs to customize the tree node by node (ie every node has different style etc..) 我有非常具体的需求来逐个节点自定义树节点(即每个节点都有不同的样式等。)

Is it possible to set the shape of node as rectangle (I found circle, square and sphere as options)? 是否可以将节点的形状设置为矩形(我找到了圆形,正方形和球形作为选项)? I would like to set the length and height manually for every node. 我想为每个节点手动设置长度和高度。

Also, do you have any experience with ete2. 另外,您是否对ete2有任何经验。 Does it have any limitations for customization? 定制是否有任何限制? It seems like a good tool for visualizing trees, but I want to create somewhat a more 'special' layout. 它看起来像是可视化树木的好工具,但是我想创建某种更“特殊”的布局。

Thanks in advance, 提前致谢,

L. L.

only filledRects are supported via NodeStyle. 通过NodeStyle仅支持fillRects。 However, you can get the same effect and more control by adding a RectFace in branch-right position to the nodes. 但是,通过在节点的右分支位置添加RectFace ,可以获得相同的效果和更多的控制。 Many other configurations are available. 还有许多其他配置可用。 For example: 例如:

from ete2 import Tree, RectFace, TreeStyle, AttrFace
tree = Tree()
tree.populate(10)

# Disable auto tip names
ts = TreeStyle()
ts.show_leaf_name = False

for node in tree.traverse():
    # disable default node shapes
    node.img_style["size"] = 0
    # add a custom rect shapes to nodes
    rectF = RectFace(10, 10, "blue", "white")
    rectF.margin_right = 5
    node.add_face(rectF, column=0, position="branch-right")

    # Add tip names in a custom position
    if node.is_leaf():
        nameF = AttrFace("name", fsize=10, fgcolor="slateGrey")
        node.add_face(nameF, column=1, position="branch-right")

tree.show(tree_style=ts)

ETE定制树

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM