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


Python TreeStyle.rotation方法代码示例

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


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

示例1: make_tree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import rotation [as 别名]
def make_tree(treefile, image_file, clone_info):
    colour_list = ['MidnightBlue','RoyalBlue', 'LightSkyBlue', 'Aquamarine', 'SpringGreen', 'GreenYellow',\
                   'Gold','DarkOrange']
    weeks = ['16', '30', '38', '48', '59', '119', '176', '206']
    weeks = ['6', '14', '53', '92','144']
    t = Tree(treefile,format = 1)
    ts = TreeStyle()
    for i in range(5):
        ts.legend.add_face(CircleFace(20, colour_list[i]), column=0)
        ts.legend.add_face(TextFace('week' + weeks[i]), column=1)
    ts.legend_position = 2
    ts.show_leaf_name = True
    ts.branch_vertical_margin = 15
    ts.rotation = 90
    ns = NodeStyle()
    ns["size"] = 1
    ns.hz_line_width = 10
    ns.vt_line_width = 10
    edge = 0
    for node in t.traverse():
        node.name = node.name.replace("'", "")
        node.name = node.name.replace(".", ",")
        name = node.name.split(' ')[0]
        print name
        if name in clone_info.keys():
            style_node(node, colour_list[int(clone_info[name][0])-1], int(int(clone_info[name][1])/10)+5)
        if not node.is_leaf() and node.name != 'NoName':
                f = TextFace(node.name)
                f.margin_top = 2.5
                f.margin_bottom = 2.5
                f.margin_right = 2.5
                f.margin_left = 2.5
                node.add_face(f, column=0, position="branch-top")
    t.render(image_file, tree_style = ts)
开发者ID:AnnaLaddach,项目名称:MRes-project,代码行数:36,代码来源:tree_functions3.py

示例2: show

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import rotation [as 别名]
	def show(self, i=0):
		t = Tree(str(self)+";")
		ts = TreeStyle()
		ts.show_leaf_name = True
		ts.rotation = 90
		t.render("mytree-{0}.png".format(i), w=183, units="mm", tree_style=ts)
		t.show(tree_style=ts)
开发者ID:c19,项目名称:DataStructure,代码行数:9,代码来源:avl_tree.py

示例3: plotTree

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

示例4: get_example_tree

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import rotation [as 别名]
def get_example_tree():
    t = Tree()
    t.populate(10)
    ts = TreeStyle()
    ts.rotation = 45
    ts.show_leaf_name = False
    ts.layout_fn = rotation_layout
    
    return t, ts
开发者ID:a1an77,项目名称:ete,代码行数:11,代码来源:face_rotation.py

示例5: _on_Button2_ButRel_1

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import rotation [as 别名]
	def _on_Button2_ButRel_1(self,Event=None):
		from ete2 import Tree
		from ete2 import TreeStyle
		players = int(float(self._Entry2.get()))
		timer = int(float(self._Entry1.get()))
		tree = MinMax(players, timer)
		ts = TreeStyle()
		ts.rotation=270
		ts.show_leaf_name=True
		t = Tree(newick='('+tree.head.getKids('Start')+');', format=0)
		t.render(file_name="MysteryBox.svg",tree_style=ts)
开发者ID:jasongi,项目名称:The-Mystery-Box-Solver,代码行数:13,代码来源:uther.py

示例6: render_tree_image

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import rotation [as 别名]
	def render_tree_image(self, filename):
		def my_layout(node):
			name_faces = AttrFace("name", fsize=10, fgcolor = "#0000FF")
			faces.add_face_to_node(name_faces, node, column=0, position="branch-right")
		t = Tree("%s;" % self.newick_string(), format = 1)
		s = "0"	
		for n in t.iter_descendants():
			text = TextFace(s)
			if s == "0": s = "1"
			else: s = "0"
			text.fgcolor = "#FF0000";
			nstyle = NodeStyle()
			nstyle['size'] = 15
			nstyle['fgcolor'] = "#333"
			n.set_style(nstyle)
			n.add_face(text, column = 0, position = "branch-top")
		ts = TreeStyle()
		ts.rotation = 90
		ts.show_leaf_name = False
		ts.layout_fn = my_layout
		ts.margin_left = 0
		ts.branch_vertical_margin = 50
		ts.show_scale = False
		t.render(filename, tree_style = ts, w = 2000)
开发者ID:lbalbastre,项目名称:Huffman-python,代码行数:26,代码来源:HuffmanImpl.py

示例7: input

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import rotation [as 别名]
			return '('+self.left.getKids('Q')+','+self.right.getKids('W')+')'+ label + '' + string.replace(string.replace(string.replace(string.replace(str(self.costs),',',''),' ', ''),'[',''),']','')

if ((len(sys.argv) == 2 and sys.argv[1] == '-cmd')):
	players = input("Input number of players: ")
	timer = input("Input timer number: ")
	tree = MinMax(players, timer)
	if (tree.doMove > 0):
		print tree.doMove
		print tree.head.costs
	else:
		print "It doesn't matter, you dead"
	if (raw_input('Render? Only if on Windows and have ETE2 package y/n: ') == 'y'):
		from ete2 import Tree
		from ete2 import TreeStyle
		ts = TreeStyle()
		ts.rotation=270
		ts.show_leaf_name=True
		t = Tree(newick='('+tree.head.getKids('Start')+');', format=0)
		t.render(file_name="MysteryBox.svg",tree_style=ts)
		print "Saved graph to MysteryBox.svg"
