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


Python TreeStyle.optimal_scale_level方法代码示例

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


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

示例1: draw_ete2_tree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import optimal_scale_level [as 别名]
def draw_ete2_tree(organism, snplist, tree_file_name, config, c):
    '''Draws a phylogenetic tree using ETE2

    Keyword arguments:
    organism -- the organism of which to make a tree
    snplist -- a list of the SNP names, positions and state
    file_name -- the name of the out-file _tree.pdf will be added

    '''
    newick = tree_to_newick(organism, config, c)
    tree = Tree(newick, format=1)
    tree_depth = int(tree.get_distance(tree.get_farthest_leaf()[0]))
    for n in tree.traverse():
        # Nodes are set to red colour
        nstyle = NodeStyle()
        nstyle["fgcolor"] = "#BE0508"
        nstyle["size"] = 10
        nstyle["vt_line_color"] = "#000000"
        nstyle["hz_line_color"] = "#000000"
        nstyle["vt_line_type"] = 0
        nstyle["hz_line_type"] = 0
        nstyle["vt_line_width"] = 2
        nstyle["hz_line_width"] = 2
        for snp in snplist:
            if n.name == snp[0]:
                if snp[1] == snp[3]:
                    # If the SNP is Derived in snplist,
                    # change appearance of node
                    nstyle["fgcolor"] = "#99FF66"
                    nstyle["size"] = 15
                    nstyle["vt_line_color"] = "#000000"
                    nstyle["hz_line_color"] = "#000000"
                    nstyle["vt_line_type"] = 0
                    nstyle["hz_line_type"] = 0
                elif snp[3] == "-":
                    # If the SNP is missing due to a gap, make it grey
                    nstyle["fgcolor"] = "#DDDDDD"
                    nstyle["size"] = 10
                    nstyle["vt_line_color"] = "#DDDDDD"
                    nstyle["hz_line_color"] = "#DDDDDD"
                    nstyle["vt_line_type"] = 1
                    nstyle["hz_line_type"] = 1
        n.set_style(nstyle)
    ts = TreeStyle()
    ts.show_leaf_name = False  # Do not print(leaf names, they are added in layout)
    ts.show_scale = False  # Do not show the scale
    ts.layout_fn = CanSNPer_tree_layout  # Use the custom layout
    ts.optimal_scale_level = 'full'  # Fully expand the branches of the tree
    if config["dev"]:
        print("#[DEV] Tree file: %s" % tree_file_name)
    tree.render(tree_file_name, tree_style=ts, w=tree_depth * 500)
开发者ID:druvus,项目名称:CanSNPer,代码行数:53,代码来源:__main__.py

示例2: get_tree_style

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import optimal_scale_level [as 别名]
def get_tree_style(tree_file, abund, rownames):

    with open("matrix.txt", "w") as temp:
        cols = len(abund[0])
        header = "#Names"
        for i in xrange(cols):
            header += "\tOTU%d" % i
        temp.write("%s\n" % header)
        for i, row in enumerate(abund):
            temp.write("%s\t%s\n" % (rownames[i], '\t'.join([str(i) for i in row])))

    t = Tree(tree_file)
    t.convert_to_ultrametric(10)

    assert isinstance(abund, numpy.ndarray)
    assert isinstance(rownames, numpy.ndarray)
    ts = TreeStyle()
    ts.mode = "r"
    ts.show_leaf_name = False
    ts.show_scale = False
    ts.show_branch_length = False
    ts.branch_vertical_margin = 20
    ts.force_topology = True
    ts.optimal_scale_level = "full"
    ts.scale = 50
    ts.draw_guiding_lines = True
    ts.guiding_lines_type = 0
    ts.guiding_lines_color = "black"
    for n in t.traverse():
        if not n.is_leaf():
            nstyle = NodeStyle()
            n.set_style(nstyle)
            nstyle['size'] = 0
            nstyle['hz_line_width'] = 3
            nstyle['vt_line_width'] = 3
        else:
            nstyle = NodeStyle()
            n.set_style(nstyle)
            nstyle['size'] = 0
            nstyle['hz_line_width'] = 3
            nstyle['vt_line_width'] = 3
            nstyle['fgcolor'] = "Black"
            nstyle['shape'] = "square"
            name_face = AttrFace("name", fsize=14, ftype="Arial", fgcolor="black", penwidth=10, text_prefix=" ", text_suffix=" ")
            n.add_face(name_face, column=0, position="aligned")
            row_index = rownames.tolist().index(n.name)
            col = 1
            for i in xrange(10):
                col += 1
                n.add_face(CircleFace(5, color=get_color(abund, row_index, i)), column=col, position="aligned")
    return t, ts
