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.1.2.tar.gz (48.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.1.2-py3-none-any.whl (54.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for phylustrator-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5dfdaa248c23fb9ad7a1dfed6dbdf44a0739fd8038b510e4782f931324bd734a
MD5 6885bd8f3ebb8fe2a2877f9c90d15aa0
BLAKE2b-256 042d9ecbd5af092dcd9f41b3079be0ae5d936356b3b65f840e27d668ebee2a2a

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for phylustrator-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 33a2a330d37582c72f25eabfa8a801ef54d894bd0b00c187c2f729878d925691
MD5 7b1f7e249cea5aa84950670f3f3d744c
BLAKE2b-256 2ce840b34f421f869f0686bb8b19f80be325001ff3e9955ec8cd22fc8d3e43d8

See more details on using hashes here.

Provenance

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

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

This release

0.1.2 This release

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