Splits#

Working with Splits#

The phylozoo.core.split module provides the Split class, which represents a bipartition of a set of elements into two complementary subsets. Splits are fundamental to phylogenetic analysis, providing the mathematical foundation for representing evolutionary relationships in trees and networks. The split class inherits from the Partition class, which provides additional mathematical operations.

Creating Splits#

Splits can be created from any two complementary subsets:

from phylozoo.core.split import Split

# Create a split dividing taxa into two groups
split = Split({"A", "B"}, {"C", "D"})

# Create from different iterable types
split2 = Split(["A", "B"], ["C", "D"])

The constructor automatically converts inputs to frozensets and ensures the split is properly formed. It raises a PhyloZooValueError if the input is invalid.

Accessing Split Properties#

Splits provide access to their components:

# Access all elements in the split
elements = split.elements  # frozenset({"A", "B", "C", "D"})

# Access individual parts (inherited from Partition)
parts = split.parts        # tuple of frozensets
part1, part2 = split.parts # (frozenset({"A", "B"}), frozenset({"C", "D"}))

Split Operations#

Splits support fundamental phylogenetic operations.

Equality Checking

The == operator (which is inherited from Partition) checks whether two splits are equal. Two splits are equal if they have the same parts, regardless of the order of the parts.

# Check if two splits are equal
split1 = Split({"A", "B"}, {"C", "D"})
split2 = Split({"C", "D"}, {"A", "B"})
are_equal = split1 == split2  # True

Triviality Checking

The is_trivial() method checks whether a split is trivial, meaning one side contains only a single element.

# Check if split is trivial (one side has only one element)
trivial_split = Split({"A"}, {"B", "C", "D"})
is_trivial = trivial_split.is_trivial()  # True

normal_split = Split({"A", "B"}, {"C", "D"})
is_trivial = normal_split.is_trivial()  # False

Compatibility Analysis

The is_compatible() function checks whether two splits are compatible, meaning they can coexist in the same phylogenetic tree. Two splits are compatible if one side of each split is a subset of one side of the other split.

from phylozoo.core.split import is_compatible

# Check compatibility between splits
split1 = Split({"A", "B"}, {"C", "D"})
split2 = Split({"A"}, {"B", "C", "D"})
compatible = is_compatible(split1, split2)  # True

split3 = Split({"A", "C"}, {"B", "D"})
compatible = is_compatible(split1, split3)  # False (incompatible)

Subsplit Relationships

The is_subsplit() function checks whether one split is a subsplit of another. A split \(S_1\) is a subsplit of \(S_2\) if one of its sides is a subset of one side of the other split, and the other side of this split is a subset of the other side of the other split. For example, \(\{1, 2\} | \{5, 6\}\) is a subsplit of \(\{1, 2, 3\} | \{4, 5, 6\}\) because \(\{1, 2\} \subseteq \{1, 2, 3\}\) and \(\{5, 6\} \subseteq \{4, 5, 6\}\).

from phylozoo.core.split import is_subsplit

# Check subsplit relationships
split = Split({"1", "2", "6"}, {"3", "4", "5"})
subsplit = Split({"1", "2"}, {"4", "5"})

is_subsplit = is_subsplit(subsplit, split)  # True

The induced_quartetsplits() function returns a set of all subsplits of size 4 of the split.

from phylozoo.core.split import induced_quartetsplits

# Return all quartets splits
q_splits = induced_quartetsplits(split)

See Also#

  • API Reference - Complete function signatures and detailed examples

  • Split Systems - Collections of splits for phylogenetic analysis

  • Partitions - Base partition class

  • Quartets - Quartet-based phylogenetic representations