当前位置: 首页>>代码示例>>Python>>正文


Python TreeStyle.mode方法代码示例

本文整理汇总了Python中ete3.TreeStyle.mode方法的典型用法代码示例。如果您正苦于以下问题:Python TreeStyle.mode方法的具体用法?Python TreeStyle.mode怎么用?Python TreeStyle.mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ete3.TreeStyle的用法示例。


在下文中一共展示了TreeStyle.mode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_example_tree

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
def get_example_tree():
    # 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

    return t, ts
开发者ID:cancerconnector,项目名称:clonal-evolution,代码行数:27,代码来源:bubble_tree_example.py

示例2: show_tree

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
def show_tree(experiment_folder):
    model = MDPD.Hierachical_MDPD(1)
    model.load(os.path.join(experiment_folder, 'model.p'))

    width, depth = model.width, model.depth

    root = Tree()

    cache = [(0, root)]

    for i in range(depth + 1):
        foo = []

        for idx, node in cache:
            paren = int((idx - 1) / width)
            kid = idx - paren * width
            face = faces.ImgFace(os.path.join(experiment_folder, 'images', '{}_{}_{}.png'.format(idx, paren, kid)))
            node.add_face(face, 0)

            if i < depth:
                for k in range(width):
                    foo.append((idx * width + k + 1, node.add_child()))

        cache = foo

    ts = TreeStyle()
    ts.mode = "c"

    root.render(os.path.join(experiment_folder, 'images', 'tree_plot.png'), tree_style=ts)
    return root
开发者ID:zyzzhaoyuzhe,项目名称:MDPD,代码行数:32,代码来源:EXP_MNIST.py

示例3: get_example_tree

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
def get_example_tree():

    # 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));")
    for n in t.traverse():
        n.dist = 0

    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"
    ts.root_opening_factor = 1
    return t, ts
开发者ID:AlishaMechtley,项目名称:ete,代码行数:34,代码来源:node_background.py

示例4: get_example_tree

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
def get_example_tree():
    t = Tree()
    ts = TreeStyle()
    ts.layout_fn = layout
    ts.mode = "r"
    ts.show_leaf_name = False
    t.populate(10)
    return t, ts
开发者ID:abdo3a,项目名称:ete,代码行数:10,代码来源:barchart_and_piechart_faces.py

示例5: get_example_tree

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
def get_example_tree():
    t = Tree()
    ts = TreeStyle()
    ts.layout_fn = layout
    ts.mode = "c"
    ts.show_leaf_name = True
    ts.min_leaf_separation = 15
    t.populate(100)
    return t, ts
开发者ID:AlishaMechtley,项目名称:ete,代码行数:11,代码来源:floating_piecharts.py

示例6: balanceplot

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
def balanceplot(balances, tree,
                layout=None,
                mode='c'):
    """ Plots balances on tree.

    Parameters
    ----------
    balances : np.array
        A vector of internal nodes and their associated real-valued balances.
        The order of the balances will be assumed to be in level order.
    tree : skbio.TreeNode
        A strictly bifurcating tree defining a hierarchical relationship
        between all of the features within `table`.
    layout : function, optional
        A layout for formatting the tree visualization. Must take a
        `ete.tree` as a parameter.
    mode : str
        Type of display to show the tree. ('c': circular, 'r': rectangular).

    Note
    ----
    The `tree` is assumed to strictly bifurcating and
    whose tips match `balances.

    See Also
    --------
    TreeNode.levelorder
    """
    # The names aren't preserved - let's pray that the topology is consistent.
    ete_tree = Tree(str(tree))
    # Some random features in all nodes
    i = 0
    for n in ete_tree.traverse():
        if not n.is_leaf():
            n.add_features(weight=balances[-i])
            i += 1

    # Create an empty TreeStyle
    ts = TreeStyle()

    # Set our custom layout function
    if layout is None:
        ts.layout_fn = default_layout
    else:
        ts.layout_fn = layout
    # Draw a tree
    ts.mode = mode

    # We will add node names manually
    ts.show_leaf_name = False
    # Show branch data
    ts.show_branch_length = True
    ts.show_branch_support = True

    return ete_tree, ts
