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


Python TreeStyle.mode方法代码示例

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


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

示例1: plotTree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import mode [as 别名]
 def plotTree(self, tree, out_fn=None, rotation=270, show_leaf_name=False, 
               show_branch_length=False, circularTree=False, show_division_nodes=True, 
               distance_between_branches=4, show_border=False, width=None, height=None):            
     from ete2 import TreeStyle        
     from PyQt4 import QtSvg, QtCore, QtGui
     from ete2.treeview import qt4_render, drawer, main
     
       
     ts = TreeStyle()   
     ts.show_scale = False
     ts.show_border = show_border
     ts.orientation = 1 # 0, tree is drawn from left-to-right. 1, tree is drawn from right-to-left
     ts.rotation = rotation
     ts.show_leaf_name = show_leaf_name
     ts.show_branch_length = show_branch_length
     if circularTree:
         ts.mode = 'c'
     else:
         ts.mode = 'r'
     ts.branch_vertical_margin = distance_between_branches
     
     
     def hideInternalNodesLayout(node):
         if not node.is_leaf():
             node.img_style["size"] = 0
     
     if show_division_nodes is False:
         ts.layout_fn = hideInternalNodesLayout
     
     if out_fn is not None:        
         scene  = qt4_render._TreeScene()
         img = ts
         
         tree_item, n2i, n2f = qt4_render.render(tree, img)
         scene.init_data(tree, img, n2i, n2f)
         tree_item.setParentItem(scene.master_item)
         scene.master_item.setPos(0,0)
         scene.addItem(scene.master_item)      
         main.save(scene, out_fn, w=width, h=height, dpi=600)    
           
     else:
         scene, img = drawer.init_scene(tree, None, ts)
         tree_item, n2i, n2f = qt4_render.render(tree, img)
         scene.init_data(tree, img, n2i, n2f)
     
         tree_item.setParentItem(scene.master_item)
         scene.addItem(scene.master_item)
     
         size = tree_item.rect()
         w, h = size.width(), size.height()
     
         svg = QtSvg.QSvgGenerator()
         svg.setFileName("test.svg")
         svg.setSize(QtCore.QSize(w, h))
         svg.setViewBox(size)
         pp = QtGui.QPainter()
         pp.begin(svg)            
         scene.render(pp, tree_item.rect(), tree_item.rect(), QtCore.Qt.KeepAspectRatio)
开发者ID:kkiefer,项目名称:ilastik,代码行数:60,代码来源:trackingUtilities.py

示例2: get_example_tree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.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:a1an77,项目名称:ete,代码行数:34,代码来源:node_background.py

示例3: build_vis

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import mode [as 别名]
def build_vis():
	ts = TreeStyle()
	ts.mode = "c"
	ts.arc_start = 0 # 0 degrees = 3 o'clock
	ts.arc_span = 360
	ts.layout_fn = my_layout # Use custom layout
	return ts
开发者ID:WebValley2014,项目名称:DataViz,代码行数:9,代码来源:import.py

示例4: get_example_tree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.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:a1an77,项目名称:ete,代码行数:27,代码来源:bubble_map.py

示例5: ETETree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import mode [as 别名]
def ETETree(seqs, ref, metric):
    """Tree showing bola alleles covered by tepitope"""
    from ete2 import Tree,PhyloTree,TreeStyle,NodeStyle
    aln = Genome.clustalAlignment(seqs=seqs)
    t = Tree('temp.dnd')
    #t.set_outgroup(t&ref)
    ts = TreeStyle()
    ts.show_leaf_name = True
    ts.mode = "c"
    ts.arc_start = -180
    ts.arc_span = 180
    cutoff=0.25
    def func(node):
        if node.name=='NoName' or not node.name in metric:
            return False
        if metric[node.name]<=cutoff:
            return True
    matches = filter(func, t.traverse())
    print len(matches), "nodes have distance <=%s" %cutoff
    nst1 = NodeStyle()
    nst1["bgcolor"] = "Yellow"
    for n in matches:
        n.set_style(nst1)
    nst2 = NodeStyle()
    nst2["bgcolor"] = "LightGreen"
    hlanodes = [t.get_leaves_by_name(name=r)[0] for r in refalleles]
    for n in hlanodes:
        n.set_style(nst2)
    t.show(tree_style=ts)
    return
开发者ID:dmnfarrell,项目名称:epitopemap,代码行数:32,代码来源:sequtils.py

示例6: visualizeTree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import mode [as 别名]
def visualizeTree(sTreePath, pathToSfamilies, bootValue, width, height):
    # Random tree
    stree = Tree()
    stree = readTreeFromFile(sTreePath)
   
    snodesStatDic={}
    snodesStatDic= getFamiliesStatisticsForEachNode(pathToSfamilies, bootValue)
    #print snodesStatDic
    # Some random features in all nodes
    for n in stree.traverse():
        if n.name in snodesStatDic.keys():
            total= reduce(lambda x,y: x+y, snodesStatDic[n.name])
            #norm= [(x*100)/total for x in snodesStatDic[n.name]]
            norm= [x for x in snodesStatDic[n.name]]
            n.add_features(pie_data=norm)
    # Create an empty TreeStyle
    ts = TreeStyle()

    # Set our custom layout function
    ts.layout_fn=layout

    # Draw a tree 
    ts.mode = "r"
    
    #ts.force_topology= False
    ts.complete_branch_lines_when_necessary= True
    # 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 stree, ts
开发者ID:malagori,项目名称:PhyloGenClust,代码行数:36,代码来源:visualizeResults.py

示例7: showTreeInGrid

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import mode [as 别名]
def showTreeInGrid(gid,biome,grid_level=14,taxonomic_level='sp'):
    """
    Performs a selection, spatial filter and returns an image.
    grid_level is the grid layer.
    taxonomic_level is the taxonomic level to be shown. Options are:
    sp, gns, fam, ord, cls, phy, king
    """
    
    mesh = initMesh(grid_level)
    try:
        cell = mesh.objects.get(id=id)
    except:
        logger.error("Selected id does not exist in selected grid")
        return None
    
    gb=GriddedTaxonomy(biome,cell,generate_tree_now=True)
    forest = gb.taxonomies[0].forest

    ts = TreeStyle()
    ts.show_leaf_name = True
    ts.mode = "c"
    ts.arc_start = -180 # 0 degrees = 3 o'clock
    ts.arc_span = 360

    forest[taxonomic_level].show(tree_style=ts)
    return 'Parece que se tiene que ver algo'
开发者ID:molgor,项目名称:biospatial,代码行数:28,代码来源:actionsQGIS.py

示例8: generateImage

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import mode [as 别名]
 def generateImage(self, tree):
     ts = TreeStyle()
     ts.layout_fn = self.__layout__
     ts.mode = "c"
     ts.show_leaf_name = False
     tree.render(self.treePNGFile, w=1000, tree_style = ts)
     tree.render(self.treeSVGFile, w=250, tree_style = ts)
开发者ID:mahdi-b,项目名称:symTyper,代码行数:9,代码来源:PlacementTree_ete2.py

示例9: get_example_tree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.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:molsim,项目名称:ete,代码行数:10,代码来源:barchart_and_piechart_faces.py

示例10: get_example_tree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.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:a1an77,项目名称:ete,代码行数:11,代码来源:floating_piecharts.py

示例11: get_tree_style

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

示例12: draw_ete_tree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import mode [as 别名]
    def draw_ete_tree(self, corpus, fontsize=5,
                      color_leafs=False,
                      save_newick=True, mode='c',
                      outputfile=None,
                      return_svg=True, show=False,
                      save=False):
        root = self.to_ete(labels=corpus.titles)

        def layout(node):
            if node.is_leaf():
                N = AttrFace("name", fsize=7)
                faces.add_face_to_node(faces.AttrFace("name","Arial",10, None), node, 0, position='branch-right')
                # problems: aligment of labels to branch, left padding of labels

        ts = TreeStyle()
        ts.mode = mode
        ts.show_leaf_name = False
        ts.scale = 120
        ts.show_scale = False
        ts.branch_vertical_margin = 10

        nstyle = NodeStyle()
        nstyle["fgcolor"] = "#0f0f0f"
        nstyle["size"] = 0
        nstyle["vt_line_color"] = "#0f0f0f"
        nstyle["hz_line_color"] = "#0f0f0f"
        nstyle["vt_line_width"] = 1
        nstyle["hz_line_width"] = 1
        nstyle["vt_line_type"] = 0
        nstyle["hz_line_type"] = 0

        for n in root.traverse():
           n.set_style(nstyle)
        
        ts.layout_fn = layout

        if outputfile:
            outputfile = os.path.expanduser(outputfile)

        if save_newick: # save tree in newick format for later manipulation in e.g. FigTree:
            root.write(outfile=os.path.splitext(outputfile)[0]+'.newick')

        if save:
            root.render(outputfile, tree_style=ts)
        if show:
            root.show(tree_style=ts) 
        if return_svg: # return the SVG as a string
            return root.render("%%return")[0]
开发者ID:akvankorlaar,项目名称:pystyl,代码行数:50,代码来源:dendrogram.py

示例13: get_tree_style

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

示例14: render_tree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.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:a1an77,项目名称:ete,代码行数:20,代码来源:utils.py

示例15: give_tree_layout

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

	# for all nodes give them the weight = score
	for n in t.traverse():
		n.add_features(weight=n.dist/20.0)

	# Create an empty TreeStyle
	ts = TreeStyle()

	# Set our custom layout function
	ts.layout_fn = layout

	ts.show_leaf_name = False
	# Draw a tree 
	ts.mode = "c"
	#ts.arc_start = -180
	#ts.arc_span = 180
	#ts.scale = 100
	ts.min_leaf_separation = 10
	ts.show_scale = False

	return ts
开发者ID:sanja7s,项目名称:SR_Twitter,代码行数:24,代码来源:bubble_tree_map_COM.py


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