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


Python TreeStyle.scale方法代码示例

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


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

示例1: drawTree

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import scale [as 别名]
def drawTree(treeFile, ShowBool):
	"""
	Draw a tree from a phy file
	"""
	t = Tree(treeFile)
	imgFile = treeFile.replace(".tree", ".tree.png")

	# Basic tree style
	ts = TreeStyle()
	ts.show_leaf_name = True
	ts.show_branch_support = True
	ts.scale =  160

	# Draws nodes as small red spheres of diameter equal to 10 pixels
	nstyle = NodeStyle()
	nstyle["shape"] = "sphere"
	nstyle["size"] = 10
	nstyle["fgcolor"] = "darkred"
	#nstyle["faces_bgcolor"] = "pink"

	nstyle2 = NodeStyle()
	nstyle2["shape"] = "sphere"
	nstyle2["size"] = 10
	nstyle2["fgcolor"] = "darkblue"
	


	# Gray dashed branch lines
	nstyle["hz_line_type"] = 1
	nstyle["hz_line_color"] = "#cccccc"

	# 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():
		if n.is_leaf():
			if n.name.split("|")[-1] == "GI":
				n.set_style(nstyle)
			if n.name.split("|")[-1] == "plasmid":
				n.set_style(nstyle2)
			gi = n.name.split("|")[1]
			n.name = n.name.split("|")[0] #+ "   " + n.name.split("|")[1]
			n.name = n.name.replace("_tRNA_modification_GTPase_", "")
			n.name = n.name.replace("_DNA", "")
			n.name = " " + n.name + " "
			if n.name[-1] == "_": n.name.rstrip()
			
			taxon, color = taxonToColour(gi)
			n.add_face(TextFace(taxon, fgcolor = color, fsize = 8), column=1, position="branch-right")
			#n.img_style["bgcolor"] = color
			
	if ShowBool == True: #permet de flipper les braches pour avoir des topologies similaires
		t.show(tree_style=ts)
	t.render(imgFile, w=393, units="mm", tree_style=ts)
开发者ID:MathGon,项目名称:SGI_TA,代码行数:55,代码来源:3_alignment_and_phylo.py

示例2: TreeStyle

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import scale [as 别名]
# remove dodgy sample
big_tree.search_nodes(name="'EBOV|EMLab-RT|IPDPFHGINSP_GUI_2015_5339||GIN|Conakry|?|MinION_LQ05|2015-04-08'")[0].delete(
    preserve_branch_length=True
)
# root the same as the MCC tree
ancestor = big_tree.get_common_ancestor(
    "'EBOV|EMLab|EM_079422|KR817187|GIN|Macenta|?||2014-03-27'",
    "'EBOV|EMLab|Gueckedou-C05|KJ660348|GIN|Gueckedou|?||2014-03-19'",
)
big_tree.set_outgroup(ancestor)
big_tree.ladderize()

ts = TreeStyle()
ts.show_leaf_name = False
# ts.show_branch_support = True
ts.scale = 100000
if mode == "small":
    ts.scale = 750000

# add legend
for each in colourDict.keys():
    ts.legend.add_face(CircleFace(radius=size[mode] / 2, color=colourDict[each]), column=0)
    ts.legend.add_face(TextFace(each, ftype="Helvetica", fsize=size[mode]), column=1)
ts.legend.add_face(CircleFace(radius=size[mode] / 2, color="#F1F1F1"), column=0)
ts.legend.add_face(TextFace("Guinea", ftype="Helvetica", fsize=size[mode]), column=1)
ts.legend.add_face(RectFace(width=size[mode], height=size[mode], bgcolor="#D3D3D3", fgcolor="#FFFFFF"), column=0)
ts.legend.add_face(TextFace("Sierra Leone", ftype="Helvetica", fsize=size[mode]), column=1)
ts.legend.add_face(
    RectFace(triangle=True, width=size[mode], height=size[mode], bgcolor="#939393", fgcolor="#FFFFFF"), column=0
)
ts.legend.add_face(TextFace("Liberia", ftype="Helvetica", fsize=size[mode]), column=1)
开发者ID:meren,项目名称:ebov,代码行数:33,代码来源:generate_tree_figure.py

