本文整理汇总了Python中ete_dev.Tree.render方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.render方法的具体用法?Python Tree.render怎么用?Python Tree.render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ete_dev.Tree
的用法示例。
在下文中一共展示了Tree.render方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from ete_dev import Tree [as 别名]
# 或者: from ete_dev.Tree import render [as 别名]
def test(self):
# Text faces
I = TreeImage()
I.mode = "rect"
I.aligned_header.add_face(self.headerF, 0)
I.aligned_header.add_face(self.headerF, 1)
I.aligned_header.add_face(self.headerF, 2)
I.aligned_header.add_face(self.headerF, 3)
I.aligned_foot.add_face(self.footF, 0)
I.aligned_foot.add_face(self.footF, 1)
I.aligned_foot.add_face(self.footF, 2)
I.aligned_foot.add_face(self.footF, 3)
I.draw_aligned_faces_as_grid = True
t = Tree()
t.dist = 0
t.populate(10)
style = NodeStyleDict()
style["fgcolor"] = "#ff0000"
style["size"] = 20
style.add_fixed_face(self.fixedF, "branch-right", 0)
t.img_style = style
t.render("./test.svg", layout=mylayout, tree_style=I)
t.show(mylayout, tree_style=I)
t.show(mylayout2, tree_style=I)
示例2: TreeStyle
# 需要导入模块: from ete_dev import Tree [as 别名]
# 或者: from ete_dev.Tree import render [as 别名]
col += 1
# Add the corresponding face to the node
if name.startswith("Dme"):
faces.add_face_to_node(flyFace, node, column=col)
elif name.startswith("Dre"):
faces.add_face_to_node(fishFace, node, column=col)
elif name.startswith("Mms"):
faces.add_face_to_node(mouseFace, node, column=col)
elif name.startswith("Ptr"):
faces.add_face_to_node(chimpFace, node, column=col)
elif name.startswith("Hsa"):
faces.add_face_to_node(humanFace, node, column=col)
elif name.startswith("Cfa"):
faces.add_face_to_node(dogFace, node, column=col)
# Modifies this node's style
node.img_style["size"] = 16
node.img_style["shape"] = "sphere"
node.img_style["fgcolor"] = "#AA0000"
# If leaf is "Hsa" (homo sapiens), highlight it using a
# different background.
if node.is_leaf() and node.name.startswith("Hsa"):
node.img_style["bgcolor"] = "#9db0cf"
# And, finally, Visualize the tree using my own layout function
ts = TreeStyle()
ts.layout_fn = mylayout
t.render("img_faces.png", w=600, tree_style = ts)
示例3: master_ly
# 需要导入模块: from ete_dev import Tree [as 别名]
# 或者: from ete_dev.Tree import render [as 别名]
# Center text according to masterItem size
tw = text.boundingRect().width()
th = text.boundingRect().height()
center = masterItem.boundingRect().center()
text.setPos(center.x()-tw/2, center.y()-th/2)
return masterItem
def master_ly(node):
if node.is_leaf():
# Create an ItemFAce. First argument must be the pointer to
# the constructor function that returns a QGraphicsItem. It
# will be used to draw the Face. Next arguments are arbitrary,
# and they will be forwarded to the constructor Face function.
F = faces.DynamicItemFace(ugly_name_face, 100, 50)
faces.add_face_to_node(F, node, 0, position="aligned")
t = Tree()
t.populate(8, reuse_names=False)
ts = TreeStyle()
ts.layout_fn = master_ly
ts.title.add_face(faces.TextFace("Drawing your own Qt Faces", fsize=15), 0)
t.render("item_faces.png", h=400, tree_style=ts)
# The interactive features are only available using the GUI
t.show(tree_style=ts)
示例4: NodeStyle
# 需要导入模块: from ete_dev import Tree [as 别名]
# 或者: from ete_dev.Tree import render [as 别名]
style1["fgcolor"] = "#0f0f0f"
style1["size"] = 0
style1["vt_line_color"] = "#ff0000"
style1["hz_line_color"] = "#ff0000"
style1["vt_line_width"] = 2
style1["hz_line_width"] = 2
style1["vt_line_type"] = 2 # 0 solid, 1 dashed, 2 dotted
style1["hz_line_type"] = 2
t.children[0].img_style = style1
t.children[1].img_style = style1
# Set dashed blue lines in all leaves
style2 = NodeStyle()
style2["fgcolor"] = "#000000"
style2["shape"] = "circle"
style2["vt_line_color"] = "#0000aa"
style2["hz_line_color"] = "#0000aa"
style2["vt_line_width"] = 2
style2["hz_line_width"] = 2
style2["vt_line_type"] = 1 # 0 solid, 1 dashed, 2 dotted
style2["hz_line_type"] = 1
for l in t.iter_leaves():
l.img_style = style2
ts = TreeStyle()
ts.layout_fn = layout
ts.show_leaf_name = False
t.render("node_style.png", w=400, tree_style=ts)
示例5: Tree
# 需要导入模块: from ete_dev import Tree [as 别名]
# 或者: from ete_dev.Tree import render [as 别名]
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
ts = TreeStyle()
# Set our custom layout function
ts.layout_fn = layout
# Draw a tree
ts.mode = "c"
# We will add node names manually
ts.show_leaf_name = False
# Show branch data
ts.show_branch_length = True
ts.show_branch_support = True
t.render("tree_faces.png", w=600, dpi=300, tree_style=ts)
t.show(tree_style=ts)
示例6: TreeStyle
# 需要导入模块: from ete_dev import Tree [as 别名]
# 或者: from ete_dev.Tree import render [as 别名]
t.add_face(bottom_c0_r0, column=0, position="branch-bottom")
t.add_face(bottom_c0_r1, column=0, position="branch-bottom")
a = t&"a"
a.set_style(NodeStyle())
a.img_style["bgcolor"] = "lightgreen"
b = t&"b"
b.set_style(NodeStyle())
b.img_style["bgcolor"] = "indianred"
c = t&"c"
c.set_style(NodeStyle())
c.img_style["bgcolor"] = "lightblue"
t.set_style(NodeStyle())
t.img_style["bgcolor"] = "lavender"
t.img_style["size"] = 12
for leaf in t.iter_leaves():
leaf.img_style["size"] = 12
leaf.add_face(right_c0_r0, 0, "branch-right")
leaf.add_face(aligned_c0_r1, 0, "aligned")
leaf.add_face(aligned_c0_r0, 0, "aligned")
leaf.add_face(aligned_c1_r1, 1, "aligned")
leaf.add_face(aligned_c1_r0, 1, "aligned")
ts = TreeStyle()
ts.show_scale = False
t.render("face_positions.png", w=800, tree_style=ts)
示例7: Tree
# 需要导入模块: from ete_dev import Tree [as 别名]
# 或者: from ete_dev.Tree import render [as 别名]
from ete_dev import Tree
t = Tree()
# Generate a random tree with 50 leaves
t.populate(50)
# Render tree in png and pdf format using the default size
t.render("./random_tree.png")
t.render("./random_tree.pdf")
# Render tree in pdf setting a custom width. height will be imputed
t.render("./random_tree.pdf", w=300)
# Render tree in pdf setting a custom height. Width will be imputed
t.render("./random_tree.pdf", h=600)
# Render tree in pdf setting a custom width and height
t.render("./random_tree.pdf", w=300, h=300)
示例8: Tree
# 需要导入模块: from ete_dev import Tree [as 别名]
# 或者: from ete_dev.Tree import render [as 别名]
C.opacity = 0.3
# And place as a float face over the tree
faces.add_face_to_node(C, node, 0, position="float")
# 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
ts = TreeStyle()
# Set our custom layout function
ts.layout_fn = layout
# Draw a tree
ts.mode = "c"
# We will add node names manually
ts.show_leaf_name = False
# Show branch data
ts.show_branch_length = True
ts.show_branch_support = True
t.render("bubble_map.png", w=600, dpi=300, tree_style=ts)
# t.show(tree_style=ts)
示例9: xrange
# 需要导入模块: from ete_dev import Tree [as 别名]
# 或者: from ete_dev.Tree import render [as 别名]
# n4.size = (10, 10)
#n2.size = 10
#n3.size = 10
#n5.size = 10
#n2.dist = 0.1
#n2.size = 1
#n3.size = 1
#n2.dist = 0.5
#t.populate(100)#, random_branches=True)
#t.write(outfile="test.nw")
ts.layout_fn = layout2
t.show(tree_style=ts)
ts.scale = 1
sys.exit()
t.show(tree_style=ts)
for x in xrange(30):
t = Tree()
t.dist = 0
t.populate(100, random_branches=True)
t.render("/tmp/kk.png", tree_style=ts)
sys.exit()
ts.layout_fn = layout
t.show(tree_style=ts)
ts.mode = "r"
t.show(tree_style=ts)
示例10: NodeStyle
# 需要导入模块: from ete_dev import Tree [as 别名]
# 或者: from ete_dev.Tree import render [as 别名]
# Set dashed blue lines in all leaves
nst1 = NodeStyle()
nst1["bgcolor"] = "LightSteelBlue"
nst2 = NodeStyle()
nst2["bgcolor"] = "Moccasin"
nst3 = NodeStyle()
nst3["bgcolor"] = "DarkSeaGreen"
nst4 = NodeStyle()
nst4["bgcolor"] = "Khaki"
t = Tree("((((a1,a2),a3), ((b1,b2),(b3,b4))), ((c1,c2),c3));")
n1 = t.get_common_ancestor("a1", "a2", "a3")
n1.set_style(nst1)
n2 = t.get_common_ancestor("b1", "b2", "b3", "b4")
n2.set_style(nst2)
n3 = t.get_common_ancestor("c1", "c2", "c3")
n3.set_style(nst3)
n4 = t.get_common_ancestor("b3", "b4")
n4.set_style(nst4)
ts = TreeStyle()
ts.layout_fn = layout
ts.show_leaf_name = False
ts.mode = "c"
t.render("node_background.png", w=400, tree_style=ts)
t.show(tree_style=ts)