3

ETE Toolkit によって生成される出力画像のフォント フェイスの向きを変更したい: http://etetoolkit.org

何らかの理由で、下の図に示すように、回転と向きの変更はラベルに影響しません。

ETE

Jupiter ノートブックでこの例を生成するコードは次のとおりです。

from ete3 import Tree, TreeStyle

def draw_ete(newick):
    t = Tree(newick)
    ts = TreeStyle()
    ts.scale = 5
    ts.rotation = -90
    ts.orientation = 1
    return t.render("%%inline", tree_style=ts)

newick = """((p, e, a, s, ((e, _), p, o), r, r, i, d, g, (e, _)), (h, o, t), ((,, ↵), (p, e, a, s, ((e, _), p, o), r, r, i, d, g, (e, _))), (c, (o, l, d)), ((,, ↵), (p, e, a, s, ((e, _), p, o), r, r, i, d, g, (e, _))), ((i, n), _, t, h, ((e, _), p, o), t, (,, ↵), n, (i, n), (e, _), d, a, y, s, _, (o, l, d), .), ↵, ↵, (s, o, m, (e, _), l, i, k, (e, _), i, t, _), (h, o, t), ((,, ↵), (s, o, m, (e, _), l, i, k, (e, _), i, t, _)), (c, (o, l, d)), ((,, ↵), (s, o, m, (e, _), l, i, k, (e, _), i, t, _)), ((i, n), _, t, h, ((e, _), p, o), t, (,, ↵), n, (i, n), (e, _), d, a, y, s, _, (o, l, d), .));"""
draw_ete(newick)

また、出力を 1 行ではなく複数の行に分割できるかどうかも知りたいです。長いシーケンスは幅の広いスペースを必要とする傾向があるため、シーケンスを複数の行に分割することが実用的です。

4

1 に答える 1

3

etetoolkit メーリング リストからの回答:

1) カスタム レイアウトと TextFaces を使用して回転が可能です。この例を確認してください:

from ete3 import Tree, TreeStyle, add_face_to_node, TextFace

from random import randint

def rotation_layout(node):
    if node.is_leaf():
        F = TextFace(node.name, tight_text=True)
        F.rotation = randint(0, 360)
        add_face_to_node(TextFace("third" ), node, column=8, position="branch-right")
        add_face_to_node(TextFace("second" ), node, column=2, position="branch-right")
        add_face_to_node(F, node, column=0, position="branch-right")

        F.border.width = 1
        F.inner_border.width = 1

def get_example_tree():
    t = Tree()
    t.populate(10)
    ts = TreeStyle()
    ts.rotation = 45
    ts.show_leaf_name = False
    ts.layout_fn = rotation_layout

    return t, ts

if __name__ == "__main__":
    t, ts = get_example_tree()
    t.show(tree_style=ts)

回転した木のラベル

2) いくつかの行に分割: あなたの質問を完全には理解していませんが、最終的なツリー イメージの幅を縮小することについて質問する場合、唯一の方法は、描画を複数のレンダー コールに分割し、必要なノードごとに 1 つにすることです。描く。例えば。1 つのツリーを 2 つの独立したイメージに分割するには、次を実行できます。

t.children[0].render("left_side.png")
t.children[1].render("right_side.png")

3) 一番下の枝目盛りのことですか?設定できますTreeStyle.show_scale=False

于 2016-02-22T13:56:32.383 に答える