示例3: draw_tree

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import scale [as 别名]
def draw_tree(tree, conf, outfile):
    try:
        from ete3 import (add_face_to_node, AttrFace, TextFace, TreeStyle, RectFace, CircleFace,
                             SequenceFace, random_color, SeqMotifFace)
    except ImportError as e:
        print(e)
        return

    def ly_basic(node):
        if node.is_leaf():
            node.img_style['size'] = 0
        else:
            node.img_style['size'] = 0
            node.img_style['shape'] = 'square'
            if len(MIXED_RES) > 1 and hasattr(node, "tree_seqtype"):
                if node.tree_seqtype == "nt":
                    node.img_style["bgcolor"] = "#CFE6CA"
                    ntF = TextFace("nt", fsize=6, fgcolor='#444', ftype='Helvetica')
                    add_face_to_node(ntF, node, 10, position="branch-bottom")
            if len(NPR_TREES) > 1 and hasattr(node, "tree_type"):
                node.img_style['size'] = 4
                node.img_style['fgcolor'] = "steelblue"

        node.img_style['hz_line_width'] = 1
        node.img_style['vt_line_width'] = 1

    def ly_leaf_names(node):
        if node.is_leaf():
            spF = TextFace(node.species, fsize=10, fgcolor='#444444', fstyle='italic', ftype='Helvetica')
            add_face_to_node(spF, node, column=0, position='branch-right')
            if hasattr(node, 'genename'):
                geneF = TextFace(" (%s)" %node.genename, fsize=8, fgcolor='#777777', ftype='Helvetica')
                add_face_to_node(geneF, node, column=1, position='branch-right')

    def ly_supports(node):
        if not node.is_leaf() and node.up:
            supFace = TextFace("%0.2g" %(node.support), fsize=7, fgcolor='indianred')
            add_face_to_node(supFace, node, column=0, position='branch-top')

    def ly_tax_labels(node):
        if node.is_leaf():
            c = LABEL_START_COL
            largest = 0
            for tname in TRACKED_CLADES:
                if hasattr(node, "named_lineage") and tname in node.named_lineage:
                    linF = TextFace(tname, fsize=10, fgcolor='white')
                    linF.margin_left = 3
                    linF.margin_right = 2
                    linF.background.color = lin2color[tname]
                    add_face_to_node(linF, node, c, position='aligned')
                    c += 1

            for n in range(c, len(TRACKED_CLADES)):
                add_face_to_node(TextFace('', fsize=10, fgcolor='slategrey'), node, c, position='aligned')
                c+=1

    def ly_full_alg(node):
        pass

    def ly_block_alg(node):
        if node.is_leaf():
            if 'sequence' in node.features:
                seqFace = SeqMotifFace(node.sequence, [])
                # [10, 100, "[]", None, 10, "black", "rgradient:blue", "arial|8|white|domain Name"],
                motifs = []
                last_lt = None
                for c, lt in enumerate(node.sequence):
                    if lt != '-':
                        if last_lt is None:
                            last_lt = c
                        if c+1 == len(node.sequence):
                            start, end = last_lt, c
                            motifs.append([start, end, "()", 0, 12, "slategrey", "slategrey", None])
                            last_lt = None
                    elif lt == '-':
                        if last_lt is not None:
                            start, end = last_lt, c-1
                            motifs.append([start, end, "()", 0, 12, "grey", "slategrey", None])
                            last_lt = None

                seqFace = SeqMotifFace(node.sequence, motifs,
                                       intermotif_format="line",
                                       seqtail_format="line", scale_factor=ALG_SCALE)
                add_face_to_node(seqFace, node, ALG_START_COL, aligned=True)


    TRACKED_CLADES = ["Eukaryota", "Viridiplantae",  "Fungi",
                      "Alveolata", "Metazoa", "Stramenopiles", "Rhodophyta",
                      "Amoebozoa", "Crypthophyta", "Bacteria",
                      "Alphaproteobacteria", "Betaproteobacteria", "Cyanobacteria",
                      "Gammaproteobacteria",]

    # ["Opisthokonta",  "Apicomplexa"]

    colors = random_color(num=len(TRACKED_CLADES), s=0.45)
    lin2color = dict([(ln, colors[i]) for i, ln in enumerate(TRACKED_CLADES)])

    NAME_FACE = AttrFace('name', fsize=10, fgcolor='#444444')

    LABEL_START_COL = 10
