MagCluster 
MagCluster is a tool for finding, annotating, and visualizing magnetosome gene clusters (MGCs) in bacterial genomes.
What's New in v1.1
- Standalone
magcluster clinkercommand: plot or re-plot sliced MGC GenBank files (clusters_gbk/*.gbk) anytime—with MagCluster's 8-family color scheme and domain labels—without re-running gene calling or HMM search. - Automatic batch plotting (
--batch-size 50): large datasets (> 50 MGC clusters) are automatically split in input order intoMGC_align_batch01.html,MGC_align_batch02.html, … so Clinker alignments stay fast and browser rendering never freezes. - Cohort summary table (
mgc_summary.tsv): everymagcluster runwrites a single overview table across all input genomes, including MGC status, subcluster counts, coordinates, predicted mineral type (Magnetite/Greigite/Putative/Mixed), and.gbkpaths. - One-step Prokka-free pipeline (v1.0):
magcluster runpredicts genes natively with Pyrodigal and searches 92 curated magnetosome HMMs (Mam,Mms,Mad,Man,Mae,Maq,Mca,Feo) in memory via PyHMMER. - Flexible inputs & run log: accepts GenBank (
.gbk/.gbff), nucleotide FASTA contigs (.fasta/.fna/.fa), and protein FASTA (.faa), including.gzcompressed files, and records full provenance inmagcluster.log. See CHANGELOG.md.
Installation
MagCluster requires Python 3.10 or newer.
Option A: pip (PyPI)
pip install magcluster
Option B: conda / mamba (Bioconda)
conda create -n magcluster -c conda-forge -c bioconda magcluster
conda activate magcluster
To add it to an existing environment: conda install -c conda-forge -c bioconda magcluster.
List conda-forge before bioconda as shown. If your conda is configured with strict channel priority, conda install -c bioconda magcluster alone can fail to solve.
Option C: development version from GitHub
pip install git+https://github.com/RunJiaJi/MagCluster.git
# or, from a local clone:
git clone https://github.com/RunJiaJi/MagCluster.git
cd MagCluster
pip install -e ".[dev]"
Verify the installation:
magcluster --version
magcluster run --help # -h works too
Quick Start
1. Annotated GenBank file (.gbff / .gbk)
magcluster run genome.gbff -o results/
2. Unannotated FASTA contigs (.fasta / .fna / .fa)
MagCluster automatically predicts genes and uses all CPU cores by default:
magcluster run contigs.fasta -o results/ -t 8
3. Multiple genomes in a folder
magcluster run genomes_dir/ -o results/
4. Protein FASTA (.faa / .pep)
Prodigal-style headers (>id # start # end # strand # ...) keep the genomic coordinates, so clusters are detected and plotted. If your input contains protein sequences without coordinates, MagCluster will annotate magnetosome proteins and output TSV table and FASTA files without plotting the gene cluster:
magcluster run proteins.faa -o results/
5. High-throughput screening + standalone Clinker plotting
# Step 1: fast screening on hundreds of genomes without plotting
magcluster run genomes_dir/ -o results/ --no-plot -t 16
# Step 2: plot all or selected MGC slices anytime with `magcluster clinker`
magcluster clinker results/ -o plots/
6. Overwrite an existing output folder
magcluster run genome.gbff -o results/ --force
Commands & Options
magcluster run
magcluster run [OPTIONS] INPUTS...
INPUTS can be files or folders. In a folder, only files with a genome extension are used (.gbk, .gbff, .gbf, .gb, .fa, .fasta, .fna, .fsa, .fsa_nt, .faa, .pep, each optionally .gz). Other files (e.g. README.txt) and hidden files are skipped with a warning. A file given explicitly is used even without an extension; its format is detected from the first line. GFF3 files are not supported because they contain no sequences. Use the matching GenBank/GBFF, FASTA or Prodigal .faa file instead.
| Option | Aliases | Default | Description |
|---|---|---|---|
--outdir |
-o |
magcluster_results |
Output directory (must not be an existing file) |
--force |
-f |
False |
Allow a non-empty output directory. Outputs of a previous MagCluster run there (mgc_summary.tsv, per-genome tables, FASTA, MGC_align*.html, clusters_gbk/, figures/, magcluster*.log) are deleted first; other files are kept |
--threads |
-t |
0 |
Number of CPU threads (0 = all available cores; values above the available cores are capped) |
--evalue |
-e |
1e-5 |
HMM search E-value cutoff (≥ 0) |
--score |
-s |
per-profile trusted_cutoff (25.0) |
Minimum HMM bit score. If omitted, each profile's trusted_cutoff from rules.yaml is used (25.0 for all 92 built-in profiles). An explicit value replaces it for every profile, including values below 25 |
--max-gap |
5 |
Maximum non-magnetosome genes allowed between hits in a cluster (≥ 0). Hits must also be ≤ 25 kb apart (fixed) | |
--threshold |
-th, --min-families |
3 |
Minimum number of distinct magnetosome families (any non-Feo family) required to call an MGC (≥ 1) |
--flank |
-un, --unmag-num |
3 |
Number of non-magnetosome flanking genes to keep on each side (≥ 0) |
--meta / --single |
Auto | Force metagenome or single-genome mode for gene prediction. Auto uses meta mode for inputs < 100 kb or with > 200 contigs all < 20 kb. --single falls back to meta mode (with a warning) when there is too little sequence (< 20 kb) to train. Ignored for inputs that already contain CDS/proteins |
|
--identity |
-i |
0.3 |
Minimum sequence identity cutoff for Clinker alignments (0.0–1.0) |
--batch-size |
-b |
50 |
Maximum number of MGC clusters plotted per Clinker HTML file in input order (0 = plot all clusters in a single MGC_align.html) |
--clinker-opts |
None |
Extra arguments passed to Clinker (e.g. "-na -ufo"). Relative output paths such as -mo matrix.tsv are written inside the output directory |
|
--clinker-help |
Show available Clinker options guide and exit | ||
--static-plot |
False |
Also generate static SVG figures in figures/ |
|
--no-plot |
False |
Skip Clinker visualization (tables and GenBank slices only) | |
--log |
<outdir>/magcluster.log |
Write the run log to another file | |
--help |
-h |
Show help and exit |
Global options: magcluster --version (-v) and magcluster --help (-h).
Genome IDs (used in output file names, the genome column and gene IDs of predicted genes) are taken from the input file name minus .gz and the genome extension, e.g. GCF_000513295.1.fna → GCF_000513295.1 and strainX.v1.fna → strainX.v1. Spaces and special characters are replaced by _ (e.g. my strain.fna → my_strain). If two inputs give the same ID (e.g. NCBI Datasets' genomic.gbff), the later one gets a suffix (genomic_2) and a warning is printed. The same input file listed twice is used once.
Exit status: 0 on success. 1 if any input could not be read, Clinker failed, or the output directory cannot be used. Results of the other genomes are still written. 2 for invalid command-line options.
magcluster clinker
Generate interactive Clinker gene cluster comparison HTML figures directly from sliced MGC GenBank files (clusters_gbk/*.gbk) or external GenBank loci, without re-running gene prediction or HMM search:
magcluster clinker [OPTIONS] [INPUTS]...
INPUTS can be individual .gbk/.gbff files (including .gz), a clusters_gbk/ directory, or a magcluster run results directory (its clusters_gbk/ subfolder is detected automatically). MagCluster's 8-family color palette and domain labels are restored from embedded GenBank /note metadata; external GenBank files are annotated automatically with the built-in 92 magnetosome HMMs.
| Option | Aliases | Default | Description |
|---|---|---|---|
--outdir |
-o, --output |
clinker_results |
Output directory (writes MGC_align.html or MGC_align_batch*.html), or a specific .html file path (e.g. -o custom.html) |
--list |
-l |
None |
Plain-text file listing .gbk paths, file names, or cluster/genome IDs (one per line) in the exact top-to-bottom plotting order |
--batch-size |
-b |
50 |
Maximum number of clusters per Clinker HTML file in input order (0 = plot all clusters in a single HTML) |
--identity |
-i |
0.3 |
Minimum sequence identity cutoff for Clinker alignments (0.0–1.0) |
--threads |
-t |
0 |
Number of CPU threads (0 = all available cores) |
--clinker-opts |
None |
Extra arguments passed to Clinker (e.g. "-na -ufo") |
|
--clinker-help |
Show available Clinker options guide and exit | ||
--force |
-f |
False |
Overwrite existing Clinker HTML output file(s) (never deletes TSV/FASTA/GBK files) |
--log |
<outdir>/magcluster_clinker.log |
Write the Clinker run log to another file | |
--help |
-h |
Show help and exit |
Examples:
# Plot all MGC slices from a previous `magcluster run --no-plot` output directory:
magcluster clinker results/ -o results/
# Compare specific GenBank files into a single named HTML:
magcluster clinker AMB-1_MGC.gbk MSR-1_MGC.gbk -o amb1_vs_msr1.html
# Plot a selected subset in exact custom order (e.g. matching a phylogenetic tree):
magcluster clinker results/ -l tree_order.txt -o tree_mgc.html --clinker-opts "-ufo"
magcluster db
View the built-in reference database, the 10 core defining families, and all 92 HMM profiles sorted by sequence count:
magcluster db
Output Files
Running magcluster run <inputs> -o results/ produces:
results/
├── mgc_summary.tsv # Cohort summary table (1 row per input genome)
├── {genome}_mgc_genes.tsv # Table of all identified magnetosome gene hits (clustered + unclustered)
├── {genome}_magnetosome_proteins.faa # Extracted magnetosome protein sequences
├── MGC_align.html # Interactive gene cluster map (or MGC_align_batch01.html, ... when >50 MGCs)
├── MGC_align_batches.tsv # Batch membership index (only when >1 Clinker HTML batch is generated)
├── magcluster.log # Run log (see below)
├── clusters_gbk/ # Sliced GenBank file for each cluster
│ └── {cluster_id}.gbk
└── figures/ # Only with --static-plot
└── {cluster_id}.svg # Static cluster map (pyGenomeViz)
Genomes without any magnetosome hit produce no per-genome table or FASTA file, while genomes with only isolated homologs (unclustered, status = no_MGC in mgc_summary.tsv) still write {genome}_mgc_genes.tsv so scattered hits are not lost. Every input genome is recorded in mgc_summary.tsv and magcluster.log.
0. Cohort summary (mgc_summary.tsv)
One row per input genome, making it easy to filter MGC-positive genomes, mineral types, and .gbk paths across large batches:
| Column | Meaning |
|---|---|
genome, input_file |
Sanitized genome ID and original file name |
status |
MGC_detected, no_MGC, no_coordinates, no_genes, or failed |
n_genes, n_hits, n_clustered_hits |
Total CDSs, total HMM hits, and hits inside the MGC |
cluster_id, n_subclusters, coordinates |
MGC identifier, number of syntenic slices, and genomic coordinates |
n_distinct_families, families |
Count and sorted list of distinct non-Feo magnetosome families in the MGC |
mineral_type, flags |
Magnetite / Greigite / Putative/Mixed, and quality flags (Contig_Edge, Spans_Origin) |
gbk_file |
Relative path to the sliced GenBank file (clusters_gbk/{cluster_id}.gbk) |
1. Gene table ({genome}_mgc_genes.tsv)
| Column | Meaning |
|---|---|
cluster_id |
Cluster ID (e.g. MSR-1_genome_MGC), or unclustered for isolated genes |
genome |
Genome name |
gene_id |
Locus tag or gene identifier |
contig |
Contig or scaffold name |
start, end |
Gene coordinates (1-based) |
strand |
Strand (+ or -) |
profile |
Best matching HMM profile (e.g. MamE_full, MamE_Cter, MamQ_greigite) |
parent_family |
Family name (e.g. MamE, MamQ) |
role |
core, accessory, or iron_context |
score, evalue |
HMM match score and E-value |
2. Protein sequences ({genome}_magnetosome_proteins.faa)
Amino acid sequences of all magnetosome proteins found in that genome, with detailed header info:
>MGMSRV2_RS11765 [MSR-1_genome] cluster=MSR-1_genome_MGC family=MamE profile=MamE_full score=1000.4 evalue=1.97e-301
MSERRPVGRTL...
3. Interactive visualization (MGC_align.html)
Open this file in your webbrowser:
- Gene labels: Arrows show specific domain annotations like
MamE_Cter,MamE_Nter, andMamQ_greigite. - Family colors:
- Red:
mamfamily - Yellow:
mmsfamily - Green:
madfamily - Blue:
manfamily - Gold:
feofamily - Purple:
maefamily - Teal:
maqfamily - Pink:
mcafamily - Grey: Other neighboring non-magnetosome genes
- Red:
- Customizable: Drag genes, change colors, re-align, and export publication-ready SVG figures directly from the browser.
4. Run log (magcluster.log)
A plain-text log of the run, overwritten on each run into the same folder (e.g. with --force). It contains:
- the start and end time, MagCluster, Python and dependency versions;
- the full command line and every effective parameter;
- the genome ID assigned to each input file;
- per-genome progress, timings and results (genes, hits, MGC coordinates, subclusters with their families, mineral type);
- all warnings and errors, including skipped files.
Use --log FILE to write it somewhere else.
5. Static figures (figures/{cluster_id}.svg)
Written with --static-plot: one SVG per MGC (one track per subcluster), drawn with pyGenomeViz.
Helpful Tips
Faster Clinker plotting & HTML size on large datasets
With pairwise sequence alignments enabled (the default), Clinker stores gene-to-gene alignment links for all cluster pairs, so HTML file size grows roughly quadratically (O(N^2)) with the number of homologous clusters per batch—especially when comparing closely related strains that share 50+ conserved genes. While --batch-size 50 (default) keeps diverse datasets manageable (and writes MGC_align_batches.tsv when multiple batches are created), you can make large or closely related comparisons much lighter with --batch-size and --clinker-opts:
# Use smaller batches (e.g. 20 clusters per HTML) for closely related strain sets:
magcluster clinker results/ -o plots/ -b 20
# Skip pairwise sequence alignment (reduces HTML size ~10x and runs in <1s):
magcluster run *.gbff -o results/ --clinker-opts "-na"
# Keep the original file order instead of automatic reordering:
magcluster run *.gbff -o results/ --clinker-opts "-ufo"
# Both:
magcluster run *.gbff -o results/ --clinker-opts "-na -ufo"
To see all Clinker visualization options, run:
magcluster run --clinker-help
# or
magcluster clinker --clinker-help
How an MGC is called
- Magnetosome HMM hits on the same contig are grouped when at most
--max-gap(default 5) non-magnetosome genes and at most 25 kb separate consecutive hits. Feo (iron-transport) hits do not start or extend a group. - A group is kept if it contains at least
--threshold(default 3) distinct magnetosome families. Any non-Feo family counts (core Mam families as well as accessory families such as Mad, Mms, Man, Mae, Maq, Mca). Feo families never count. - Each kept group is extended by
--flank(default 3) genes on each side. All kept groups of one genome are reported together as one MGC ({genome}_MGC) with one subcluster (loc1,loc2, …) per group. - On a complete circular replicon (GenBank
circulartopology, or a FASTA header containing "complete genome", "complete sequence" or "circular"), an MGC whose subclusters lie on both sides of the origin is reported withstart > endand marked "(spans origin)".
The 10 core defining families shown by magcluster db are:
MamA, MamB, MamE, MamI, MamK, MamL, MamM, MamO, MamP, MamQ
They are listed for reference; MGC calling does not require them.
Citation
If you use MagCluster, please cite:
Runjia Ji, Wensi Zhang, Yongxin Pan, and Wei Lin. (2022).
MagCluster: a Tool for Identification, Annotation, and Visualization of Magnetosome Gene Clusters.
Microbiology Resource Announcements, 11:e01031-21.
https://doi.org/10.1128/mra.01031-21
Dependencies used by MagCluster:
- Pyrodigal: doi:10.21105/joss.04296
- PyHMMER: doi:10.1093/bioinformatics/btad214
- Clinker: doi:10.1093/bioinformatics/btab007
Contact
Questions or suggestions? Feel free to reach out:
- GitHub Issues: Open an issue
- Email: Runjia Ji (
jirunjia@gmail.com) or Wei Lin (weilin@mail.iggcas.ac.cn)
Metadata
Release files for magcluster 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| magcluster-1.1.1.tar.gz | 2.0 MB | With provenance | Details for magcluster-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| magcluster-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for magcluster-1.1.1-py3-none-any.whl |
Total release size: 3.9 MB
Release files / magcluster-1.1.1.tar.gz
| Download URL | magcluster-1.1.1.tar.gz |
|---|---|
| Size | 2.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
82a6f99f799df6366a449b3c7c88ecd6aafd43e1dbadcea333ab88a296ec0dda
|
|
BLAKE2b-256 checksum How to use checksums |
c812fce6a3aeebb71a656f7006e83c39bba443f050247d1f13fcd921f0020f61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logRelease files / magcluster-1.1.1-py3-none-any.whl
| Download URL | magcluster-1.1.1-py3-none-any.whl |
|---|---|
| Size | 1.9 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4987a0d5dc296ee2659770a4927750cfb5f036c6099dea569bdd09d8c8f56fb5
|
|
BLAKE2b-256 checksum How to use checksums |
b0e0a12f904721426fec7973b5b3c98dfad9c9fbc1bfc23caadf33de478ae14e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logSecurity for magcluster 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for magcluster-1.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.