Skip to main content

nf-metro

Documentation | Playground | Gallery

Generate metro-map-style SVG diagrams from Mermaid graph definitions with %%metro directives. Designed for visualizing bioinformatics pipeline workflows (e.g., nf-core pipelines) as transit-style maps where each analysis route is a colored "metro line."

nf-core/rnaseq metro map

Try it without installing: the nf-metro playground runs the full layout engine in your browser. Edit a .mmd file, preview the result live, import a Nextflow -with-dag diagram directly, and tweak layout options - no Python, no CLI needed.

What nf-metro does

  • Static SVG - a self-contained diagram you can commit, embed in a README, or drop into docs.
  • Interactive HTML - pan, zoom, hover for station details, click a line in the legend to isolate it and zoom to its extent.
  • Live progress overlay - light up stations in real time as a Nextflow pipeline runs, using nf-metro serve with Nextflow's -with-weblog.
  • Dashboard mode - nf-metro serve-multi hosts many pipelines or runs side by side on one page.
  • Nextflow DAG import - convert a -with-dag Mermaid export into a metro map with nf-metro convert (or --from-nextflow on render).
  • Embedded data manifest - every SVG carries a machine-readable JSON manifest so overlays and downstream tools can address stations without re-running the layout engine.

Installation

pip (PyPI)

pip install nf-metro

Conda (Bioconda)

conda install bioconda::nf-metro

Container (Seqera Containers)

A pre-built container is available via Seqera Containers:

docker pull community.wave.seqera.io/library/pip_nf-metro:611b1ba39c6007f1

Extras

Two features need a dependency the base install leaves out:

pip install "nf-metro[validate]"   # nf-metro validate-svg (jsonschema)
pip install "nf-metro[font]"       # render --text-to-paths (fonttools)

Development

pip install -e ".[dev]"

Requires Python 3.11+.

Quick start

Write a two-line pipeline to pipeline.mmd:

cat > pipeline.mmd <<'EOF'
%%metro title: Simple Pipeline
%%metro line: main | Main | #4CAF50
%%metro line: qc | Quality Control | #2196F3 | dashed

graph LR
    input[Input]
    fastqc[FastQC]
    trim[Trimming]
    align[Alignment]

    input -->|main| trim
    trim -->|main| align
    input -->|qc| fastqc
    trim -->|qc| fastqc
EOF

Render it:

nf-metro render pipeline.mmd -o pipeline.svg

Check the input without rendering, or see what nf-metro made of it:

nf-metro validate pipeline.mmd
nf-metro info pipeline.mmd

Every command takes --help, and the CLI reference documents each one and every option it accepts. The Guide is a step-by-step walkthrough of writing .mmd files, ending in the full directive reference.

Input format

Input files are a subset of Mermaid graph LR syntax extended with %%metro directives. The map above uses only global directives, which configure the whole map, plus edges carrying the line IDs that pass along them. Section directives inside Mermaid subgraph blocks control how each section is laid out.

From there the Guide covers sections, entry and exit ports, grid placement, file and folder icons, off-track stations, inactive lines and the rest, directive by directive.

Interactive HTML output

--format html produces a self-contained page with the SVG inlined plus a small JS/CSS layer (no external dependencies, no network):

nf-metro render pipeline.mmd --format html -o pipeline.html

Drag to pan, scroll to zoom, hover a station for its label, section and lines, and click a line in the legend to isolate it and zoom to its extent. An Embed... panel copies out a snippet for a host page: inline HTML that keeps full interactivity, an iframe one-liner, or the raw <svg> for contexts that strip scripts.

GitHub READMEs are one of those contexts, so embed there as a static SVG (or link out to a hosted version). Most static-site generators and internal wikis run the inline-HTML snippet as-is. See the embedding guide for the options.

Live progress

nf-metro can light up a metro map in real time as a Nextflow pipeline runs. Map stations to Nextflow processes with %%metro process: directives, then start the server and point Nextflow's -with-weblog at it:

nf-metro serve path/to/map.mmd
nextflow run my/pipeline -with-weblog http://localhost:8080/events

Stations transition from pending to running to done as tasks are submitted and complete. The layout is computed once and the overlay is drawn on top, so the map never re-flows during a run. nf-metro serve-multi is the dashboard version: each pipeline or run registers its own map and gets a stable /r/<id>/ URL.

For multi-pipeline dashboards, persistent history, and the optional Nextflow plugin that handles wiring automatically, see the live progress guide.

Embedded data manifest

Every rendered SVG carries a machine-readable manifest, so the committed file is a self-contained artifact: a downstream tool can position overlays, restyle nodes, or look up which processes a node represents without re-running the layout engine. The data travels as a JSON block in a <metadata id="diagram-manifest"> element and as data-node-* attributes on each station's <g> element. See the data manifest docs for the schema and how to consume it.

Examples

The examples/ directory contains ready-to-render .mmd files:

Example Description
simple_pipeline.mmd Minimal two-line pipeline with no sections
rnaseq_auto.mmd nf-core/rnaseq with fully auto-inferred layout
rnaseq_sections.mmd nf-core/rnaseq with manual grid overrides

Topology gallery

examples/topologies/ collects the layout patterns the engine is tested against. See the topology README for descriptions and rendered previews, or browse the online gallery.

A few highlights:

Wide Fan-Out Section Diamond Variant Calling
Wide Fan-Out Section Diamond Variant Calling
Fold Serpentine Multi-Line Bundle RNA-seq Lite
Fold Double Multi-Line Bundle RNA-seq Lite

Python API

nf-metro is a command-line tool. Its Python modules are importable, but the internal API (parser, layout engine, renderer) is not part of the public, semver-stable surface and may change between releases without notice. Drive nf-metro through the nf-metro CLI (or python -m nf_metro) for stable behaviour.

Contributing

See the Contributing guide for setup, testing, how to add topology fixtures, working with layout invariants, and the visual review process.

License

MIT

Download files

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

Source Distribution

nf_metro-2.0.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

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

nf_metro-2.0.0-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file nf_metro-2.0.0.tar.gz.

File metadata

  • Download URL: nf_metro-2.0.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nf_metro-2.0.0.tar.gz
Algorithm Hash digest
SHA256 ed143d81fb148ed405b3a05dc3663f4c4a32b39edfe36f10eea043364018107f
MD5 b9efb50705a8e1b8faaaf27bdbca8244
BLAKE2b-256 c4b16ba10f4d1355fb82845aab2c3705fec07144a09632a0b6b0486364d2feca

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_metro-2.0.0.tar.gz:

Publisher: publish.yml on seqeralabs/nf-metro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nf_metro-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: nf_metro-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nf_metro-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f8ac8a36dcedce5e51ceb4043bc9f855482579741d532da317b43c53cdbc384
MD5 2f985e7f5b228f69b7677586cda8e8c9
BLAKE2b-256 9706ce3aa96be153d659825bde0d6905a9a7c4e5c5a7f89d224aff94d1b95d3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_metro-2.0.0-py3-none-any.whl:

Publisher: publish.yml on seqeralabs/nf-metro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 files

1.1.0

2 files

1.0.0

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.1

2 files

0.6.0

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.7

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 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