#.........这里部分代码省略.........
开发者ID:Ward9250,项目名称:ete,代码行数:103,代码来源:visualize.py

示例4: Tree

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import scale [as 别名]
#figure IES loss
from __future__ import print_function
from ete3 import Tree, NodeStyle, TreeStyle
from pyies.userOptions import basePath
import os.path
import string

geneFamily = '4137'
analysis = '2'
phyldogResultsPath = "analysis/phyldogT" + analysis + "/results"
treeF = os.path.join(basePath, 'analysis', 'phyldogT' + analysis, 'results', geneFamily + ".ReconciledTree"
)
alnF = os.path.join(basePath, 'analysis', 'msas', 'filtered', 'cluster.' + geneFamily + '.nucl.fa')
t = Tree(treeF)
ts = TreeStyle()
ts.scale = 500
nstyle = NodeStyle()
nstyle["size"] = 0
for n in t.traverse():
   n.set_style(nstyle)

#seqs = SeqGroup(sequences = alnF, format = "fasta")

# for leaf in t:
#     geneId = leaf.name
#     seq = seqs.get_seq(geneId)
#     seq = seq.translate(None, string.ascii_lowercase) # keep only CDS
#     #iesmotif = [[1, len(seq), "line", 2, 5, None, None, None]]
#     #seqFace = SeqMotifFace(seq = seq, gap_format = "blank", seq_format = "line")
#     seqFace = SequenceFace(seq, seqtype = 'dna')
#     leaf.add_face(seqFace, 0, "aligned")
开发者ID:,项目名称:,代码行数:33,代码来源:

示例5: open

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import scale [as 别名]
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,代码行数:31,代码来源:wikitree.py

示例6: TreeStyle

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import scale [as 别名]
import random
from ete3 import Tree, TreeStyle, NodeStyle, faces, AttrFace, TreeFace

# Tree Style used to render small trees used as leaf faces
small_ts = TreeStyle()
small_ts.show_leaf_name = True
small_ts.scale = 10

def layout(node):
    if node.is_leaf():
        # Add node name to laef nodes
        N = AttrFace("name", fsize=14, fgcolor="black")
        faces.add_face_to_node(N, node, 0)

        t = Tree()
        t.populate(10)

        T = TreeFace(t, small_ts)
        # Let's make the sphere transparent
        T.opacity = 0.8
        # And place as a float face over the tree
        faces.add_face_to_node(T, node, 1, position="aligned")

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))
开发者ID:AlishaMechtley,项目名称:ete,代码行数:33,代码来源:tree_faces.py

示例7: TreeStyle

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import scale [as 别名]
        F = faces.TextFace(mynode.name,fsize=20)
        faces.add_face_to_node(F,mynode,0,position="aligned")

#Plot Pie Chart	
ts = TreeStyle()
ts.show_leaf_name = False

ts.layout_fn = phyparts_pie_layout
nstyle = NodeStyle()
nstyle["size"] = 0
for n in plot_tree.traverse():
	n.set_style(nstyle)
	n.img_style["vt_line_width"] = 0

ts.draw_guiding_lines = True
ts.guiding_lines_color = "black"
ts.guiding_lines_type = 0
ts.scale = 30
ts.branch_vertical_margin = 10
plot_tree.convert_to_ultrametric()
plot_tree.ladderize(direction=1)    
my_svg = plot_tree.render(args.svg_name,tree_style=ts,w=595,dpi=300)

if args.show_nodes:
	node_style = TreeStyle()
	node_style.show_leaf_name=False
	node_style.layout_fn = node_text_layout
	plot_tree.show(tree_style=node_style)

     
    
开发者ID:mossmatters,项目名称:MJPythonNotebooks,代码行数:30,代码来源:phypartspiecharts.py

