splitp package¶
Submodules¶
splitp.nx_tree module¶
-
class
splitp.nx_tree.
NXTree
(newickString, name=None, numStates=4, taxa_ordering=None)¶ Bases:
object
A rooted phylogenetic tree.
A rooted phylogenetic tree consisting of a collection of node objects and an adjacency matrix
- Attributes:
num_nodes: The number of nodes in the tree num_bases: The size of the character set for the phylogeny nodes: A list of node objects representing the nodes in the tree adjM: An adjacency matrix describing the connections within the tree initDist: The initial distribution of states/characters at the root of the tree.
-
add_node
(n, branch_length=0, in_node=None)¶ Adds a new node to the tree
- Args:
n: The node object to add into the tree. in_node: The name of the parent node, default is None and is used for the root.
-
adjacency_matrix
()¶
-
all_singular_values
(M)¶
-
all_splits
(trivial=False, only_balance=None, randomise=False)¶
-
build_JC_matrix
(l)¶
-
build_K2ST_matrix
(transition, transversion)¶
-
draw_from_multinomial
(LT, n)¶ Use a given table of probabilities from getLikelihoods() and draw from its distribution
-
evolve_pattern
()¶
-
false_splits
(only_balance=None, randomise=False)¶
-
fast_signed_sum_subflattening
(split, data_dict, bundle=None, labels=None)¶ A faster version of signed sum subflattening. Requires a data dictionary and can be supplied with a bundle of re-usable information to reduce the number of calls to the multiplications function.
-
fast_sparse_flattening
(split, table, format='dok')¶ A faster version of signed sum subflattening. Requires a data dictionary and can be supplied with a bundle of re-usable information to reduce the number of calls to the multiplications function.
-
flattening
(split, table)¶ Build a flattening matrix from a split
- Args:
split: A string representing the split to build the flattening from table: A pandas data-frame table with site pattern `probabilities’
- Returns:
A flattening matrix as a data-frame (to provide labels)
-
generate_alignment
(sequence_length)¶
-
get_descendants
(n, return_iter=False)¶ Returns a list of children/descendents of a given node
-
get_num_taxa
()¶ Returns the number of taxa/leaf-nodes in the tree
-
get_parent
(n)¶ Returns the parent node for a given node
-
get_pattern_probabilities
()¶ Returns a full table of site-pattern probabilities (binary character set)
-
get_root
(return_index=True)¶ Returns the root node
-
hartigan_algorithm
(pattern)¶
-
index_of_node
(node_name)¶
-
is_leaf
(n_index_or_name)¶ Determines whether a node is a leaf node from it’s index.
-
is_root
(n_index_or_name)¶ Determines whether a node is a root node from it’s index.
-
node_index
(n)¶
-
node_name
(index)¶
-
nodes
()¶
-
nodes_list
()¶
-
num_nodes
()¶
-
parsimony_score
(pattern)¶ Calculate a parsimony score for a site pattern or split
- Args:
pattern: A string representing a site pattern or split
- Returns:
A parsimony score for the given split or site pattern
-
rate_matrix
(model)¶
-
reassign_all_transition_matrices
(matrix)¶
-
scale_TR_rate_matrix
(Q, return_scale_factor=False)¶
-
signed_sum_subflattening
(split, data_table)¶
-
sparse_flattening
(split, table, format='dok')¶
-
sparse_subflattening
(split, data_table, as_dense_array=False)¶
-
split_score
(matrix, return_singular_values=False, force_frob_norm_on_dense=False, data_table_for_frob_norm=None)¶
-
subflattening
(Ft, specialState='T', type=(1, 1))¶ Creates a subflattening from a transformed flattening data frame
-
subflattening_alt
(F, S=None, returnLRMats=False)¶
-
svd_error
(M)¶ “Returns the SVD for a given matrix (All but two/four largest SVs)
-
transformed_flattening
(F, S=None)¶ Creates a transformed flattening from a flattening data frame
-
true_splits
(include_trivial=False)¶ Returns set of all true splits in the tree.
splitp.parsers module¶
-
splitp.parsers.
json_to_newick
(json_dict, namestring='id', lengthstring='branch_length', childrenstring='children')¶
-
splitp.parsers.
newick_to_json
(newick_string, namestring='id', lengthstring='branch_length', childrenstring='children', generate_names=False)¶ Parses a newick string (example “((A,B),C)”) into JSON format accepted by NetworkX
- Args:
- newick_string: The newick string to convert to JSON. Names, branch lengths and named
internal nodes accepted. If no names are given, an ID is generated for the name if generate_names=True.
namestring: The label for node name to use in the JSON (default “id”). lengthstring: The label for branch length to use in the JSON (default “branch_length”). childrenstring: The label for children arrays to use in the JSON (default “children”). generate_names: Whether or not to generate names if none are given
splitp.squangles module¶
splitp.tree_helper_functions module¶
-
splitp.tree_helper_functions.
all_splits
(num_taxa, trivial=False, only_balance=None, randomise=False)¶ Generates all splits as string-representations
- Args:
num_taxa: The number of taxa on the tree. trivial: Whether or not to calculate trivial splits, default True. only_trivial: Whether to ONLY create trivial splits, default False.
- Returns:
A list of string-representations of splits (using ‘|’-notation)
-
splitp.tree_helper_functions.
balanced_newick_tree
(num_taxa)¶
-
splitp.tree_helper_functions.
check_splits_representatives
(split_reps, orbits)¶
-
splitp.tree_helper_functions.
frob_norm
(matrix, data_table=None)¶ Calculates the Frobenius Norm for a given matrix
-
splitp.tree_helper_functions.
get_balance
(s, asTuple=False)¶ Returns a string formatted ‘X|X’ which describes the balance of a given split string
-
splitp.tree_helper_functions.
get_pattern_counts
(alignment, asNumpyArray=False)¶
-
splitp.tree_helper_functions.
is_sparse
(matrix)¶
-
splitp.tree_helper_functions.
make_substitution_matrix
(subs_prob, k)¶
-
splitp.tree_helper_functions.
normalised
(scores)¶
-
splitp.tree_helper_functions.
pattern_counts_to_probs
(patterns, seqLen)¶
-
splitp.tree_helper_functions.
pattern_probs_from_alignment
(pathToFile, check=True)¶
-
splitp.tree_helper_functions.
read_alignment_from_file
(pathToFile, check=True)¶
-
splitp.tree_helper_functions.
scaled_h_matrix
(_lambda)¶
-
splitp.tree_helper_functions.
scores_to_weights
(scores)¶
-
splitp.tree_helper_functions.
split_equivalence_classes
(splits, group)¶ Breaks up list of splits into equivalence classes under the canonical action of the specified group.