treeflow.tree.io module
- treeflow.tree.io.parse_newick(newick_file: str, remove_zero_edges: bool = True, epsilon: float = 1e-06, subnewick_format=0) NumpyRootedTree
Read a rooted TreeFlow Numpy tree from a Newick file
- Parameters:
newick_file (str) – File to read tree from
remove_zero_edges (bool) – Whether to expand zero-length edges (default: True)
epsilon (float) – Value to expand zero-length edges to (default: 1e-6)
subnewick_format (int) – Format passed to ete3.Tree (default: 0) (see documentation at http://etetoolkit.org/docs/latest/reference/reference_tree.html)
- Returns:
Parsed TreeFlow tree composed of Numpy arrays
- Return type:
- treeflow.tree.io.remove_zero_edges(tree: NumpyRootedTree, epsilon: float = 1e-06) NumpyRootedTree
- treeflow.tree.io.write_tensor_trees(topology_file: str, branch_lengths: Tensor, output_file: str, branch_metadata: Mapping[str, Tensor] | None = None)
Write a collection of Tensor tree branch lengths, and possibly branch metadata, to a Nexus file
- Parameters:
topology_file (str) – Newick file to read tree topology from
branch_lengths (Tensor) – Tensor of branch lengths with dimensions (num_samples, num_branches)
output_file (str) – File to write trees to in Nexus format
branch_metadata (Mapping[str, Tensor] (optional)) – Mapping from keys to Tensors with dimensions (num_samples, num_branches) containing branch metadata