Library for the Development and Use of Phylogenetic Network Methods
Welcome to the PhyNetPy documentation. PhyNetPy is a comprehensive Python library for phylogenetic network analysis, providing tools for network construction, manipulation, simulation, and inference.
| Module | Description |
|---|---|
| Alphabet | Character-to-state mapping for biological sequence data (DNA, RNA, Protein, Codon, SNP). |
| BiMarkers | SNP (biallelic marker) likelihood computation for phylogenetic networks, with optional GPU acceleration. |
| BirthDeath | Birth-death process network simulators (Yule and CBDP models). |
| GTR | Time-reversible nucleotide substitution models (GTR, JC, K80, F81, HKY, K81, SYM, TN93). |
| GeneTrees | Gene tree container and analysis utilities including consensus tree construction and concordance factors. |
| GraphUtils | Network decomposition, distances, and structural edits: blobs, tree-of-blobs, cluster/mu/tripartition distances, reticulation-aware comparison, and ASCII rendering. |
| IO | Central I/O hub for reading and writing phylogenetic file formats (FASTA, VCF, Newick, Nexus). |
| MSA | Multiple Sequence Alignment parsing, storage, grouping, and distance computation. |
| Matrix | Data matrix storage and reduction for sequence alignments with unique site pattern compression. |
| MetropolisHastings | Hill-climbing and simulated-annealing search drivers, plus the ProposalKernel interface. |
| ModelGraph | The Model container pairing a network with its likelihood calculator, plus dirty-state tracking for incremental rescoring. |
| ModelMove | Network topology move operations for MCMC search (add/remove/flip reticulation, SPR). |
| ModelSelection | Information-criterion-based reticulation-count selection (AIC, BIC, AICc) and reticulation sweep helpers. |
| Network | Core phylogenetic network data structures: Node, Edge, Branch, and Network classes. |
| Newick | Newick format label extraction and Nexus file generation utilities. |
| PopulationGenetics | Validated population allele-count data and pulse-admixture graph semantics. |
| ReticulationComparison | Reticulation-aware network comparison: tripartition matching, Nakhleh metric, and precision/recall over reticulations. |
| SNPSimulator | SNP data simulator for phylogenetic networks using a forward-in-time 2-state CTMC. |
| State | State management for MCMC accept/reject decisions with model validation. |
| Validation | Comprehensive file format validation for phylogenetic data files (Newick, Nexus, FASTA, PHYLIP, etc.). |
| criteria | Axis 3 -- the statistical objective: MDC, Likelihood, PseudoLikelihood, and Bayesian, which wraps one of the likelihoods rather than sitting parallel to them. |
| data | Axis 1 -- what you observed: GeneTrees, Alignment, BiallelicMarkers. The input knows its own type, which is half of the dispatch key. |
| infer | The public inference API: the verbs infer, score, and simulate, the InferenceResult they return, plus the registry, scorers, kernels, result types, and MCMC diagnostics around them. |
| models | Axis 2 -- the generative biology: MSC (diploid, ILS only) and Allopolyploid (whole-genome duplication). |
pip install phynetpy
from phynetpy import read_newick
# Parse a network from a Newick string
network = read_newick("((A:0.1,B:0.2):0.3,C:0.4);")[0]
# Access network properties
print(f"Number of nodes: {len(network.V())}")
print(f"Number of edges: {len(network.E())}")
print(f"Leaves: {[leaf.label for leaf in network.get_leaves()]}")