本文整理汇总了Python中ete3.TreeStyle.show_scale方法的典型用法代码示例。如果您正苦于以下问题:Python TreeStyle.show_scale方法的具体用法?Python TreeStyle.show_scale怎么用?Python TreeStyle.show_scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ete3.TreeStyle
的用法示例。
在下文中一共展示了TreeStyle.show_scale方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: export_tree
# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import show_scale [as 别名]
def export_tree(tree, filename, insignif_color, signif_color, i_group, width):
'''
exports the given tree to the given filename
'''
ts = TreeStyle()
ts.show_leaf_name = False
ts.show_scale = False
ts.layout_fn = generate_layout(insignif_color, signif_color, i_group)
tree.render(filename, w=width, tree_style=ts)
示例2: _get_motif_tree
# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import show_scale [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
示例3: get_tree_style
# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import show_scale [as 别名]
def get_tree_style():
ts = TreeStyle()
# ts.mode = 'c'
ts.margin_top = 10
ts.margin_bottom = 10
ts.margin_left = 10
ts.margin_right = 10
ts.show_leaf_name = False
ts.show_branch_length = False
ts.show_branch_support = False
ts.show_scale = False
title = TextFace(" Tax Assignment Tree", fsize=10)
title.hz_align = 2
title.vt_align = 2
ts.title.add_face(TextFace(" "), column=0)
ts.title.add_face(TextFace(" "), column=0)
ts.title.add_face(title, column=0)
return ts
示例4: get_default_tree_style
# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import show_scale [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
示例5: PhyloTree
# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import show_scale [as 别名]
nw = '(0:0, 1:20);'
fa = """
>0
AA..
>1
CAA.
"""
t = PhyloTree(nw, alignment=fa, alg_format='fasta', format=1)
ts = TreeStyle()
ts.show_branch_length = False
ts.show_leaf_name = False
ts.draw_guiding_lines = True
ts.draw_aligned_faces_as_table = True
ts.show_scale = False
def my_layout(node):
#
# add names to all nodes (not just to leaf nodes)
# ete3/test/test_treeview/face_rotation.py
F = TextFace(node.name, tight_text=True)
add_face_to_node(F, node, column=0, position="branch-right")
#
# add branch lengths
# ete3/treeview/qt4_render.py
if not node.is_root():
bl_face = AttrFace("dist", fsize=8, ftype="Arial",
fgcolor="black", formatter="%0.3g")
#
# This is a failed attempt to center the branch length text on the branch.
示例6: heatmap_view
# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import show_scale [as 别名]
def heatmap_view(tree, orthologous_groups, save_dir):
"""Generates a heatmap of regulation states in all species."""
light_tree = copy.deepcopy(tree) # Tree copy for the light heatmap
# Heat map settings
rect_face_fgcolor = 'black'
locus_tag_len = max(len(gene.locus_tag) + 5
for ortho_grp in orthologous_groups
for gene in ortho_grp.genes)
rect_face_width = locus_tag_len * 8
light_rect_face_width = 20
rect_face_height = 20
rotation = 90
# Sort orthologous groups by the number of regulated genes in each group
orthologous_groups = filter_and_sort_orthologous_grps(orthologous_groups)
# For each species and its gene in each orthologous group, draw a rectangle
for node, light_node in zip(tree.get_leaves(), light_tree.get_leaves()):
for i, orthologous_grp in enumerate(orthologous_groups, start=1):
#get all orthologs in group
matching_genes = [g for g in orthologous_grp.genes \
if g.genome.strain_name == node.name]
#if there is ortholog
if len(matching_genes) > 0:
# Get the first ortholog from the genome in the group
#this is the one with higher probability of regulation.
#so this probability will be displayed for the group
gene = matching_genes[0]
p_regulation = gene.operon.regulation_probability
p_notregulation = 1.0 - p_regulation
p_absence = 0
# No ortholog from this genome
else:
gene = None
p_regulation = 0
p_notregulation = 0
p_absence = 1
# Color of the rectangle is based on probabilities
rect_face_bgcolor = rgb2hex(
p_notregulation, p_regulation, p_absence)
rect_face_text = ('%s [%d]' % (gene.locus_tag, gene.operon.operon_id)
if gene else '')
rect_face_label = {'text': rect_face_text,
'font': 'Courier',
'fontsize': 8,
'color': 'black'}
# Create the rectangle
rect_face = RectFace(rect_face_width, rect_face_height,
rect_face_fgcolor, rect_face_bgcolor,
label=rect_face_label)
light_rect_face = RectFace(light_rect_face_width, rect_face_height,
rect_face_fgcolor, rect_face_bgcolor,
label='')
rect_face.rotation = -rotation
light_rect_face.rotation = -rotation
# Add the rectangle to the corresponding column
node.add_face(rect_face, column=i, position='aligned')
light_node.add_face(light_rect_face, column=i, position='aligned')
ts = TreeStyle()
# Add orthologous group descriptions
descriptions = ['-'.join([grp.description, str(grp.NOGs)]) for grp in orthologous_groups]
max_description_len = max(map(len, descriptions))
descriptions = [
'[%d]' % i + description + ' '*(max_description_len-len(description))
for i, description in enumerate(descriptions, start=1)]
for i, description in enumerate(descriptions, start=1):
text_face = TextFace(description, ftype='Courier')
text_face.hz_align = 1
text_face.vt_align = 1
text_face.rotation = -rotation
ts.aligned_header.add_face(text_face, column=i)
# Rotate the generated heatmap.
ts.margin_left = 10
ts.margin_top = 20
ts.rotation = rotation
ts.show_scale = False
# For some reason, it can't render to PDF in color
tree.render(os.path.join(save_dir, 'heatmap.svg'), tree_style=ts)
light_tree.render(os.path.join(save_dir, 'heatmap_light.svg'), tree_style=ts)
示例7: Tree
# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import show_scale [as 别名]
from ete3 import Tree,TreeStyle,TextFace
t = Tree('tagfrog.phy')
for node in t.traverse():
node.img_style['size'] = 3
if node.is_leaf():
name_face = TextFace(node.name)
ts = TreeStyle()
ts.show_scale = True
t.render('tagfrog.pdf')