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.9.tar.gz (65.8 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.9-py3-none-any.whl (66.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: phylustrator-0.2.9.tar.gz
  • Upload date:
  • Size: 65.8 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.9.tar.gz
Algorithm Hash digest
SHA256 05b24cb791eb28ea16bc4c38490f373ddac6aa91a0e77e4ff0c5b55f68af3699
MD5 d8522cb3fddab8cdf06c0b8b06a288dc
BLAKE2b-256 3eb36a54c1c7990047142f53455f7cdec472d7726b4d4d835e55e5a9b37830eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for phylustrator-0.2.9.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.9-py3-none-any.whl.

File metadata

  • Download URL: phylustrator-0.2.9-py3-none-any.whl
  • Upload date:
  • Size: 66.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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 afe9597adcb2af00d949c57a767edb2e80daeb9a7a7f38708d31e371f2058e83
MD5 10c89d0372ca893dd42018bd83337a20
BLAKE2b-256 a79b7ae8170a2fd122dff62d5422d1d605718d795361b9d0a5e38e342dd4e7c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for phylustrator-0.2.9-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

This release

0.2.9 This release

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

0.2.3

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