示例8: ln

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import scale [as 别名]
# for key in prune_count.keys():
#     # node_weight = ln(prune_count[key])
#     # node_weight = ln(n_children)
#     # print(node_weight,n_children)
#     # node = lookup[key]
#     node.add_features(weight=random.randint(50))

for n in t.traverse():
    n.add_face(TextFace(n.name, fsize = 16), column=0, position="branch-bottom")
    # n.add_features(weight=random.randint(0,20))

t.prune(prune_list)
# Create an empty TreeStyle
ts = TreeStyle()
# Set our custom layout function
ts.layout_fn = layout
# Draw a tree
# ts.mode = "c"  # this makes it circular
# False need to add node names manually
ts.show_leaf_name = False
ts.scale = 120

# Show branch data
ts.show_branch_length = False
ts.show_branch_support = True


# print (t.get_ascii(show_internal=True))

t.show(tree_style=ts)
开发者ID:cancerconnector,项目名称:clonal-evolution,代码行数:32,代码来源:treebuilder.py

示例9: format

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import scale [as 别名]
def format( tree , genedict , detection , includenames , filename , speciescolors = None):
	print 'final output...'
	red = Color('red')
	blue = Color('blue')
	colorvec = list(red.range_to(blue, len(genedict.keys())))
	colormap = {}
	columnmap = {}
	for i,ref in enumerate(genedict):
		if ref not in detection:	
			columnmap[ref] = 3
			if 'hybrid' in ref.lower():
				columnmap[ref] = 0
			if 'eff' in ref.lower():
				columnmap[ref] = 1
			if 'hap' in ref.lower():
				columnmap[ref] = 2
			colormap[ref] = colorvec[i].hex
	for i,ref in enumerate(detection):
		columnmap[ref] = 3 + i
		colormap[ref] = colorvec[i].hex 

	print columnmap
	print colormap

	circledict = {}
	for n in t.traverse():
		
		nst = NodeStyle()
		nst["size"] = 0
		nst["fgcolor"] = 'black'
		nst["hz_line_width"] = 4
		nst["vt_line_width"]= 4
		nst.show_name = False
		if n.is_leaf():
			if speciescolors != None and n.name in speciescolors:
				nst["bgcolor"] = colors[n.name]
			nst.show_name = True			
			n.add_face( AttrFace(attr = 'name', ftype='Helvetica', fgcolor='black', fsize =18 ,fstyle = 'normal'   ), column =0 )
			refs = json.loads(n.refs)
			for ref in genedict:
				if ref in refs and ref in detection:
					n.add_face( CircleFace ( 10 , colormap[ref]), column =  2 + columnmap[ref] )
					n.img_style = nst
				if ref in refs and ref not in detection:
					n.add_face( RectFace ( 20 , 20 , colormap[ref], colormap[ref] ), column =  2 + columnmap[ref] )
					n.img_style = nst
				if ref not in refs and ref not in detection:
					n.add_face( RectFace ( 20 , 20 , colormap[ref], 'white' ), column =  2 + columnmap[ref] )
					n.img_style = nst
			###color by species
			if n.name in speciescolors:
				nst['bgcolor'] = speciescolors[n.name]
		else:
			if n.name.strip() in includenames:
				n.add_face( AttrFace(attr = 'name', ftype='Helvetica', fgcolor='black', fsize =20 ,fstyle = 'normal'   ), column =0 )
				nst.size = 2
				n.img_style = nst
			else:
				nst.size = 0
				n.img_style = nst 
	ts = TreeStyle()
	for i,ref in enumerate(colormap.keys()):
		if 'ubi' not in ref:
			ts.title.add_face(TextFace(ref, fsize=12), column=0)
			ts.title.add_face( RectFace(10 , 10 , colormap[ref] , colormap[ref]), column = 1)
	ts.show_leaf_name=False 

	"""ts.mode = "c"
				ts.arc_start = 270
				ts.arc_span = 359
				ts.root_opening_factor = 1
			"""
	ts.scale =  190
	
	t.show(tree_style = ts)
	t.render(filename + ".png", tree_style = ts)
	t.render( filename +".svg" , tree_style = ts)
开发者ID:cactuskid,项目名称:Taxonomy_scripts,代码行数:79,代码来源:detectiontree.py

