Skip to main content

Publication-quality plots from MAGGIC pipeline results

Project description

maggic-wand

maggic-wand generates publication-quality static plots from MAGGIC (Metagenome Assembled Genome with Iterative Classification) pipeline output. It takes the maggic-results.tsv table and optional maggic-globalabundance.tsv (CoverM TMM matrix) and produces PNG charts suitable for downstream MultiQC integration.


 

Problems It Solves

  • Manual plotting: Avoids per-run manual invocation of ggplot/matplotlib scripts
  • Inconsistent taxonomy parsing: extracts genus, species, and phylum from GTDB-Tk style __-delimited strings in one place
  • Abundance aggregation: joins CoverM TMM per-bin values to genus/species level with taxonomy from results
  • Reproducible output: fixed color palettes (tab20-based), deterministic figure sizes, 300dpi PNG


 

How It Works

  1. User points maggic-wand at a directory containing maggic-results.tsv
  2. The tool loads results, optionally joins with maggic-globalabundance.tsv for abundance-aware plots
  3. Taxonomy (genus, species, phylum) is extracted and attached to abundance rows
  4. Requested plot types are generated as 300dpi PNGs


 


 

Minimum Requirements

  1. Python 3.11+
  2. Dependencies: pandas, matplotlib, seaborn, scipy, wordcloud, typer, beartype, rich


 

Installation

Installation from PyPI

pip install maggic-wand

Or with uv:

uv pip install maggic-wand

The package installs the maggic-wand CLI entry point.

Installation via uv (Editable)

git clone repo-url
cd maggic-wand
uv sync

Installation from Source

pip install .

For development with formatting tools:

pip install -e ".[dev]"


 

Input Files

maggic-wand expects these files in the results directory:

File Required Source
maggic-results.tsv Yes MAGGIC pipeline output (30-column TSV with bin metadata, taxonomy, AMR, MGE fields)
maggic-globalabundance.tsv No CoverM TMM-normalized abundance matrix (bins x samples)
ALL_REFINED_BINS_QUALITY_REPORT.tsv No Binette post deduplication quality report (12 columns)

Plots that depend on abundance data (diversity, heatmap) are skipped with a warning if maggic-globalabundance.tsv is absent. The quality-ecdf plot is skipped if the Binette quality report is absent.


 

Usage

Generate All Plots

maggic-wand plot --maggic-results-dir /path/to/maggic/results/

This discovers maggic-results.tsv and optional companion files, then writes all PNG plots to <results_dir>/plots/.

Single Plot Type

# Only diversity (genus + species) and heatmap (genus + species)
maggic-wand plot --maggic-results-dir results/ --plot-type diversity,heatmap

Individual Plot Commands

For targeted use (e.g., scripting a single chart):

# Diversity stacked bars (genus + species)
maggic-wand plot-diversity results/maggic-results.tsv results/maggic-globalabundance.tsv -o diversity.png -n 10

# Quality scatter
maggic-wand plot-quality results/maggic-results.tsv -o quality.png

# Heatmaps (genus + species)
maggic-wand plot-heatmap results/maggic-results.tsv results/maggic-globalabundance.tsv -o heatmap.png -n 30


 

Plot Types

Plot Flag Input Needed Description
Diversity diversity results + abundance Stacked bars at genus and species level, top-N taxa, TMM-summed per sample, normalized to 100%
Heatmap heatmap results + abundance Hierarchical clustering heatmaps at genus and species level, phylum-colored side bar, column dendrogram
Quality scatter quality results Completeness vs Contamination, colored by bin type
AMR wordcloud amr-wordcloud results Gene frequency from AMR_Genes column
AMR donut amr-donut results AMR class distribution, top-15 + Other
MGE radar mge-radar results Dual radar (plasmid + virus profile), top-N bins
Quality ECDF quality-ecdf results + Binette report Cumulative completeness/contamination/score by binning tool (VAMB, MetaBat2, SemiBin2)
Contig scatter contigscatter results log10(contig count) vs Completeness, marker size = genome size


 

CLI Help

maggic-wand --help
maggic-wand plot --help
maggic-wand plot-diversity --help
maggic-wand plot-heatmap --help

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

maggic_wand-0.1.2.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

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

maggic_wand-0.1.2-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: maggic_wand-0.1.2.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Rocky Linux","version":"9.7","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for maggic_wand-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c803c1534e084a110e02480707769ebe1bb84dec573aff7f3e2dde12ccac8a93
MD5 6a26ab263f11b2696856ff36e68d4415
BLAKE2b-256 c46954fc627a58781c0d639f2499a6a6a118a9643c328dc96db1a0ab9aacf72c

See more details on using hashes here.

File details

Details for the file maggic_wand-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: maggic_wand-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Rocky Linux","version":"9.7","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for maggic_wand-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dd04062dc845376fd1bc3430d98ba59575701df348d372c349c60de4b4f6317f
MD5 055eb1ec8a410f887cd845830008fb0e
BLAKE2b-256 4b00f578cb8f2d793409484fd5d4a37668aa991ab57fae2b4e7f482eeb9634dd

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