Skip to content

API

  • Analyze provides analysis tools of tree samples and inference runs.
  • Distances provides tree-tree distance and similarity measures.
  • Interface provides dataclasses for processing MCMC data.
  • Serialize contains utilities for serialization and deserialization of trees, MCMC rus and analysis.
  • Tree Inference implements the mutation tree infernce; scDNA mutation profiles synthesis.
  • Visualize implements visualization of trees and MCMC runs and diagostics theirof.

This package handels trees with Anytree, see our adaption in the class TreeNode below. For the inference we convert trees to binary adjacency matrices see Tree Inference, for reasons of performance.

pyggdrasil.TreeNode

Bases: Generic[NameType, DataType], NodeMixin

Tree node compatible with AnyTree. It can be annotated with the label type and the data type.

Attrs

name: identifier of the node (compatible with declared type) data: payload data parent: the node of the parent children: iterable with the children nodes

__init__(name, data=None, parent=None, children=None)

Parameters:

Name Type Description Default
name NameType

identifier of the node (compatible with declared type)

required
data DataType

payload data

None
parent Optional[TreeNode]

the node of the parent

None
children Optional[Iterable[TreeNode]]

iterable with the children nodes

None

__str__()

Casts to str.

convert_anytree_to_treenode(node) staticmethod

Converts an AnyTree node to a TreeNode.

Ignores the data attribute TreeNode nodes.

Parameters:

Name Type Description Default
node Node

AnyTree node to be converted

required

Returns: TreeNode with the same topology as the AnyTree node

convert_to_anytree_node(tree_node) staticmethod

Converts a TreeNode to an AnyTree node.

print_topo()

Prints the topology of the tree.

pyggdrasil.compare_trees(tree1, tree2)

Compares two labeled rooted trees.

Returns:

Type Description
bool

True iff the two labeled rooted trees have the same structure

Note

Assumes that labels in each tree is unique Pyright may throw a false positive error when passing a TreeNode