示例10: get_example_tree

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import scale [as 别名]
def get_example_tree():
    t = Tree()
    t.populate(10)

    # Margins, alignment, border, background and opacity can now be set for any face
    rs1 = faces.TextFace("branch-right\nmargins&borders",
                         fsize=12, fgcolor="#009000")
    rs1.margin_top = 10
    rs1.margin_bottom = 50
    rs1.margin_left = 40
    rs1.margin_right = 40
    rs1.border.width = 1
    rs1.background.color = "lightgreen"
    rs1.inner_border.width = 0
    rs1.inner_border.line_style = 1
    rs1.inner_border.color= "red"
    rs1.opacity = 0.6
    rs1.hz_align = 2 # 0 left, 1 center, 2 right
    rs1.vt_align = 1 # 0 left, 1 center, 2 right

    br1 = faces.TextFace("branch-right1", fsize=12, fgcolor="#009000")
    br2 = faces.TextFace("branch-right3", fsize=12, fgcolor="#009000")

    # New face positions (branch-top and branch-bottom)
    bb = faces.TextFace("branch-bottom 1", fsize=8, fgcolor="#909000")
    bb2 = faces.TextFace("branch-bottom 2", fsize=8, fgcolor="#909000")
    bt = faces.TextFace("branch-top 1", fsize=6, fgcolor="#099000")

    # And faces can also be used as headers or foot notes of aligned
    # columns
    t1 = faces.TextFace("Header Face", fsize=12, fgcolor="#aa0000")
    t2 = faces.TextFace("Footer Face", fsize=12, fgcolor="#0000aa")

    # Attribute faces can now contain prefix and suffix fixed text
    aligned = faces.AttrFace("name", fsize=12, fgcolor="RoyalBlue",
                             text_prefix="Aligned (", text_suffix=")")
    # horizontal and vertical alignment per face
    aligned.hz_align = 1 # 0 left, 1 center, 2 right
    aligned.vt_align = 1

    # Node style handling is no longer limited to layout functions. You
    # can now create fixed node styles and use them many times, save them
    # or even add them to nodes before drawing (this allows to save and
    # reproduce an tree image design)
    style = NodeStyle()
    style["fgcolor"] = "Gold"
    style["shape"] = "square"
    style["size"] = 15
    style["vt_line_color"] = "#ff0000"
    t.set_style(style)
    # add a face to the style. This face will be render in any node
    # associated to the style.
    fixed = faces.TextFace("FIXED branch-right", fsize=11, fgcolor="blue")
    t.add_face(fixed, column=1, position="branch-right")
    # Bind the precomputed style to the root node

    # ETE 2.1 has now support for general image properties
    ts = TreeStyle()

    # You can add faces to the tree image (without any node
    # associated). They will be used as headers and foot notes of the
    # aligned columns (aligned faces)
    ts.aligned_header.add_face(t1, column = 0)
    ts.aligned_header.add_face(t1, 1)
    ts.aligned_header.add_face(t1, 2)
    ts.aligned_header.add_face(t1, 3)
    t1.hz_align = 1 # 0 left, 1 center, 2 right
    t1.border.width = 1

    ts.aligned_foot.add_face(t2, column = 0)
    ts.aligned_foot.add_face(t2, 1)
    ts.aligned_foot.add_face(t2, 2)
    ts.aligned_foot.add_face(t2, 3)
    t2.hz_align = 1

    # Set tree image style. Note that aligned header and foot is only
    # visible in "rect" mode.

    ts.mode =  "r"
    ts.scale = 10
    for node in t.traverse():
        # If node is a leaf, add the nodes name and a its scientific
        # name
        if node.is_leaf():
            node.add_face(aligned, column=0, position="aligned")
            node.add_face(aligned, column=1, position="aligned")
            node.add_face(aligned, column=3, position="aligned")
        else:
            node.add_face(bt, column=0, position="branch-top")
            node.add_face(bb, column=0, position="branch-bottom")
            node.add_face(bb2, column=0, position="branch-bottom")
            node.add_face(br1, column=0, position="branch-right")
            node.add_face(rs1, column=0, position="branch-right")
            node.add_face(br2, column=0, position="branch-right")

    return t, ts
