Skip to main content

omicsplot

Publication-quality matplotlib figures for omics data, with two focuses:

  • omicsplot.heatmap — ComplexHeatmap-style heatmaps where the body is specified in absolute physical units (mm, cm, inch, pt). Surrounding panels (dendrograms, annotations, labels, colorbar, legend) grow outward without shrinking the body. Multi-panel composition with | (side-by-side) and / (stacked) keeps body positions exactly aligned across panels. Includes a chromosome-aware genomic_heatmap for binned signals (methylation, expression, copy number, accessibility).

  • omicsplot.tracks — genome-wide track plots stacked vertically across per-chromosome subplot axes sized proportionally to chromosome lengths. Built-in track types: scatter, line segments, bar, step coverage, SV triangles. Trivially extensible by subclassing _BaseTrack.

Both submodules share a unit system inspired by R's grid::unit(): absolute (mm, cm, inch, pt), relative (npc), and flexible (null).

Install

pip install omicsplot

Requires Python ≥ 3.10. Depends on numpy, pandas, matplotlib, scipy, seaborn.

Quick start

The snippets below show the API for each value proposition. Complete runnable examples — including synthetic data generation — are in docs/scripts/render_readme.py, which produces the figures shown here.

Heatmap with absolute physical sizing

from omicsplot import unit
from omicsplot.heatmap import Heatmap, HeatmapAnnotation

hm = Heatmap(
    df,
    width=unit(120, 'mm'),
    height=unit(50, 'mm'),
    row_dendrogram_size=unit(12, 'mm'),
    col_dendrogram_size=unit(10, 'mm'),
    z_score=0,                 # row-wise normalization
    cmap='RdBu_r',
    center=0,
)
hm.add_top_annotation(HeatmapAnnotation(
    group=sample_groups,
    batch=sample_batch,
    height=unit(3, 'mm'),
))
hm.draw()

heatmap with absolute physical sizing

Multi-panel composition

Use | for side-by-side and / for stacked. With share_row_order=True (side-by-side) or share_col_order=True (stacked), bodies stay aligned across panels.

hm_a = Heatmap(mat_a, width=unit(40, 'mm'), height=unit(45, 'mm'),
               cmap='RdBu_r', center=0, name='Expression',
               show_row_names=False)
hm_a.add_left_annotation(HeatmapAnnotation(
    Group=groups, colors=group_colors, width=unit(4, 'mm'),
))

hm_b = Heatmap(mat_b, width=unit(25, 'mm'), height=unit(45, 'mm'),
               cmap='YlOrRd', col_cluster=False, name='Copy number',
               show_row_names=False)

(hm_a | hm_b).draw(share_row_order=True)

side-by-side composition with aligned bodies

Compound layouts also work: (A | B) / C, A | B | C, etc.

Chromosome-aware genomic heatmap

genomic_heatmap takes a long-form matrix with chrom/start/end columns and arranges the columns into chromosome-proportional segments. The optional cluster-of-clusters dendrogram (row_cluster_dendrogram) shows relationships between groups, not individual rows.

from omicsplot.heatmap import genomic_heatmap

genomic_heatmap(
    matrix,                    # columns: chrom, start, end, then per-cell
    chrom_col='chrom',
    cmap='bwr', vmin=0, vmax=4, center=2,
    row_cluster=False,
    show_row_names=False,
    row_annotation={'Cluster': cluster_labels},
    row_annotation_colors={'Cluster': palette},
    row_gap=unit(2, 'mm'),
    row_cluster_dendrogram=cluster_link,             # leaves are groups
    row_cluster_dendrogram_size=unit(10, 'mm'),
)

chromosome-aware genomic heatmap with cluster dendrogram

Genome-wide tracks

Each chromosome gets its own subplot axis sized proportionally to its length. genome_range returns chromosome lengths for common builds.

from omicsplot import genome_range
from omicsplot.tracks import ScatterTrack, plot_tracks

gs = genome_range(genome='hg38')

scatter = ScatterTrack(
    points, x_column='start', y_column='value',
    ylabel='logR', ylim=(-1.5, 1.5),
    s=1, alpha=0.4,
)
plot_tracks(scatter, gs, figsize=(10, 0.8))

genome-wide tracks with chromosome-proportional axes

Status

Alpha. API may change before 1.0.

License

MIT.

Metadata

Release files for omicsplot 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for omicsplot 0.1.0
File Size Uploaded
omicsplot-0.1.0.tar.gz 58.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for omicsplot 0.1.0
File Interpreter ABI Platform
omicsplot-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 123.4 kB

Release files / omicsplot-0.1.0.tar.gz

Download URL omicsplot-0.1.0.tar.gz
Size 58.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8840d4e0ce3333c6c026401a3b6a7f94afa6c9f4b9da856389668b24e05f5813
BLAKE2b-256 checksum
How to use checksums
531b8f5d20d3c2f442b632559396d998da7e97eb620eabfbb51028e172d5016b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / omicsplot-0.1.0-py3-none-any.whl

Download URL omicsplot-0.1.0-py3-none-any.whl
Size 65.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
99e908db10d8c9d0df9f84476be734163340a1f4a4e116c709cac668ab3bc0db
BLAKE2b-256 checksum
How to use checksums
e3833c8908e393f928b72af2269751b6e8e58492f2484adfe9d72bbcd441f0f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page