TreeViz Class
pycirclizely.tree.TreeViz
TreeViz(
tree_data: str | Path | Tree,
*,
format: str = "newick",
outer: bool = True,
align_leaf_label: bool = True,
ignore_branch_length: bool = False,
leaf_label_size: float = 12,
leaf_label_rmargin: float = 2.0,
reverse: bool = False,
ladderize: bool = False,
line_kws: dict[str, Any] | None = None,
align_line_kws: dict[str, Any] | None = None,
label_formatter: TextFormatter = None,
track: Track
)
Phylogenetic Tree Visualization Class
Interface for changing tree properties and adding tree annotations in a track
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tree_data
|
str | Path | Tree
|
Tree data ( |
required |
format
|
str
|
Tree format ( |
'newick'
|
outer
|
bool
|
If True, plot tree on outer side. If False, plot tree on inner side. |
True
|
align_leaf_label
|
bool
|
If True, align leaf label. |
True
|
ignore_branch_length
|
bool
|
If True, ignore branch length for plotting tree. |
False
|
leaf_label_size
|
float
|
Leaf label size. |
12
|
leaf_label_rmargin
|
float
|
Leaf label radius margin. |
2.0
|
reverse
|
bool
|
If True, reverse tree. |
False
|
ladderize
|
bool
|
If True, ladderize tree. |
False
|
line_kws
|
dict[str, Any] | None
|
Shape properties. https://plotly.com/python/reference/layout/shapes/ |
None
|
align_line_kws
|
dict[str, Any] | None
|
Shape properties. https://plotly.com/python/reference/layout/shapes/ |
None
|
label_formatter
|
TextFormatter
|
User-defined label text format function to change label text content. |
None
|
track
|
Track
|
Track for tree visualization. |
required |
Methods:
Name | Description |
---|---|
get_target_xlim |
Args: |
highlight |
Args: |
load_tree |
Args: |
marker |
Args: |
search_target_node_name |
Args: |
set_node_label_props |
Args: |
set_node_line_props |
Args: |
show_node_info |
Show node information as hovertext. |
Attributes
max_tree_depth
cached
property
Max tree depth (root -> leaf max branch length)
name2xr
cached
property
Tree node name & node xr coordinate dict
Functions
get_target_xlim
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str | list[str] | tuple[str]
|
Search query node name(s) for getting x limit. If multiple node names are set, MRCA(Most Recent Common Ancestor) node is set. |
required |
highlight
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str | list[str] | tuple[str]
|
Search query node name(s) for highlight. If multiple node names are set, MRCA(Most Recent Common Ancestor) node is set. |
required |
**kwargs
|
Any
|
Shape properties
(e.g. |
{}
|
load_tree
staticmethod
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
str | Path | Tree
|
Tree data. |
required |
format
|
str
|
Tree format. |
required |
marker
marker(
query: str | list[str] | tuple[str],
*,
descendent: bool = True,
hover_text: list[str] | None = None,
**kwargs: Any
) -> None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str | list[str] | tuple[str]
|
Search query node name(s) for plotting marker. If multiple node names are set, MRCA(Most Recent Common Ancestor) node is set. |
required |
descendent
|
bool
|
If True, plot markers on target node's descendent as well. |
True
|
hover_text
|
list[str] | None
|
Custom hover text for each marker. If None, generates default phylogenetic info. |
None
|
**kwargs
|
Any
|
Scatter trace properties that override defaults. Common options include: - marker: dict with properties like size, color, symbol,.. - mode: 'markers', 'lines', 'markers+lines' - name: legend name for the trace |
{}
|
search_target_node_name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str | list[str] | tuple[str]
|
Search query node name(s). If multiple node names are set, MRCA(Most Recent Common Ancestor) node is set. |
required |
set_node_label_props
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_node_label
|
str
|
Target node label name. |
required |
**kwargs
|
Any
|
Annotation properties
(e.g. |
{}
|
set_node_line_props
set_node_line_props(
query: str | list[str] | tuple[str],
*,
descendent: bool = True,
apply_label_color: bool = False,
**kwargs: Any
) -> None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str | list[str] | tuple[str]
|
Search query node name(s) for coloring tree node line. If multiple node names are set, MRCA(Most Recent Common Ancestor) node is set. |
required |
descendent
|
bool
|
If True, set properties on target node's descendent as well. |
True
|
apply_label_color
|
bool
|
If True & |
False
|
**kwargs
|
Any
|
Shape properties
(e.g. |
{}
|
show_node_info
show_node_info(
*,
node_type: Literal["all", "internal", "leaf"] = "all",
hover_text_formatter: (
Callable[[list[dict]], list[str]] | None
) = None,
**kwargs: Any
) -> None
Show node information as hovertext.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node_type
|
Literal['all', 'internal', 'leaf']
|
Which nodes to show information for: - "all": All nodes - "internal": Only internal nodes (default) - "leaf": Only leaf nodes |
'all'
|
hover_text_formatter
|
Callable[[list[dict]], list[str]] | None
|
User-defined function for hover text format. |
None
|
**kwargs
|
Any
|
Scatter trace properties that override defaults. Note: The scatter points will be invisible by default (opacity=0). |
{}
|