Skip to main content

Transcript model figures with composable genomic and protein coordinate systems.

Project description

txplot

Transcript model figures built on matplotlib. Distinct from existing libraries in that coordinate systems are first-class objects: genomic and protein spaces compose, and the joint genomic-protein "exon bridge" view is a renderable object rather than a side-effect.

Install

pip install "txplot @ git+https://github.com/ymvk/monorepo@main#subdirectory=packages/txplot"

Quick start

import pandas as pd
import txplot as tx

gs = tx.GenomicSpace.from_gtf("annotation.gtf", gene="BRCA1")
ps = tx.ProteinSpace.from_transcript(gs, "ENST00000357654")

fig = tx.Figure(
    tx.GenomicPanel(gs, [
        tx.Coverage(coverage_df),
        tx.Sashimi(junction_df, scale="log"),
        tx.Transcripts("annotation.gtf", "BRCA1", cds_utr=True, chevrons=True),
        tx.Lollipops(mutations_df, coord="genomic", color_by="category"),
    ], title="BRCA1"),
    tx.Bridge(gs, ps),
    tx.ProteinPanel(ps, [
        tx.Domains(pfam_df),
        tx.Lollipops(mutations_df, coord="protein", color_by="category"),
    ], title="BRCA1 protein"),
    figsize=(12, 7),
)
fig.save("brca1.svg")

Design

Three coordinate objects:

Object Maps Used by
GenomicSpace genomic bp to [0, 1] figure coord GenomicPanel + genomic tracks
ProteinSpace 1-based AA position to [0, 1] ProteinPanel + protein tracks
Bridge genomic CDS exons to AA ranges Own renderable panel

GenomicSpace optionally compresses introns to a fixed fractional width per intron; exonic regions share the remaining width proportionally. Disable with compress_introns=False for a linear axis.

Tracks render into a horizontal slot of their panel's Axes. They have a height attribute that determines their relative vertical allocation.

Tracks

Each track accepts a pandas.DataFrame with a documented schema. No parsing of BAM/VCF is done in v0.1; users bring their data as DataFrames and can pipeline via pysam, bcbio, polars, etc.

Transcripts(gtf, gene, cds_utr=True, chevrons=True)

Reads exon and CDS records from the GTF. Draws tall rectangles for CDS regions and thin rectangles for UTR regions; overlays directional >/< chevrons on intron lines.

Lollipops(data, coord="genomic" | "protein", color_by="category")

DataFrame columns:

Column Type Required Description
position int yes Genomic (if coord="genomic") or AA position
height float no VAF or recurrence count (default 1)
category str no Consequence label for color
label str no Text drawn next to the head

Consequence colors default to a colorblind-safe palette (missense=vermillion, nonsense=black, synonymous=sky, splice=reddish purple, ...).

Sashimi(data, scale="linear" | "log")

Column Type Description
start int Junction 5' genomic position
end int Junction 3' genomic position
count int Read count supporting the junction

Renders quadratic-Bezier arcs between start and end; arc linewidth proportional to count (with optional log1p scaling for wide dynamic range).

Coverage(data)

Column Type Description
position int Genomic position
depth int Read depth

Filled histogram. The max depth is annotated at the right edge.

Domains(data) (ProteinSpace only)

Column Type Description
name str Domain name, drawn as label in the box
start int AA start (1-based inclusive)
end int AA end (inclusive)

Palettes

txplot.palette.OKABE_ITO is the default for small categorical sets (up to 8). Larger sets delegate to glasbey via txplot.palette.categorical(n, colorblind_safe=True).

What's not in v0.1

Deferred to v0.2+:

  • Conservation track (phyloP / phastCons; needs bigWig support).
  • Direct BAM/VCF parsing helpers (txplot.io).
  • Protein hydrophobicity / secondary-structure overlays.
  • Multi-sample / multi-condition faceting.

Project details


Download files

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

Source Distribution

txplot-0.1.0.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

txplot-0.1.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file txplot-0.1.0.tar.gz.

File metadata

  • Download URL: txplot-0.1.0.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for txplot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8579b06eaa7ed9c393311043c9be6a2ab2513ba12964147f1257319885f46dcf
MD5 08977cf1711590ef491d93e302d57f2d
BLAKE2b-256 9f7ee0c514b50133434922d371d3995e52278f1557bb08c9762bcece16dc92d8

See more details on using hashes here.

File details

Details for the file txplot-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: txplot-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for txplot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f00094ace3574466d6c5693265ea0982d56418c72098356af940acec640d439d
MD5 acef8ad1f2a9f414b19561f3ec086bc5
BLAKE2b-256 5c3a35ae62d41c0e82f04d478993f326888ad460e1c69bce2e74c0773ea7ccbf

See more details on using hashes here.

Supported by

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