Quickstart#

Get started with PhyloZoo in minutes! This guide walks you through installation, creating networks, and working with related data types, at every step referring to the corresponding section in the manual.

Getting Started#

Install PhyloZoo using pip. For most users (including visualization), use:

pip install phylozoo[viz]

For a minimal install without plotting, use pip install phylozoo. See the Installation Guide for full details.

Networks#

Let’s create a simple phylogenetic network:

from phylozoo import DirectedPhyNetwork

# Create a simple tree network
network = DirectedPhyNetwork(
    edges=[("root", "A"), ("root", "B"), ("root", "C")],
    nodes=[
        ("A", {"label": "A"}),
        ("B", {"label": "B"}),
        ("C", {"label": "C"})
    ]
)

print(f"Network has {network.num_nodes} nodes")
print(f"Leaves: {network.leaves}")
print(f"Is tree: {network.is_tree()}")

This creates a simple tree with three leaves.

Now let’s create a network with a hybrid node. Hybrid edges use a gamma value (must sum to 1.0 for edges into the same hybrid):

# Create a network with hybridization
hybrid_net = DirectedPhyNetwork(
    edges=[
        ("root", "u1"), ("root", "u2"),  # Root to tree nodes
        ("u1", "h", {"gamma": 0.6}),    # Hybrid edge
        ("u2", "h", {"gamma": 0.4}),     # Hybrid edge (must sum to 1.0)
        ("h", "leaf1")                   # Hybrid to leaf
    ],
    nodes=[("leaf1", {"label": "A"})]
)

print(f"Network level: {hybrid_net.level()}")

PhyloZoo also supports semi-directed networks, which allow undirected tree edges for modeling root uncertainty. See Semi-Directed Networks for details.

Load and Save#

Networks can be saved and loaded in standard formats:

# Save network to file (eNewick format)
network.save("my_network.enewick")

# Load network from file
loaded_net = DirectedPhyNetwork.load("my_network.enewick")

Supported formats include eNewick, NEXUS, and DOT. See the I/O overview for all formats.

Visualization#

Plot networks with the built-in visualization module:

from phylozoo.viz import plot

# Plot network (opens interactive window)
plot(network, show=True)

# Save to file instead
plot(network, path="network.png")

For layout options and styling, see Visualization.

Next Steps#

Ready to dive deeper? Check out:

  1. The Manual for comprehensive guides on all modules

  2. The API Reference for complete function signatures and examples