Skip to main content

Phylustrator

A small, composable plotter for evolutionary figures. Two domains share one grammar: ph.trees plots phylogenetic trees and ph.genomes plots genomes, synteny and alignments. Start a figure, add layers with +, and save it to SVG, PDF, or PNG.

A 100-tip tree with branches coloured by a Brownian-motion trait

Install

pip install git+https://github.com/AADavin/Phylustrator

SVG output needs nothing else; for PDF/PNG also install cairosvg (pip install cairosvg).

Trees

import phylustrator as ph

tree = ph.trees.loads("((((Human:6,Chimp:6)a:2,Gorilla:8)b:3,Orang:11)c:5,Gibbon:16)root;")
brain = {"Human": 1350, "Chimp": 400, "Gorilla": 500, "Orang": 400, "Gibbon": 100,
         "a": 650, "b": 560, "c": 500, "root": 470}

(ph.trees.plot(tree)
 + ph.trees.color_branches(brain)
 + ph.trees.tip_labels()
 + ph.trees.colorbar("brain size (cc)")
 + ph.trees.time_axis("million years")).save("tree.png")

That is the whole idea: plot(tree) starts a figure and each + layer adds one decoration.

  • Layoutsrectangular (default), radial, unrooted.
  • Layerscolor_branches, color_history, tip_labels, node_labels, tip_track, branch_events, colorbar, legend, time_axis, time_marker, scale_bar, note, highlight_clade.

Genomes

The same grammar, for genome maps. Plot a genome as a line or a ring, colour genes by family or strand, link two genomes with synteny ribbons, or set a copy-number heatmap / alignment beside a tree.

import phylustrator as ph

G = ph.genomes.read_gff("genome.gff")           # {name: Genome}
genome = next(iter(G.values()))
(ph.genomes.plot(genome, layout="circular", coordinates="nucleotide")
 + ph.genomes.genes(by="strand")
 + ph.genomes.position_axis()).save("ring.png")
  • Layoutslinear, circular, and stack (one genome per row, for synteny).
  • Layersgenes, synteny, highlight, position_axis.
  • Panelsheatmap, alignment, placed next to a tree with ph.beside(tree, panel).

ZOMBI2 I/O

ph.zombi reads the output of the ZOMBI2 genome-evolution simulator into the data models above — kept in one clearly-separated layer so the core stays format-agnostic:

import phylustrator as ph

G = ph.zombi.read_genomes("run/genomes")        # {lineage: Genome}
M = ph.zombi.read_profiles("run")               # family x genome copy-number Matrix
aln = ph.zombi.read_alignment("run", family=0)  # Alignment keyed by genome
tree = ph.zombi.read_species_tree("run")        # a Tree

Command line

phyl is a one-shot tree viewer — hand it a Newick file:

phyl tree.nwk                 # render to a temporary PDF and open it
phyl tree.nwk -o fig.svg      # save instead (format from the extension: .svg / .pdf / .png)
phyl tree.nwk --radial --no-labels

Flags: --layout {rectangular,radial,unrooted} (or --radial / --unrooted), --no-labels, --node-labels, --no-stem, --no-open. Colouring and everything else live in the Python API.

Dependencies

Only drawsvg (plus cairosvg for PDF/PNG). No ete3, no matplotlib.

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phylustrator-0.2.3.tar.gz (59.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

phylustrator-0.2.3-py3-none-any.whl (62.3 kB view details)

Uploaded Python 3

File details

Details for the file phylustrator-0.2.3.tar.gz.

File metadata

  • Download URL: phylustrator-0.2.3.tar.gz
  • Upload date:
  • Size: 59.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for phylustrator-0.2.3.tar.gz
Algorithm Hash digest
SHA256 26176e29dea315ff5e2dd9b97e08ab391f72e9c27b2e44675439124bce9a5b9a
MD5 6873c6c05614d8218527b1b7408d9037
BLAKE2b-256 63b036909f15cd8517737a8212a86e0c4fe2cadf10ac0b84d1b7fa2211636922

See more details on using hashes here.

Provenance

The following attestation bundles were made for phylustrator-0.2.3.tar.gz:

Publisher: release.yml on AADavin/Phylustrator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phylustrator-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: phylustrator-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 62.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for phylustrator-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3577fc0633732858ed4ca9417c49c8f5b6df6445e1409495d29a44bd379a77fe
MD5 2ae8ff0fd1079559d9ba5901c13ec301
BLAKE2b-256 853c75290aee9ed9d1db63ff1c8f3d18b11b943304eff67e212a9d89bf8dfb97

See more details on using hashes here.

Provenance

The following attestation bundles were made for phylustrator-0.2.3-py3-none-any.whl:

Publisher: release.yml on AADavin/Phylustrator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.17

2 files

0.2.16

2 files

0.2.15

2 files

0.2.14

2 files

0.2.13

2 files

0.2.12

2 files

0.2.11

2 files

0.2.10

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

This release

0.2.3 This release

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page