Plotting and saving

Reference

This page summarizes the high-level API contract. For visual examples, start with Quick Start, Track Catalog, and Aesthetics. For generated field lookup, use Compact Options.

GenomicFigure

from plotnado import GenomicFigure

fig = GenomicFigure(
    width=12,
    track_height=1.25,
    theme="publication",  # "default" | "minimal" | "publication" | None
)

Every track helper returns self, so figures can be built with chained or sequential calls.

Core track helpers

Helper Purpose Typical input
bigwig(data, **kwargs) Continuous signal. BigWig path/URL or table with chrom, start, end, value.
bed(data, **kwargs) Genomic intervals. BED/BigBed path or table with chrom, start, end.
narrowpeak(data, **kwargs) ENCODE narrowPeak intervals. narrowPeak path or compatible table.
links(data, **kwargs) Interaction arcs. BEDPE-like table.
genes(genome="hg38", **kwargs) Gene models. Built-in genome name or custom annotation data.
overlay(tracks, **kwargs) Multiple signals in one panel. List of signal sources or BigWigTrack objects.
bigwig_collection(files, **kwargs) Multi-file signal collection. BigWig file list.
bigwig_diff(file_a, file_b, **kwargs) Difference between two signal files. Two BigWig files.
scalebar(**kwargs) Genomic distance cue. No external data.
axis(**kwargs) Coordinate ticks. No external data.
spacer(height=0.5, **kwargs) Blank vertical space. No external data.

Figure-level controls

fig.autoscale(True)
fig.autocolor("Set2")
fig.highlight("chr1:1,032,000-1,046,000")
fig.highlight_style(color="#ffdd57", alpha=0.22)

The rendered example shows highlight, autoscale, and overlay behavior together.

from plotnado import GenomicFigure
from plotnado.examples import REGION, review_signal
# review_signal() → DataFrame(chrom, start, end, value) — replace with BigWig paths/URLs or DataFrames

fig = GenomicFigure(track_height=1.2)
fig.autoscale(True)
fig.highlight("chr1:1,032,000-1,046,000")
fig.highlight_style(color="#ffdd57", alpha=0.22)
fig.bigwig(review_signal(2.0), title="Control", autoscale_group="signal", color="#1f77b4")
fig.bigwig(review_signal(10.0, 1.2), title="Treatment", autoscale_group="signal", color="#d62728")
fig.overlay(
    [review_signal(5.5, 2.0), review_signal(6.5, 2.8)],
    title="Overlay",
    autoscale_group="signal",
    colors=["#2ca02c", "#9467bd"],
    alpha=0.55,
)
fig.plot(REGION)

fig.plot("chr1:1,000,000-2,000,000")
fig.plot("chr1:1,000,000-2,000,000", extend=0.25)
fig.plot_gene("GNAQ", extend=0.5)
fig.plot_regions(["chr1:1,000,000-2,000,000", "chr2:5,000,000-6,000,000"], ncols=2)
fig.save("out.png", region="chr1:1,000,000-2,000,000", dpi=200)

Editing after build

fig["track title"]
fig[0]
fig["track title"].color = "coral"

fig.update_track("title", color="purple", max_value=500)
fig.update_track(height=0.2)
fig.update_track(track_type="bigwig", height=0.3)
fig.update_track(group="group_1", max_value=1000)
fig.update_track(where=lambda t: "CD" in (t.title or ""), color="coral")

fig.remove_track("title")
fig.bigwig("extra.bw", title="extra", position="top")

Loading external definitions

fig = GenomicFigure.from_template("template.yaml")

fig, locus = GenomicFigure.from_igv_session("session.xml")
fig.plot(locus)

fig.to_toml("figure.toml")
fig2 = GenomicFigure.from_toml("figure.toml")

Runtime option discovery

GenomicFigure.available_track_aliases()
GenomicFigure.track_options("bigwig")
GenomicFigure.track_options_markdown("bigwig")