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.1.tar.gz (22.3 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.1-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: maggic_wand-0.1.1.tar.gz
  • Upload date:
  • Size: 22.3 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.1.tar.gz
Algorithm Hash digest
SHA256 bd67dbc3fc0ae63922cfd7b2f70753212b422d44a25a116a44057d05c2ec9bae
MD5 b95ca05f4215f6fc36542351efe4a530
BLAKE2b-256 49292bf24c1f441de121567925b3e6cf5813595dda9d62f4f576be71b3f78cf3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: maggic_wand-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 51dba88701354738072dc4b115cc864bd69845ed2c66ccecbc485ead4d0262b0
MD5 881847bc5691bae501d50e7fb6b90940
BLAKE2b-256 3416164e72e73ce8d4a741e51f7c9c9d4ce42f757aa86cbc81957cea5602c7ad

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