ete
ete copied to clipboard
expected collapse branch to outline instead of traingle
I tried to design a layout that collapse target branch(taxonomic rank) to a outline instead of a traingle clade, unfortunately I wasn't able to do so. I wonder if I execute the correct parameters
example tree gtdb_annotated.nw.txt
example code
from ete4 import Tree
# from staple_layouts import LayoutBarplot
# from conditional_layouts import LayoutBinary
from ete4.smartview import TreeStyle, NodeStyle, TreeLayout
from ete4.smartview import RectFace, CircleFace, SeqMotifFace, TextFace, OutlineFace, LegendFace
TREEFILE = './gtdb_annotated.nw.txt'
popup_prop_keys = ['name', 'dist', 'support', 'rank', 'sci_name',
'taxid', 'lineage', 'named_lineage']
t = Tree(TREEFILE, format=1)
level = 2
def collapse_order():
def layout_fn(node):
color="green"
if not node.is_root() and node.props.get('rank') == 'order':
#face_name = TextFace(node.props.get('sci_name'), color=color)
face_name = OutlineFace(node.props.get('sci_name'), color=color, collapsing_height= float("inf"))
node.sm_style["draw_descendants"] = False
node.sm_style["outline_color"] = color
node.add_face(face_name, column = 8, position = 'aligned', collapsed_only=True)
layout_fn.name = "level4_order"
return layout_fn
return
layouts = [
TreeLayout(name='order', ns=collapse_order())
]
t.explore(tree_name='example',layouts=layouts, \
popup_prop_keys=popup_prop_keys)