开发者ID:AlishaMechtley,项目名称:ete,代码行数:98,代码来源:face_positions.py

示例11: showTree

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import scale [as 别名]
def showTree(delimitation, scale = 500, render = False, fout = "", form = "svg", show_support = False):
    """delimitation: species_setting class"""
    tree = delimitation.root
    style0 = NodeStyle()
    style0["fgcolor"] = "#000000"
    style0["vt_line_color"] = "#0000aa"
    style0["hz_line_color"] = "#0000aa"
    style0["vt_line_width"] = 2
    style0["hz_line_width"] = 2
    style0["vt_line_type"] = 0 
    style0["hz_line_type"] = 0
    style0["size"] = 0
    
    #tree.clear_face()
    tree._faces = _FaceAreas()
    for node in tree.get_descendants():
        node.set_style(style0)
        node.img_style["size"] = 0
        node._faces = _FaceAreas()
        #node.clear_face()
    
    tree.set_style(style0)
    tree.img_style["size"] = 0
    
    style1 = NodeStyle()
    style1["fgcolor"] = "#000000"
    style1["vt_line_color"] = "#ff0000"
    style1["hz_line_color"] = "#0000aa"
    style1["vt_line_width"] = 2
    style1["hz_line_width"] = 2
    style1["vt_line_type"] = 0 
    style1["hz_line_type"] = 0
    style1["size"] = 0
    
    style2 = NodeStyle()
    style2["fgcolor"] = "#0f0f0f"
    style2["vt_line_color"] = "#ff0000"
    style2["hz_line_color"] = "#ff0000"
    style2["vt_line_width"] = 2
    style2["hz_line_width"] = 2
    style2["vt_line_type"] = 0 
    style2["hz_line_type"] = 0
    style2["size"] = 0
    
    for node in delimitation.active_nodes:
        node.set_style(style1)
        node.img_style["size"] = 0
        for des in node.get_descendants():
            des.set_style(style2)
            des.img_style["size"] = 0
    
    for node in delimitation.root.traverse(strategy='preorder'):
        if show_support and hasattr(node, "bs"):
            if node.bs == 0.0:
                node.add_face(TextFace("0", fsize = 8), column=0, position = "branch-top")
            else:
                node.add_face(TextFace("{0:.2f}".format(node.bs), fsize = 8), column=0, position = "branch-top")
    
    ts = TreeStyle()
    """scale pixels per branch length unit"""
    ts.scale =  scale 
    ts.branch_vertical_margin = 7
    if render:
        tree.render(fout+"."+form, tree_style=ts)
    else:
        tree.show(tree_style=ts)
开发者ID:zhangjiajie,项目名称:PTP,代码行数:68,代码来源:ptpllh.py

示例12: NodeStyle

# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import scale [as 别名]
							for key in  speciescolors:
								genusSpecies = key.split()
								for name in genusSpecies:
									if name in lineage:
										nst['bgcolor'] = speciescolors[key]	
										break
					leaf.img_style = nst 

	nst = NodeStyle()
	nst["size"] = 0
	nst["fgcolor"] = 'black'
	nst["hz_line_width"] = 2
	nst["vt_line_width"]= 2
	for n in t.traverse():
		if n.is_leaf() == False:
			n.img_style = nst 

	ts = TreeStyle()
	for i,ref in enumerate(colormap.keys()):
		if 'ubi' not in ref and 'HH' not in ref and 'LOMETS' not in ref:
			ts.title.add_face(TextFace(ref, fsize=12), column=0)
			ts.title.add_face( RectFace(10 , 10 , colormap[ref] , colormap[ref]), column = 1)
	#ts.mode = "c"
	#ts.arc_start = -180 #0 degrees = 3 o'clock
	ts.scale =  150 
	ts.show_leaf_name = False
	ts.show_branch_support = True
	#t.show(tree_style = ts)
	outpng = treefile+'outnocolor.png'
	t.render(outpng , tree_style = ts)
开发者ID:cactuskid,项目名称:Taxonomy_scripts,代码行数:32,代码来源:format_tree.py


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