splitp package
Subpackages
Submodules
splitp.constants module
Declare constants for the splitp package.
splitp.constructions module
- splitp.constructions.flattening(split, pattern_probabilities, flattening_format=FlatFormat.sparse)
Compute the flattening of a split given a pattern probability dictionary.
- Args:
split (str or list): The split to compute the flattening of. pattern_probabilities (dict): A dictionary of pattern probabilities. flattening_format (FlatFormat): The format to return the flattening in.
- Returns:
The flattening of the split in the specified format.
- splitp.constructions.subflattening(split, pattern_probabilities, data=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.
splitp.enums module
- class splitp.enums.DrawFormat(value)
Bases:
Enum
An enumeration.
- ASCII = 'ASCII'
- matplotlib = 'matplotlib'
- class splitp.enums.FlatFormat(value)
Bases:
Enum
An enumeration.
- reduced = 'reduced'
- sparse = 'sparse'
splitp.matrix module
- splitp.matrix.frobenius_norm(matrix, data_table=None)
Calculates the Frobenius Norm for a given matrix
- splitp.matrix.is_sparse(matrix)
splitp.model module
- class splitp.model.GTR(name='Generic GTR model', state_space=None, equilibrium_distribution=None, additional_parameters=None)
Bases:
model
A general time reversible model of evolution.
- classmethod JukesCantor(rate=1, state_space=('A', 'C', 'G', 'T'), name='Jukes-Cantor model')
A Jukes-Cantor model of evolution.
- classmethod Kimura(transversion_rate=1, transition_rate=1, state_space=('A', 'C', 'G', 'T'), name='Kimura model')
A Kimura model of evolution.
splitp.phylogenetics module
- splitp.phylogenetics.JC_corrected_distance_matrix(alignment)
- splitp.phylogenetics.distance_matrix(networkx_tree)
Distance matrix of a tree.
- Args:
networkx_tree (networkx.DiGraph): A tree.
- Returns:
numpy.ndarray: A distance matrix.
- splitp.phylogenetics.erickson_SVD(alignment, taxa=None, method=Method.flattening)
- splitp.phylogenetics.euclidean_split_distance(alignment, splits)
- splitp.phylogenetics.flattening_rank_1_approximation(flattening, return_vectors=False)
- splitp.phylogenetics.flattening_rank_1_approximation_divergence(flattening)
- splitp.phylogenetics.hartigan_algorithm(self, pattern)
- splitp.phylogenetics.join_nodes(T, i, j, new_node, root_index)
- splitp.phylogenetics.midpoint_rooting(networkx_tree, weight_label='weight')
Midpoint rooting of a tree.
- Args:
networkx_tree (networkx.DiGraph): A tree.
- Returns:
networkx.DiGraph: A rooted tree.
- splitp.phylogenetics.neighbour_joining(distance_matrix, labels=None, return_newick=False)
- splitp.phylogenetics.newick_string_from_splits(splits)
- splitp.phylogenetics.parsimony_score(self, 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
- splitp.phylogenetics.split_score(matrix, return_singular_values=False, force_frob_norm_on_dense=False, data_table_for_frob_norm=None)
- splitp.phylogenetics.split_tree_parsimony(alignment, splits=None)
- splitp.phylogenetics.star_tree(num_leaves)
- splitp.phylogenetics.tree_from_splits(splits)
splitp.phylogeny module
- class splitp.phylogeny.Phylogeny(newick_string, name=None)
Bases:
object
- draw(draw_format=DrawFormat.ASCII)
- format_split(split)
- get_descendants(n, return_iter=False)
Returns a list of children/descendents of a given node
- get_num_nodes()
- get_num_taxa()
- get_parent(n)
Returns the parent node for a given node
- get_taxa()
- is_leaf(n_index_or_name)
Determines whether a node is a leaf node from it’s index.
- is_root(node)
Determines whether a node is a root node from its index.
- name
- networkx_graph
- newick_string
- node_index(node)
- nodes()
Returns a list of all nodes in the tree.
- reassign_transition_matrices(transition_matrix)
DEPRECATED: Reassign transition matrices to all nodes in the tree
- root(return_index=True)
Returns the root node
- splits(include_trivial=False, as_strings=False)
Returns set of all splits displayed by the tree.
- unrooted_networkx_graph()
Return the unrooted version of the tree
splitp.simulation module
- splitp.simulation.draw_from_multinomial(pattern_probabilities, n)
Use a given table of probabilities from get_pattern_probabilities() and draw from its distribution
- splitp.simulation.evolve_pattern(tree, model=None)
- splitp.simulation.generate_alignment(tree, model, sequence_length)
- splitp.simulation.get_pattern_probabilities(tree, model=None)
Returns a full table of site-pattern probabilities (binary character set)
splitp.splits module
- splitp.splits.all_splits(tree, trivial=False, size=None, randomise=False, string_format=True)
- splitp.splits.format_split(tree, split)
- splitp.splits.shuffle(x)
Modify a sequence in-place by shuffling its contents.
This function only shuffles the array along the first axis of a multi-dimensional array. The order of sub-arrays is changed but their contents remains the same.
Note
New code should use the ~numpy.random.Generator.shuffle method of a ~numpy.random.Generator instance instead; please see the random-quick-start.
Parameters
- xndarray or MutableSequence
The array, list or mutable sequence to be shuffled.
Returns
None
See Also
random.Generator.shuffle: which should be used for new code.
Examples
>>> arr = np.arange(10) >>> np.random.shuffle(arr) >>> arr [1 7 5 2 9 4 3 6 0 8] # random
Multi-dimensional arrays are only shuffled along the first axis:
>>> arr = np.arange(9).reshape((3, 3)) >>> np.random.shuffle(arr) >>> arr array([[3, 4, 5], # random [6, 7, 8], [0, 1, 2]])
- splitp.splits.split_balance(s, asTuple=False)
Returns a string formatted ‘X|X’ which describes the balance of a given split string
splitp.squangles module
splitp.trees module
- splitp.trees.balanced_newick_tree(num_taxa)