开发者ID:mortonjt,项目名称:canvas,代码行数:57,代码来源:balances.py

示例7: _get_motif_tree

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
def _get_motif_tree(tree, data, circle=True, vmin=None, vmax=None):
    try:
        from ete3 import Tree, NodeStyle, TreeStyle
    except ImportError:
        print("Please install ete3 to use this functionality")
        sys.exit(1)

    t = Tree(tree)
    
    # Determine cutoff for color scale
    if not(vmin and vmax):
        for i in range(90, 101):
            minmax = np.percentile(data.values, i)
            if minmax > 0:
                break
    if not vmin:
        vmin = -minmax
    if not vmax:
        vmax = minmax
    
    norm = Normalize(vmin=vmin, vmax=vmax, clip=True)
    mapper = cm.ScalarMappable(norm=norm, cmap="RdBu_r")
    
    m = 25 / data.values.max()
    
    for node in t.traverse("levelorder"):
        val = data[[l.name for l in node.get_leaves()]].values.mean()
        style = NodeStyle()
        style["size"] = 0
        
        style["hz_line_color"] = to_hex(mapper.to_rgba(val))
        style["vt_line_color"] = to_hex(mapper.to_rgba(val))
        
        v = max(np.abs(m * val), 5)
        style["vt_line_width"] = v
        style["hz_line_width"] = v

        node.set_style(style)
    
    ts = TreeStyle()

    ts.layout_fn = _tree_layout
    ts.show_leaf_name= False
    ts.show_scale = False
    ts.branch_vertical_margin = 10

    if circle:
        ts.mode = "c"
        ts.arc_start = 180 # 0 degrees = 3 o'clock
        ts.arc_span = 180
    
    return t, ts
开发者ID:simonvh,项目名称:gimmemotifs,代码行数:54,代码来源:plot.py

示例8: render_tree

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
def render_tree(tree, fname):
    # Generates tree snapshot
    npr_nodestyle = NodeStyle()
    npr_nodestyle["fgcolor"] = "red"
    for n in tree.traverse():
        if hasattr(n, "nodeid"):
            n.set_style(npr_nodestyle)
    ts = TreeStyle()
    ts.show_leaf_name = True
    ts.show_branch_length = True
    ts.show_branch_support = True
    ts.mode = "r"
    iterface = faces.TextFace("iter")
    ts.legend.add_face(iterface, 0)

    tree.dist = 0
    tree.sort_descendants()
    tree.render(fname, tree_style=ts, w=700)
开发者ID:Ward9250,项目名称:ete,代码行数:20,代码来源:utils.py

示例9: get_default_tree_style

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
def get_default_tree_style(color_dict):
    ts = TreeStyle()
    ts.mode = "c"
    # ts.layout_fn = layout
    ts.margin_top = 50
    ts.margin_bottom = 0
    ts.margin_left = 50
    ts.margin_right = 50
    ts.show_scale = False
    ts.show_leaf_name = False
    ts.show_branch_length = False
    ts.show_branch_support = False
    for p, c in color_dict.iteritems():
        ts.legend.add_face(TextFace("    ", fsize=30), column=0)
        ts.legend.add_face(CircleFace(10, c), column=1)
        ts.legend.add_face(TextFace("   %s" % p, fsize=30), column=2)
    legend_margin_line = 5
    while legend_margin_line:
        ts.legend.add_face(TextFace(" "), column=0)
        ts.legend.add_face(TextFace(" "), column=1)
        ts.legend.add_face(TextFace(" "), column=2)
        legend_margin_line -= 1
    ts.legend_position = 3
    return ts
开发者ID:tianyabeef,项目名称:real_amplicon,代码行数:26,代码来源:02_plot_phylo_tree.py

