You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code is supposed to visualize a minimalistic tree next to a sequence alignment, with the tree leaves displayed as aligned. Especially note the setting ts.show_leaf_name=False
from ete3 import PhyloTree, TreeStyle, TextFace
tre = "(A:3,(B:1,C:6));"
aln = """
>A
ATGC
>B
GCAT
>C
AGCT
"""
t = PhyloTree(tre, alignment=aln, alg_format="fasta")
for l in t.iter_leaves():
l.add_face(TextFace(l.name), 0, position='aligned')
ts = TreeStyle()
ts.show_leaf_name=False
ts.draw_guiding_lines=True
t.show(tree_style=ts)
However, the above code displays both the original leaf names as well as the new (i.e., aligned) ones.
I wish to display only the new (i.e., aligned) leaf names. What part of the above code is incorrect?
The text was updated successfully, but these errors were encountered:
why cant i use "def layout(node):" node and leaves have some different definition?
leaf and node both are not working. please see the code attached
from ete3 import PhyloTree, faces, AttrFace, TreeStyle, NodeStyle
tre = "(A:3,(B:1,C:6));"
aln = """
A
ATGC
B
GCAT
C
AGCT
"""
t = PhyloTree(tre, alignment=aln, alg_format="fasta")
t = PhyloTree(tre, alignment=aln, alg_format="fasta")
positions_to_color = [2,3]
def layout(leaf):
sequence = leaf.name # Access the sequence directly from the leaf name
print("Processing leaf:", leaf.name) # Print the leaf name being processed
# Color specified positions
for position in positions_to_color:
aa = sequence[position - 1] # Access the character at the position
print(f" - Coloring position {position} with amino acid: {aa}") # Print position and amino acid
color = faces._aabgcolors.get(aa, "#FFFFFF")
Hi, Michael!
Never got this problem using ete3, but recently I switched to ete4, rewrote the code for the particular tree I used to render with ete3 and got same issue as you.
What solved it for me was changing the default value of TreeStyle.show_leaf_name to False:
Though, if I want the names to be shown, I just add ts.show_leaf_name = True in my code and it works perfect.
I believe you may find similar lines in ete3 code and do the same.
Good luck!
The following code is supposed to visualize a minimalistic tree next to a sequence alignment, with the tree leaves displayed as aligned. Especially note the setting
ts.show_leaf_name=False
However, the above code displays both the original leaf names as well as the new (i.e., aligned) ones.
I wish to display only the new (i.e., aligned) leaf names. What part of the above code is incorrect?
The text was updated successfully, but these errors were encountered: