TreeViz Class
TreeViz
TreeViz(
tree_data: str | Path | Tree,
*,
format: str = "newick",
height: float = 0.5,
width: float = 8,
orientation: str = "right",
align_leaf_label: bool = False,
ignore_branch_length: bool = False,
leaf_label_size: float = 12,
innode_label_size: float = 0,
show_auto_innode_label: bool = True,
leaf_label_xmargin_ratio: float = 0.01,
innode_label_xmargin_ratio: float = 0.01,
reverse: bool = False
)
Phylogenetic Tree Visualization Class
PARAMETER | DESCRIPTION |
---|---|
tree_data |
Tree data (
TYPE:
|
format |
Tree format (
TYPE:
|
height |
Figure height per leaf node of tree
TYPE:
|
width |
Figure width
TYPE:
|
orientation |
Tree orientation (
TYPE:
|
align_leaf_label |
If True, align leaf label.
TYPE:
|
ignore_branch_length |
If True, Ignore branch length for plotting tree.
TYPE:
|
leaf_label_size |
Leaf label size
TYPE:
|
innode_label_size |
Internal node label size
TYPE:
|
show_auto_innode_label |
If True, show auto defined internal node label
(e.g.
TYPE:
|
leaf_label_xmargin_ratio |
Leaf label x margin ratio
TYPE:
|
innode_label_xmargin_ratio |
Internal node label x margin ratio
TYPE:
|
reverse |
Plot tree in reverse order
TYPE:
|
max_tree_depth
cached
property
Max tree depth (root -> leaf max branch length)
name2xy
cached
property
Tree node name & node xy coordinate dict (alias for name2xy_right
)
name2xy_right
cached
property
Tree node name & node right xy coordinate dict
name2xy_center
cached
property
Tree node name & node center xy coordinate dict
name2xy_left
cached
property
Tree node name & node left xy coordinate dict
show_branch_length
show_branch_length(
*,
size: int = 8,
xpos: str = "center",
ypos: str = "top",
xmargin_ratio: float = 0.01,
ymargin_ratio: float = 0.05,
label_formatter: Callable[[float], str] | None = None,
**kwargs
) -> None
Show branch length text label on each branch
PARAMETER | DESCRIPTION |
---|---|
size |
Text size
TYPE:
|
xpos |
X position of plot text (
TYPE:
|
ypos |
Y position of plot text (
TYPE:
|
xmargin_ratio |
Text x margin ratio. If
TYPE:
|
ymargin_ratio |
Text y margin ratio. If
TYPE:
|
label_formatter |
User-defined branch length value label format function
(e.g.
TYPE:
|
**kwargs |
Text properties (e.g.
TYPE:
|
show_confidence
show_confidence(
*,
size: int = 8,
xpos: str = "center",
ypos: str = "bottom",
xmargin_ratio: float = 0.01,
ymargin_ratio: float = 0.05,
label_formatter: Callable[[float], str] | None = None,
**kwargs
) -> None
Show confidence text label on each branch
PARAMETER | DESCRIPTION |
---|---|
size |
Text size
TYPE:
|
xpos |
X position of plot text (
TYPE:
|
ypos |
Y position of plot text (
TYPE:
|
xmargin_ratio |
Text x margin ratio. If
TYPE:
|
ymargin_ratio |
Text y margin ratio. If
TYPE:
|
label_formatter |
User-defined confidence value label format function
(e.g.
TYPE:
|
**kwargs |
Text properties (e.g.
TYPE:
|
show_scale_axis
Show scale axis
PARAMETER | DESCRIPTION |
---|---|
ticks_interval |
Ticks interval. If None, interval is automatically defined.
TYPE:
|
ypos |
Y position of axis.
TYPE:
|
show_scale_bar
show_scale_bar(
*,
scale_size: float | None = None,
text_size: float = 8,
loc: str = "lower left",
label_top: bool = False
) -> None
Show scale bar
PARAMETER | DESCRIPTION |
---|---|
scale_size |
Scale size. If None, size is automatically defined.
TYPE:
|
text_size |
Text label size
TYPE:
|
loc |
Bar location (e.g.
TYPE:
|
label_top |
If True, plot label on top. If False, plot label on bottom.
TYPE:
|
highlight
highlight(
query: str | list[str] | tuple[str],
color: str,
*,
alpha: float = 0.5,
area: str = "branch-label",
**kwargs
) -> None
Plot highlight for target node
PARAMETER | DESCRIPTION |
---|---|
query |
Search query node name(s) for highlight. If multiple node names are set, MRCA(Most Recent Common Ancester) node is set.
TYPE:
|
color |
Highlight color
TYPE:
|
alpha |
Highlight color alpha(transparancy) value
TYPE:
|
area |
Highlight area (
TYPE:
|
**kwargs |
Rectangle properties (e.g.
TYPE:
|
annotate
annotate(
query: str | list[str] | tuple[str],
label: str,
*,
text_size: float = 10,
text_color: str = "black",
text_orientation: str = "horizontal",
line_color: str = "black",
xmargin_ratio: float = 0.01,
align: bool = False,
text_kws: dict[str, Any] | None = None,
line_kws: dict[str, Any] | None = None
) -> None
Annotate tree clade with line & text label
PARAMETER | DESCRIPTION |
---|---|
query |
Search query node name(s) for annotate. If multiple node names are set, MRCA(Most Recent Common Ancester) node is set.
TYPE:
|
label |
Label name
TYPE:
|
text_size |
Text size
TYPE:
|
text_color |
Text color
TYPE:
|
text_orientation |
Text orientation (
TYPE:
|
line_color |
Line color
TYPE:
|
xmargin_ratio |
X margin ratio
TYPE:
|
align |
If True, annotate position is aligned to rightmost edge.
TYPE:
|
text_kws |
TYPE:
|
line_kws |
Axes.plot properties (e.g. dict(lw=2.0, ls="dashed", ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.plot.html
TYPE:
|
marker
marker(
query: str | list[str] | tuple[str],
marker: str = "o",
*,
size: int = 6,
descendent: bool = False,
**kwargs
) -> None
Plot marker on target node(s)
PARAMETER | DESCRIPTION |
---|---|
query |
Search query node name(s) for plotting marker. If multiple node names are set, MRCA(Most Recent Common Ancester) node is set.
TYPE:
|
marker |
Marker type (e.g.
TYPE:
|
size |
Marker size
TYPE:
|
descendent |
If True, plot markers on target node's descendent as well.
TYPE:
|
**kwargs |
Axes.scatter properties (e.g.
TYPE:
|
link
link(
query1: str | list[str] | tuple[str],
query2: str | list[str] | tuple[str],
*,
pos1: str = "center",
pos2: str = "center",
color: str = "red",
linestyle: str = "dashed",
arrowstyle: str = "-|>",
connectionstyle: str = "arc3,rad=0",
**kwargs
) -> None
Plot link line between target nodes
PARAMETER | DESCRIPTION |
---|---|
query1 |
Search query node name(s) for setting link start node. If multiple node names are set, MRCA(Most Recent Common Ancester) node is set.
TYPE:
|
query2 |
Search query node name(s) for setting link end node. If multiple node names are set, MRCA(Most Recent Common Ancester) node is set.
TYPE:
|
pos1 |
Link start node branch position1 (
TYPE:
|
pos2 |
Link end node branch position2 (
TYPE:
|
color |
Link line color
TYPE:
|
linestyle |
Line line style (e.g.
TYPE:
|
arrowstyle |
Arrow style (e.g.
TYPE:
|
connectionstyle |
Connection style (e.g.
TYPE:
|
**kwargs |
PathPatch properties (e.g.
TYPE:
|
text_on_branch
text_on_branch(
query: str | list[str] | tuple[str],
text: str,
*,
size: int = 8,
xpos: str = "right",
ypos: str = "top",
xmargin_ratio: float = 0.01,
ymargin_ratio: float = 0.05,
**kwargs
) -> None
Plot text on branch of target node
PARAMETER | DESCRIPTION |
---|---|
query |
Search query node name(s) for plotting text. If multiple node names are set, MRCA(Most Recent Common Ancester) node is set.
TYPE:
|
text |
Text content
TYPE:
|
size |
Text size
TYPE:
|
xpos |
X position of plot text (
TYPE:
|
ypos |
Y position of plot text (
TYPE:
|
xmargin_ratio |
Text x margin ratio. If
TYPE:
|
ymargin_ratio |
Text y margin ratio. If
TYPE:
|
**kwargs |
Text properties (e.g.
TYPE:
|
text_on_node
Plot text on target node
PARAMETER | DESCRIPTION |
---|---|
query |
Search query node name(s) for plotting text. If multiple node names are set, MRCA(Most Recent Common Ancester) node is set.
TYPE:
|
text |
Text content
TYPE:
|
size |
Text size
TYPE:
|
**kwargs |
Text properties (e.g.
TYPE:
|
set_node_label_props
Set tree node label properties
PARAMETER | DESCRIPTION |
---|---|
target_node_label |
Target node label name
TYPE:
|
kwargs |
Text properties (e.g.
TYPE:
|
set_node_line_props
set_node_line_props(
query: str | list[str] | tuple[str], *, descendent: bool = True, **kwargs
) -> None
Set tree node line properties
PARAMETER | DESCRIPTION |
---|---|
query |
Search query node name(s) for coloring tree node line. If multiple node names are set, MRCA(Most Recent Common Ancester) node is set.
TYPE:
|
descendent |
If True, set properties on target node's descendent as well.
TYPE:
|
**kwargs |
Axes.plot properties (e.g.
TYPE:
|
set_title
Set title
PARAMETER | DESCRIPTION |
---|---|
label |
Title text label
TYPE:
|
**kwargs |
Axes.set_title properties (e.g.
TYPE:
|
update_plot_props
update_plot_props(
*,
tree_line_kws: dict[str, Any] | None = None,
tree_align_line_kws: dict[str, Any] | None = None
) -> None
Update plot properties
PARAMETER | DESCRIPTION |
---|---|
tree_line_kws |
Axes.plot properties (e.g.
TYPE:
|
tree_align_line_kws |
Axes.plot properties (e.g.
TYPE:
|
plotfig
Plot figure
PARAMETER | DESCRIPTION |
---|---|
dpi |
Figure DPI
TYPE:
|
ax |
Matplotlib axes for plotting. If None, figure & axes are newly created.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
figure
|
Matplotlib figure
TYPE:
|
savefig
Save figure to file
tv.savefig("result.png")
is alias for
tv.plotfig().savefig("result.png")
PARAMETER | DESCRIPTION |
---|---|
savefile |
Save file (
TYPE:
|
dpi |
DPI
TYPE:
|
pad_inches |
Padding inches
TYPE:
|