elif (len(sys.argv) == 2 and sys.argv[1] == '-gui'):
		#Adjust sys.path so we can find other modules of this project
		import sys
		if '.' not in sys.path:
			sys.path.append('.')
		#Put lines to import other modules of this project here
		
		if __name__ == '__main__':
			Root = Tk()
			import Tkinter
开发者ID:jasongi,项目名称:The-Mystery-Box-Solver,代码行数:32,代码来源:uther.py

示例8: cluster

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

#.........这里部分代码省略.........
            tokenType = u'char'
            if onlyCharGramsWithinWords:
                tokenType = u'char_wb'

        from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer
        vectorizer = CountVectorizer(input=u'content', encoding=u'utf-8', min_df=1,
                                      analyzer=tokenType, token_pattern=ur'(?u)\b[\w\']+\b',
                                      ngram_range=(ngramSize, ngramSize),
                                      stop_words=[], dtype=float, max_df=1.0)

        # make a (sparse) Document-Term-Matrix (DTM) to hold all counts
        DocTermSparseMatrix = vectorizer.fit_transform(allContents)
        dtm = DocTermSparseMatrix.toarray()

        from sklearn.metrics.pairwise import euclidean_distances
        from scipy.cluster.hierarchy import ward

        import matplotlib.pyplot as plt
        from scipy.cluster.hierarchy import average, weighted, ward, single, complete, dendrogram
        from scipy.cluster import hierarchy
        from scipy.spatial.distance import pdist

        if orientation == "left":
            orientation = "right"
        if orientation == "top":
            LEAF_ROTATION_DEGREE = 90
        else:
            LEAF_ROTATION_DEGREE = 0

        if linkage == "ward":
            dist = euclidean_distances(dtm)
            np.round(dist, 1)
            linkage_matrix = ward(dist)
            dendrogram(linkage_matrix, orientation=orientation, leaf_rotation=LEAF_ROTATION_DEGREE, labels=labels)
            Z = linkage_matrix
        else:
            Y = pdist(dtm, metric)
            Z = hierarchy.linkage(Y, method=linkage)
            dendrogram(Z, orientation=orientation, leaf_rotation=LEAF_ROTATION_DEGREE, labels=labels)

        plt.tight_layout()  # fixes margins

        ## Conversion to Newick/ETE
        # Stuff we need
        from scipy.cluster.hierarchy import average, linkage, to_tree
        #from hcluster import linkage, to_tree
        from ete2 import Tree, TreeStyle, NodeStyle

        # Change it to a distance matrix
        T = to_tree(Z)

        # ete2 section
        root = Tree()
        root.dist = 0
        root.name = "root"
        item2node = {T: root}

        to_visit = [T]
        while to_visit:
            node = to_visit.pop()
            cl_dist = node.dist /2.0
            for ch_node in [node.left, node.right]:
                if ch_node:
                    ch = Tree()
                    ch.dist = cl_dist
                    ch.name = str(ch_node.id)
开发者ID:bbrule,项目名称:Lexos,代码行数:70,代码来源:dendroToNewick.py

示例9: open

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import rotation [as 别名]
    SHAPE = 'c'
elif not args["-root"]:
    SHAPE = 'c'
else: SHAPE = args["-shape"]

tree_files = glob.glob( "{0}/trees/raxmltrees/*.nwk".format(INPUT_DIR))
small = [Tree( open(x).read() ) for x in tree_files]
for x in small:
    x.set_outgroup(ROOT)
    x.ladderize()
names = [x[1+x.rindex("/"):x.rindex(".")] for x in tree_files]
big = Tree( open("{0}/clusters/cluster_dendrogram.nwk".format(INPUT_DIR)).read() )
print names
small_d = dict(zip(names,small))
small_ts = TreeStyle()
small_ts.tree_width = 100
small_ts.show_leaf_name = True

big_ts = TreeStyle()
big_ts.show_leaf_name = False
big_ts.layout_fn = layout
if SHAPE == 'v':    
    big_ts.rotation = 90
    small_ts.rotation = -90
    big_ts.mode = 'r'
else: big_ts.mode = SHAPE


# big.show(tree_style=big_ts)
big.render("./treeoftrees.pdf",tree_style=big_ts)
开发者ID:kgori,项目名称:clustering_project,代码行数:32,代码来源:plotter.py

示例10: TreeStyle

# 需要导入模块: from ete2 import TreeStyle [as 别名]
# 或者: from ete2.TreeStyle import rotation [as 别名]
#ete_output_path="eteTree.png"
width = 600 # For other output args, see http://etetoolkit.org/docs/latest/tutorial/tutorial_drawing.html#rendering-trees-as-images

# Configure tree styles
ts = TreeStyle()
ts.show_leaf_name = True
ts.show_branch_length = True
ts.show_scale = False
ts.scale =  None

ts.mode = "c" # draw tree in circular style
ts.arc_start = 0
ts.arc_span = 360

if orientation == "top":
    ts.rotation = 90
    ts.branch_vertical_margin = 10 # 10 pixels between adjacent branches

# Remove the default small red spheres for each node
nstyle = NodeStyle()
nstyle["size"] = 0
for leaf in tree:
    k = leaf.name
    k = int(k)
    leaf.name = labels[k]

# Apply node styles to nodes
for n in tree.traverse():
   n.set_style(nstyle)

# Plot the tree
开发者ID:WheatonCS,项目名称:aGoodMystery,代码行数:33,代码来源:dendroToNewick.py


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