예제 #1
0
파일: tree_faces.py 프로젝트: xguse/ete
import random
from ete_dev import Tree, TreeStyle, NodeStyle, faces, AttrFace, TreeFace

small_ts = TreeStyle()
small_ts.tree_width = 100
small_ts.show_leaf_name = True

def layout(node):
    if node.is_leaf():
        # Add node name to laef nodes
        N = AttrFace("name", fsize=14, fgcolor="black")
        faces.add_face_to_node(N, node, 0)

        t = Tree()
        t.populate(10)

        T = TreeFace(t, small_ts)
        # Let's make the sphere transparent 
        T.opacity = 0.8
        # And place as a float face over the tree
        faces.add_face_to_node(T, node, 1, position="aligned")

# Random tree
t = Tree()
t.populate(20, random_branches=True)

# Some random features in all nodes
for n in t.traverse():
    n.add_features(weight=random.randint(0, 50))

# Create an empty TreeStyle
예제 #2
0
파일: face_positions.py 프로젝트: xguse/ete
t.add_face(fixed, column=1, position="branch-right")
# Bind the precomputed style to the root node 



# ETE 2.1 has now support for general image properties 
I = TreeStyle()
# You can add faces to the tree image (without any node
# associated). They will be used as headers and foot notes of the
# aligned columns (aligned faces)
I.aligned_header.add_face(t1, column = 0)
I.aligned_header.add_face(t1, 1)
I.aligned_header.add_face(t1, 2)
I.aligned_header.add_face(t1, 3)
t1.hz_align = 1 # 0 left, 1 center, 2 right 
t1.border.width = 1

I.aligned_foot.add_face(t2, column = 0)
I.aligned_foot.add_face(t2, 1)
I.aligned_foot.add_face(t2, 2)
I.aligned_foot.add_face(t2, 3)
t2.hz_align = 1

# Set tree image style. Note that aligned header and foot is only
# visible in "rect" mode.

I.mode =  "r" #(rectangular)
I.tree_width= 50
t.show(mylayout, tree_style=I)