Skip to content

iqtree/piqtree

Repository files navigation

piqtree

PyPI Version Python Version License

CI Coverage Status Documentation Status Ruff

piqtree is a library which allows you use IQ-TREE directly from Python! The interface with python is through cogent3 objects. For usage, please refer to the documentation or the examples below.

If you encounter any problems or have any feature requests feel free to raise an issue!

Contributing

If you would like to help out by contributing to the piqtree project, please check out our contributor guide!

Examples

Phylogenetic Reconstruction

from piqtree import build_tree
from cogent3 import load_aligned_seqs # Included with piqtree!

# Load Sequences
aln = load_aligned_seqs("tests/data/example.fasta", moltype="dna")
aln = aln.take_seqs(["Human", "Chimpanzee", "Rhesus", "Mouse"])

# Reconstruct a phylogenetic tree with IQ-TREE!
tree = build_tree(aln, "JC", rand_seed=1) # Optionally specify a random seed.

print("Tree topology:", tree) # A cogent3 tree object
print("Log-likelihood:", tree.params["lnL"])
# In a Jupyter notebook, try tree.get_figure() to see a dendrogram

Note See the cogent3 docs for examples on what you can do with cogent3 trees.

Fit Branch Lengths to Tree Topology

from piqtree import fit_tree
from cogent3 import load_aligned_seqs, make_tree

# Load Sequences
aln = load_aligned_seqs("tests/data/example.fasta", moltype="dna")
aln = aln.take_seqs(["Human", "Chimpanzee", "Rhesus", "Mouse"])

# Construct tree topology
tree = make_tree("(Human, Chimpanzee, (Rhesus, Mouse));")

# Fit branch lengths with IQ-TREE!
tree = fit_tree(aln, tree, "JC")

print("Tree with branch lengths:", tree)
print("Log-likelihood:", tree.params["lnL"])

More

For more examples ranging from using ModelFinder, to making rapid neighbour-joining trees, or randomly generated trees be sure to check out the documentation!

About

A Python library that exposes features from IQ-TREE - efficient software for phylogenomic inference

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

 
 
 

Contributors 6