示例10: open

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
@author: diyadas

This script plots trees of our wikipedia data.

"""

from ete3 import Tree, TreeStyle, NodeStyle

with open('/Users/diyadas/cdips/Topic-Ontology/SimpleWikiTree_u.txt','r') as f:
    treestr = f.readlines()[0]    
    

t = Tree( treestr.rstrip(),format=8)

circular_style = TreeStyle()
circular_style.mode = "c" # draw tree in circular mode
circular_style.scale = 120
circular_style.show_leaf_name = True
circular_style.show_branch_length = True
circular_style.show_branch_support = True
t.render("mytree.png", tree_style=circular_style)


nstyle = NodeStyle()
nstyle["hz_line_width"] = 3
nstyle["vt_line_width"] = 3

# Applies the same static style to all nodes in the tree. Note that,
# if "nstyle" is modified, changes will affect to all nodes
for n in t.traverse():
   n.set_style(nstyle)
开发者ID:tristanlmiller,项目名称:Topic-Ontology,代码行数:33,代码来源:wikitree.py

示例11: Tree

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
                        

#root = Tree( "((a,b),c);" )

[rows, columns] = treeStruct.shape

root = Tree()
node_cur = root

'''#######################
 Tree Style Begin
'''
ts = TreeStyle()
ts.title.add_face(TextFace("Tree example", fsize=8), column=0)
ts.scale = 50
ts.mode = 'r'

# left or right
ts.orientation = 1

ts.rotation = 270
ts.show_leaf_name = False
ts.show_branch_length = True
#ts.show_branch_length = True
'''
 Tree Style End
#######################'''



开发者ID:joe8767,项目名称:treeDrawing,代码行数:29,代码来源:lineageTree.py

示例12: main

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
def main(args):
	if args.alignment:
		t = PhyloTree(args.tree, alignment=args.alignment, alg_format='fasta')
	else:
		t = PhyloTree(args.tree)

	if args.highlight_new:
		runs = read_runs(args.highlight_new)

	t.set_outgroup('EM_079422')
	t.ladderize()

	ts = TreeStyle()
	ts.show_leaf_name = False
	ts.show_branch_support = False
	ts.layout_fn = layout

	thick_hz_line = NodeStyle()
	thick_hz_line["hz_line_width"] = 8
	t.set_style(thick_hz_line)
	#t.children[0].set_style(thick_hz_line)
	#t.children[1].set_style(thick_hz_line)

	thick_vt_line = NodeStyle()
	thick_vt_line["vt_line_width"] = 4
	t.set_style(thick_vt_line)

	# header
	if not args.hide_annotations:
		ts.aligned_header.add_face(MyTextFace('Sample identifier', fstyle='Bold', fsize=8, tight_text=False), column = 1)
		ts.aligned_header.add_face(MyTextFace('Prefecture', fstyle='Bold', fsize=8, tight_text=False), column = 2)
		ts.aligned_header.add_face(MyTextFace('Sous-prefecture', fstyle='Bold', fsize=8, tight_text=False), column = 3)
		ts.aligned_header.add_face(MyTextFace('Village', fstyle='Bold', fsize=8, tight_text=False), column = 4)
		ts.aligned_header.add_face(MyTextFace('Sample received', fstyle='Bold', fsize=8, tight_text=False), column = 5)

	if args.positions:
		positions = read_positions(args.positions)

		alg_header = RulerFace(positions,
                              col_width=11,
                              height=0, # set to 0 if dont want to use values
                              kind="stick",
                              hlines = [0],
                              hlines_col = ["white"], # trick to hide hz line
                              )

		ts.aligned_header.add_face(alg_header, 6)

	#legend
	if args.legend:
		legend = {}
		for s in samples.values():
			legend[s['prefec']] = s['prefec__colour']
		for p in sorted(legend.keys()):
			ts.legend.add_face(CircleFace(4, legend[p]), column=0)
			ts.legend.add_face(MyTextFace(p, fsize=6, tight_text=False), column=1)	
		ts.legend_position=1

	if args.circular:
		ts.mode = "c"
		ts.arc_start = -180 # 0 degrees = 3 o'clock
		ts.arc_span = 180

#	t.show(tree_style=ts)
	t.render(args.output, tree_style=ts, w=1024)
开发者ID:nickloman,项目名称:ebov,代码行数:67,代码来源:pdf_tree.py

示例13: TreeStyle

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
                faces.add_face_to_node(name, node, 0, aligned=True)
            fake = faces.TextFace(" ")
            fake.background.color = "white"
            faces.add_face_to_node(fake, node, 1, aligned=True) # fake
        else:
            if not args.no_internal_names and node.get_distance(tNCBI, topology_only=True) < 3:
                name = faces.TextFace(node.sci_name, fsize=12, fstyle='italic')
                faces.add_face_to_node(name, node, 0, position='branch-top')

            
    S = TreeStyle()
    #S.allow_face_overlap = True
    S.show_leaf_name = False
    #S.scale = 200
    #S.draw_aligned_faces_as_table = True
    #S.aligned_table_style = 0
    #S.min_leaf_separation = 1
    if args.mode == 'r':
        S.mode = 'r'
    elif args.mode == 'c':
        S.mode = 'c'

    if args.save:
        tNCBI.render(file_name=args.save, layout=layout, tree_style=S)
    else:
        print "showing"
        tNCBI.show(layout=layout, tree_style=S)


        
开发者ID:alxndrsPittis,项目名称:GeneticCodes,代码行数:29,代码来源:plot_taxonomic_tree_simple.py

示例14: TreeStyle

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
            nstyle['bgcolor'] = cp[0]
        elif abr == 'pbi':
            nstyle['bgcolor'] = cp[1]
        elif abr == 'pte':
            nstyle['bgcolor'] = cp[2]
        elif abr == 'ppe':
            nstyle['bgcolor'] = cp[3]
        elif abr == 'pse':
            nstyle['bgcolor'] = cp[4]
        elif abr == 'poc':
            nstyle['bgcolor'] = cp[5]
        elif abr == 'ptr':
            nstyle['bgcolor'] = cp[6]
        elif abr == 'pso':
            nstyle['bgcolor'] = cp[7]
        elif abr == 'pca':
            nstyle['bgcolor'] = cp[8]
        elif abr == 'tth':
            nstyle['bgcolor'] = cp[9]
        else:
            nstyle['bgcolor'] = "#000000"
        node.set_style(nstyle)


ts = TreeStyle()
#ts.show_leaf_name = False
ts.mode = 'c'
ts.title.add_face(TextFace(title, fsize=20), column=0)
#t.show(tree_style = ts)
t.render(outputfile, tree_style = ts)
开发者ID:,项目名称:,代码行数:32,代码来源:

示例15: str

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import mode [as 别名]
	else:
		#We're at the root node
		new_node.dist = 0

	cur_node_id = str(current_bud_row.OrgID)

	for idx, new_row in saved_pop_hosts[saved_pop_hosts.ParentID.eq(cur_node_id)].iterrows():	
		build_tree_recursive(new_row, new_node)

	return new_node


root_node_row = saved_pop_hosts[saved_pop_hosts.ParentID == "(none)"].squeeze()
print("Building Tree")
build_tree_recursive(root_node_row, host_phylo)


print("Drawing Tree")
#Some drawing code
ts = TreeStyle()
ts.show_leaf_name = True
ts.mode = "c"
ts.arc_start = -180 # 0 degrees = 3 o'clock
ts.arc_span = 180
host_phylo.render("tree.png", tree_style=ts)

print("Saving Tree")
#Write the Newick Format Tree
host_phylo.write(format=1, outfile="avida_tree.nw")

开发者ID:,项目名称:,代码行数:31,代码来源:


注:本文中的ete3.TreeStyle.mode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。