API Reference

Contents

API Reference#

Base#

from_ancestry

Convert an "ancestry matrix" to a vector

from_edges

Convert a list of edges to a Phylo2Vec vector

from_newick

Convert a Newick string to a Phylo2Vec vector or matrix

from_pairs

Convert a list of pairs to a Phylo2Vec vector

to_ancestry

Convert a Phylo2Vec vector to an ancestry matrix

to_edges

Convert a Phylo2Vec vector to an edge list

to_newick

Convert a Phylo2Vec vector or matrix to Newick format

to_pairs

Convert a Phylo2Vec vector to a list of pairs

IO#

load

Read a text/csv file into a Phylo2Vec vector or matrix.

load_newick

Read a Newick string/file into a Phylo2Vec vector or matrix.

save

Save a Phylo2Vec vector or matrix to a file.

save_newick

Save a Phylo2Vec vector or matrix to Newick format into a file.

Statistics#

stats.cophenetic_distances

Compute the cophenetic distance matrix of a Phylo2Vec vector (topological) or matrix (from branch lengths).

stats.cov

Compute the covariance matrix of a Phylo2Vec vector or matrix.

stats.incidence

Compute the incidence matrix of a Phylo2Vec vector.

stats.pairwise_distances

Compute a pairwise distance matrix for tree nodes from a Phylo2Vec vector.

stats.precision

Compute the precision matrix of a Phylo2Vec vector or matrix.

stats.robinson_foulds

Compute the Robinson-Foulds distance between two trees.

Utils#

sample_matrix

Sample a random tree with branch lengths via Phylo2Vec, in matrix form.

sample_vector

Sample a random tree via Phylo2Vec, in vector form.

utils.matrix.check_matrix

Input validation of a Phylo2Vec matrix

utils.newick.apply_label_mapping

Apply an integer-taxon label mapping (label_mapping) from a string-based newick (where leaves are strings) and produce a mapped integer-based newick (where leaves are integers)

utils.newick.create_label_mapping

Create an integer-taxon label mapping (label_mapping) from a string-based newick (where leaves are strings) and produce a mapped integer-based newick (where leaves are integers) this also remove annotations pertaining to parent nodes

utils.newick.find_num_leaves

Calculate the number of leaves in a tree from its Newick

utils.newick.remove_branch_lengths

Remove branch lengths annotations from a Newick string

utils.newick.remove_parent_labels

Remove parent labels from the Newick string

utils.vector.add_leaf

Add a leaf to a Phylo2Vec vector v

utils.vector.check_vector

Input validation of a Phylo2Vec vector

utils.vector.get_common_ancestor

Get the most recent common ancestor between two nodes in a Phylo2Vec tree.

utils.vector.get_node_depth

Get the depth of a node in a Phylo2Vec tree.

utils.vector.get_node_depths

Get the depths of all nodes in a Phylo2Vec tree.

utils.vector.queue_shuffle

Produce an ordered version (i.e., birth-death process version) of a Phylo2Vec vector using the Queue Shuffle algorithm.

utils.vector.remove_leaf

Remove a leaf from a Phylo2Vec v

utils.vector.reroot

Reroot a tree in phylo2vec format at a given node

utils.vector.reroot_at_random

Reroot a tree in phylo2vec format at a random node