开发者ID:alexwaldrop123,项目名称:bayesiansimulation,代码行数:53,代码来源:draw_sim_tree_with_matrix.py

示例3: setTreeStyle

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import optimal_scale_level [as 别名]
def setTreeStyle(style, layoutfunction):
    #consolidate options for showing trees
    #pass in string "circle" or "rect" and a layout function
    I = TreeStyle()
    if style == "circle":
        I.tree_width = 1200
        I.layout_fn = layoutfunction
        I.show_branch_length = False
        #I.show_branch_support = True
        I.show_leaf_name = False
        I.mode = "c"
        I.force_topology = True
        #I.legend_position = 3
        I.extra_branch_line_type = 1
        I.guiding_lines_type = 1
        I.guiding_lines_color = "#666666"
        I.extra_branch_line_color = "#666666"
        I.optimal_scale_level = "full"
        I.root_opening_factor = 0
        
    elif style =="rect":
        I = TreeStyle()
        I.layout_fn = layoutfunction
        I.show_leaf_name = False
        I.force_topology = True
        I.optimal_scale_level = "semi"
        
    else:
        I.layout_fn = layoutfunction
        I.show_leaf_name = False
        I.force_topology = True
        I.optimal_scale_level = "semi"
    return I

    

    
开发者ID:michaelalfaro,项目名称:tools,代码行数:35,代码来源:phy_utils.py

示例4: get_tree_style

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import optimal_scale_level [as 别名]
def get_tree_style(tree, metadata, colors):
    assert isinstance(tree, TreeNode)
    ts = TreeStyle()
    ts.mode = "c"
    ts.show_leaf_name = False
    ts.show_scale = False
    ts.show_branch_length = False
    ts.force_topology = True
    ts.optimal_scale_level = "mid"
    get_node_styles(tree, metadata, colors)

    for site, color in colors.items():
        if 'Gastro' in site:
            site = "GI"
        ts.legend.add_face(CircleFace(7, color), column=0)
        ts.legend.add_face(TextFace(" %s" % site, fsize=20), column=1)
    return ts
开发者ID:alexwaldrop123,项目名称:bayesiansimulation,代码行数:19,代码来源:draw_dacc_tree.py

示例5: TreeFace

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import optimal_scale_level [as 别名]
n = main_tree.add_child()
n.add_face(temp_tface, 0, "aligned")

ts.optimal_scale_level = "full"
temp_tface = TreeFace(t, ts)
n = main_tree.add_child()
n.add_face(temp_tface, 0, "aligned")

ts = TreeStyle()
t.populate(5)
ts.mode = "c"
temp_tface = TreeFace(t, ts)
n = main_tree.add_child()
n.add_face(temp_tface, 0, "aligned")

ts.optimal_scale_level = "full"
temp_tface = TreeFace(t, ts)
n = main_tree.add_child()
n.add_face(temp_tface, 0, "aligned")

t, ts = Tree(), TreeStyle()
temp_tface = TreeFace(Tree(), ts)
n = main_tree.add_child()
n.add_face(temp_tface, 0, "aligned")

t, ts = Tree(), TreeStyle()
ts.mode = "c"
temp_tface = TreeFace(Tree(), ts)
n = main_tree.add_child()
n.add_face(temp_tface, 0, "aligned")
开发者ID:sshukla31,项目名称:misc_algos,代码行数:32,代码来源:test_treeview.py

示例6: random_color

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import optimal_scale_level [as 别名]
        f = faces.TextFace("NAME", fsize=10)
        #faces.add_face_to_node(f, node, 0, position="branch-right")
        f.border.width = 0
    #node.img_style["bgcolor"] = random_color()

#Tree().show()
ts = TreeStyle()
ts.mode = "c"
ts.layout_fn = layout 
ts.show_leaf_name = False
ts.arc_span = 340
ts.arc_start = -70
#ts.allow_face_overlap = True
#ts.show_branch_length = True
ts.draw_guiding_lines = False
ts.optimal_scale_level = "mid"
ts.extra_branch_line_color = "red"
ts.root_opening_factor = 0.50
ts.show_border = True
ts.scale = None
t = Tree()
t.populate(200, random_branches=True, branch_range=(0, 0))
t.dist = 0.0
dists = [n.dist for n in t.traverse() if n.dist != 0]
#print max(dists), min(dists)
t.write(outfile="test.nw")
#for s in [5, None]:
#    ts.scale = s
#    t.render("img_scale_%s.png" %s, tree_style = ts, w=600)
t.show(tree_style=ts)
开发者ID:a1an77,项目名称:ete,代码行数:32,代码来源:test_circ_scale.py


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