Aviary
How to use Aviary
Comprehensive metagenomics pipeline reference v0.13.0
πŸ”

No sections match your search.

Aviary

Comprehensive Snakemake-based metagenomics pipeline: assembly β†’ binning β†’ annotation β†’ dereplication. Supports short-read, long-read, and hybrid workflows. Each module runs independently or as a chained pipeline.

Authors
Cite: Newell et al. Aviary: Hybrid assembly and genome recovery from metagenomes. Zenodo, 2024. doi:10.5281/zenodo.15208119

01Installation

# Set conda channels first (required)
conda config --add channels defaults
conda config --add channels bioconda
conda config --add channels conda-forge

# Option A β€” Bioconda
conda create -n aviary -c bioconda aviary
# OR into an existing environment:
conda install -c bioconda aviary

# Option B β€” Pip
pip install aviary-genome

# Option C β€” Source with pixi (recommended for development)
git clone https://github.com/rhysnewell/aviary.git
cd aviary
pixi run postinstall     # installs all dependencies

# Editable install for development
pip install -e .

02Quick Reference β€” Subcommands

aviary --version            # show installed version
aviary --help               # top-level help
aviary <subcommand> --help  # help for a specific subcommand

03Required Databases

DatabaseToolSizeRequired?
GTDBGTDB-tk (taxonomy)~85 GBYes β€” for taxonomy in recover/annotate
EggNOGEggNOG-mapper~50 GBYes β€” for functional annotation
CheckM2CheckM2 (quality)~3 GBYes β€” for MAG QC
SingleMSingleM (profiling)~14 GBYes β€” for recovery assessment
MetabuliTaxVAMB binnervariesOptional β€” only for taxvamb binner

Use aviary configure --download to auto-install all databases.

Environment variable paths

export GTDBTK_DATA_PATH=/path/to/gtdb/db/
export EGGNOG_DATA_DIR=/path/to/eggnog/
export SINGLEM_METAPACKAGE_PATH=/path/to/singlem.smpkg/
export CHECKM2DB=/path/to/checkm2db/
export CONDA_ENV_PATH=/path/to/conda/envs/
Tip: Point GTDBTK_DATA_PATH to the db/ folder inside the GTDB download directory, not the download root itself.

04Configure

aviary configure \
  -o logs/ \
  --eggnog-db-path /path/to/eggnog/ \
  --gtdb-path /path/to/gtdb/ \
  --checkm2-db-path /path/to/checkm2/ \
  --singlem-metapackage-path /path/to/singlem/ \
  --metabuli-db-path /path/to/metabuli/ \   # optional, for taxvamb
  --download                                 # auto-download missing databases

# Set a persistent tmpdir
aviary configure --tmpdir /scratch/tmp/
FlagDescription
-oOutput / log directory
--eggnog-db-pathEggNOG functional annotation database path
--gtdb-pathGTDB taxonomy database path
--checkm2-db-pathCheckM2 quality assessment database path
--singlem-metapackage-pathSingleM marker gene database path
--metabuli-db-pathMetabuli database (optional; required for taxvamb)
--downloadAuto-download all missing databases
--tmpdirPersist a custom TMPDIR for all future runs

05Assemble

QC runs automatically before assembly unless --skip-qc is set.

# Short-read only (metaSPAdes by default)
aviary assemble -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ --n-cores 16

# Short-read with MEGAHIT (faster, lower memory)
aviary assemble -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ --n-cores 16 --use-megahit

# Long-read only (myloasm default)
aviary assemble -l sample.fastq.gz -z ont -o output_dir/ --n-cores 16

# Long-read with Flye
aviary assemble -l sample.fastq.gz -z ont --long-read-assembler flye -o output_dir/ --n-cores 16

# Hybrid (short + long reads)
aviary assemble -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -l sample.fastq.gz -z ont -o output_dir/ --n-cores 16

# Host contamination removal
aviary assemble -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -r host_genome.fasta -o output_dir/ --n-cores 16

# Co-assembly of multiple samples
aviary assemble -1 s1_R1.fq.gz s2_R1.fq.gz -2 s1_R2.fq.gz s2_R2.fq.gz --coassemble -o output_dir/ --n-cores 16

Read input flags

FlagDescription
-1 PATH ..Forward short reads
-2 PATH ..Reverse short reads
-i / --interleaved PATH ..Interleaved short read files
-c / --coupled PATH ..Coupled forward/reverse list
-l / --longreads PATH ..Nanopore or PacBio reads
-z / --longread-type TYPEont | ont_hq | rs | sq | ccs | hifi (default: ont)

Assembly flags

FlagDescriptionDefault
--long-read-assemblermyloasm | flyemyloasm
--use-megahitUse MEGAHIT instead of metaSPAdes for short readsoff
--use-unicyclerUse Unicycler for metaSPAdes reassemblyoff
--coassembleCo-assemble multiple input read setsoff
-k / --kmer-sizesKmer sizes for SPAdes (odd integers <128)auto

Contig filtering flags (applied post-assembly)

FlagDescriptionDefault
--min-cov-longMinimum long read coverage for contigs5
--min-cov-shortMinimum short read coverage for contigs5
--exclude-contig-covExclude contigs with coverage ≀ this value10
--exclude-contig-sizeExclude contigs shorter than this bp2500
--include-contig-sizeAlways include contigs longer than this bp10000

Expected outputs

assembly/
  final_contigs.fasta ← assembled contigs (use as --assembly for recover)
www/
  assembly_stats.txt ← assembly summary statistics
  rastqc/ ← RastQC short-read QC reports
  nanoplot/ ← NanoPlot long-read QC reports

06QC / Read Filtering Flags

Applies to assemble, recover, and complete. QC runs automatically β€” use these flags to tune or skip it.

FlagDescriptionDefault
--skip-qcSkip all QC stepsoff
-r / --host-filter PATH ..Host reference fasta(s) to remove host readsβ€”
--min-read-size INTMinimum long read size for Filtlong100
--min-mean-q FLOATMinimum long read mean quality10
--min-short-read-length INTMinimum short read length to keep15
--max-short-read-length INTMaximum short read length (0 = no max)0
--disable-adapter-trimmingDisable fastp adapter trimmingoff
--unqualified-percent-limit FLOATMax % bases allowed unqualified40
--quality-cutoff INTShort read quality threshold15
--extra-fastp-params STRExtra params passed to fastp as stringβ€”

07Recover β€” Extract MAGs

Default binners

BinnerTypeGPU?Notes
Rosellashort+longNoCoverM-based differential coverage binner (default lead binner)
MetaBAT2shortNoCoverage-based
MaxBin2shortNoCoverage + tetra-nucleotide frequency
CONCOCTshortNoGaussian mixture model
SemiBin2short+longYesDeep learning, self-supervised

DAS_Tool is always run to produce a final consensus bin set from all binner outputs.

# Short reads only
aviary recover --assembly assembly.fasta -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ --n-cores 16 --max-threads 32

# With long reads for coverage (improves binning)
aviary recover --assembly assembly.fasta -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -l sample.fastq.gz -z ont -o output_dir/ --n-cores 16

# GPU-accelerated binners (taxvamb, comebin, semibin)
aviary recover --assembly assembly.fasta -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ --n-cores 16 --request-gpu

# Add extra binners beyond defaults
aviary recover --assembly assembly.fasta -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ --n-cores 16 --extra-binners taxvamb comebin

# Skip specific binners
aviary recover --assembly assembly.fasta -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ --n-cores 16 --skip-binners concoct maxbin

# Binning only β€” skip annotation
aviary recover --assembly assembly.fasta -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ --n-cores 16 --binning-only

# Target a specific Snakemake rule
aviary recover --assembly assembly.fasta -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ -w rosella --max-threads 12

Recover flags

FlagDescriptionDefault
--assembly PATHInput assembled contigs (.fasta) β€” requiredβ€”
-1 / -2Short reads for coverage calculationβ€”
-l / --longreadsLong reads for coverage calculationβ€”
--request-gpuEnable GPU-accelerated binners (taxvamb, comebin, semibin)off
--binning-onlyStop after binning; skip quality check and annotationoff
--strictFail immediately if any binner errorsoff
--extra-binners LISTAdd extra binners: maxbin | concoct | comebin | taxvambβ€”
--skip-binners LISTSkip specific binners from the default setβ€”
--min-contig-size INTMinimum contig size for binning (bp)1500
--min-bin-size INTMinimum MAG size (bp)200000
--semibin-model NAMESemiBin2 environment modelglobal
--skip-abundancesSkip CoverM post-binning abundance calculationsoff
--skip-taxonomySkip GTDB-tk taxonomy assignmentoff
--skip-singlemSkip SingleM recovery assessmentoff
-w / --workflow RULETarget a specific Snakemake rule (all prerequisites still run)β€”

Expected outputs

bins/
  final_bins/ ← final consensus MAG FASTA files
  bin_info.tsv ← taxonomy, QC, size, N50 for all MAGs
  checkm_minimal.tsv ← minimal CheckM2 summary
  coverm_abundances.tsv ← CoverM relative abundance per MAG per sample
diversity/singlem_out/ ← SingleM read-based community profiling
taxonomy/ ← GTDB-tk raw output
benchmarks/ ← Snakemake rule benchmarks
logs/ ← Rule-level logs β€” check here first on errors

08Annotate

aviary annotate \
  -d recover/bins/final_bins/ \
  -o output_dir/ \
  --n-cores 16
FlagDescriptionDefault
-d / --genome-fasta-directoryDirectory containing MAG FASTA filesβ€”
-x / --fasta-extensionFile extension of MAG filesfna
Note: The default extension is .fna, not .fasta. If your bins have a different extension (e.g. .fa, .fasta), always set -x accordingly.

Expected outputs

annotation/
  eggnog/ ← EggNOG-mapper functional annotation output
  gtdbtk/ ← GTDB-tk taxonomic classification output

09Complete β€” Assemble + Recover + Annotate

Note: complete does NOT include cluster (dereplication). Run that separately after all samples.
# Short reads only
aviary complete -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ --n-cores 16

# Hybrid with myloasm (default)
aviary complete -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -l sample.fastq.gz -z ont -o output_dir/ --n-cores 16

# Hybrid with Flye
aviary complete -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -l sample.fastq.gz -z ont --long-read-assembler flye -o output_dir/ --n-cores 16

# With GPU binners
aviary complete -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -l sample.fastq.gz -z ont -o output_dir/ --n-cores 16 --request-gpu

# Preview the workflow without running
aviary complete -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ --dry-run

10Cluster β€” Dereplicate MAGs

Run this once, after all samples are processed, to dereplicate the combined MAG set.

aviary cluster \
  -i run1/ run2/ run3/ \
  -o cluster_output/ \
  --n-cores 16
FlagDescriptionDefault
-i / --input-runs PATH ..Space-separated previous Aviary output directoriesβ€”
--ani FLOATANI threshold for dereplication97
--precluster-ani FLOATMinimum ANI for preclustering95
--precluster-method NAMERough ANI method: dashing | finchdashing
--min-completeness FLOATExclude genomes below this completeness %β€”
--max-contamination FLOATExclude genomes above this contamination %β€”
--use-checkm2-scoresUse CheckM2 scores for representative selectionoff

Expected outputs

dereplicated_bins/ ← final dereplicated representative MAG FASTA files

11Batch β€” Multiple Samples

aviary batch \
  --batch-file samples.tsv \
  -o batch_output/ \
  --n-cores 16

The batch file is a TSV or CSV with one sample per row. Aviary will run each sample individually and then cluster the final output. See format example at https://rhysnewell.github.io/aviary/examples/example_batch.tsv.

12Diversity β€” Strain Analysis

aviary diversity \
  -d bins/final_bins/ \
  -1 sample_R1.fastq.gz \
  -2 sample_R2.fastq.gz \
  -o output_dir/ \
  --n-cores 16

Runs Lorikeet for strain-resolved variant calling and genotyping.

13Isolate β€” Single-Organism Assembly

Separate workflow from metagenomics β€” for isolated pure culture sequencing.

aviary isolate \
  -1 sample_R1.fastq.gz \
  -2 sample_R2.fastq.gz \
  -l sample.fastq.gz \
  -z ont \
  -o output_dir/ \
  --n-cores 16
FlagDescriptionDefault
--genome-sizeApproximate genome size in bp5000000
--guppy-modelGuppy model for Medaka polishingr941_min_high_g360

14Common Flags

These flags apply across most subcommands.

FlagDescriptionDefault
-n / --n-cores INTMax CPU cores (total for Snakemake)16
--max-threads INTMax threads for any single process8
-m / --max-memory INTMax memory in GB250
-p / --pplacer-threads INTThreads for pplacer (avoid high values β€” deadlock risk)8
-o / --output PATHOutput directory./
--request-gpuEnable GPU-accelerated steps (taxvamb, comebin, semibin)off
--dry-runShow workflow steps without executingoff
-w / --workflow RULETarget a specific Snakemake rule (all prerequisites still run)β€”
--snakemake-cmds STRExtra arguments passed directly to Snakemakeβ€”
--snakemake-profile NAME/PATHSnakemake cluster profile for HPC submissionβ€”
--local-cores INTMax cores for local-only steps16
--cluster-retries INTRetry failed cluster jobs N times (memory/time auto-scaled)0
--tmpdir PATHDirectory for temporary files/tmp
--cleanClean up temp files after runTrue
--rerun-triggers VALUEWhat triggers rule rerunsmtime

Thread control explained

  • -t / --threads β€” threads per program (how many each tool gets)
  • -n / --n-cores β€” total cores Snakemake can use; if > --threads, multiple rules run in parallel
  • -p / --pplacer-threads β€” pplacer gets its own limit (deadlocks on too many threads)

Unlock a directory after a crash

aviary complete -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ --snakemake-cmds '--unlock'

Resume an interrupted run

Snakemake automatically skips completed steps. Just re-run the exact same command.

15HPC / Cluster Job Submission

PBS / qsub (e.g. aqua cluster)

# Inline qsub submission β€” note the trailing space inside the quotes (argparse quirk)
aviary complete -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ --n-cores 16 \
  --snakemake-cmds '--cluster "qsub -V" '

# Using a named Snakemake profile
aviary complete -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ --n-cores 16 \
  --snakemake-profile aqua \
  --cluster-retries 2

Example PBS profile ~/.config/snakemake/aqua/config.yaml

cluster: qsub
cluster-status: qstat
jobs: 10000
cluster-cancel: qdel
PBS quirk: Add -V to your qsub command to pass environment variables to jobs. Without -V, pysam fails to activate properly in submitted jobs.

SLURM

aviary complete -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ --n-cores 16 \
  --snakemake-profile /path/to/slurm-profile/

Example SLURM wrapper script

#!/bin/bash
#SBATCH --job-name=aviary
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=16
#SBATCH --mem=64G
#SBATCH --time=48:00:00
#SBATCH --output=aviary_%j.log

conda activate aviary
aviary complete -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -o output_dir/ --n-cores 16
sbatch submit_aviary.sh

Cluster retry behaviour

With --cluster-retries N, failed jobs are automatically resubmitted up to N times. Each retry increases the requested memory and wall time. Set --max-memory and --max-threads to cap these values.

Note on job resources: Job CPU and memory requirements were empirically derived from 1,000 Aviary runs. Binner rules are standardised at 24 CPUs. Memory is set to the nearest power of 2 above max RSS. These are capped by --max-memory / --max-threads.

16Full Workflow Walkthrough

Step-by-step (maximum control)

# Step 1 β€” Configure databases (once per system)
aviary configure -o logs/ \
  --eggnog-db-path /path/to/db/eggnog/ \
  --gtdb-path /path/to/db/gtdb/ \
  --checkm2-db-path /path/to/db/checkm2/ \
  --singlem-metapackage-path /path/to/db/singlem/ \
  --download

# Step 2 β€” QC + Assembly
aviary assemble -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz -l sample.fastq.gz -z ont -o 01_assemble/ --n-cores 16

# Step 3 β€” MAG Recovery
aviary recover \
  --assembly 01_assemble/assembly/final_contigs.fasta \
  -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz \
  -l sample.fastq.gz -z ont \
  -o 02_recover/ --n-cores 16 --max-threads 32 --request-gpu

# Step 4 β€” Annotate MAGs
aviary annotate -d 02_recover/bins/final_bins/ -o 03_annotate/ --n-cores 16

# Step 5 β€” Dereplicate (after all samples are done)
aviary cluster -i 02_recover/ run2/ run3/ -o 04_cluster/ --n-cores 16

Single-command alternative (steps 2–4)

aviary complete \
  -1 sample_R1.fastq.gz -2 sample_R2.fastq.gz \
  -l sample.fastq.gz -z ont \
  -o output_dir/ --n-cores 16 --request-gpu

# Then run cluster (step 5) separately after all samples are done
aviary cluster -i output_dir/ run2/ run3/ -o cluster/ --n-cores 16

17Key Output Files

After assemble

output_dir/assembly/final_contigs.fasta ← use as --assembly in recover

After recover

output_dir/bins/final_bins/*.fna ← final MAG FASTA files (use downstream)
output_dir/bins/bin_info.tsv ← taxonomy, completeness, contamination, size, N50
output_dir/bins/checkm_minimal.tsv ← minimal CheckM2 QC summary
output_dir/bins/coverm_abundances.tsv ← relative abundance per MAG per sample
output_dir/diversity/singlem_out/ ← SingleM community profiling
output_dir/taxonomy/ ← raw GTDB-tk output
output_dir/benchmarks/ ← per-rule resource benchmarks
output_dir/logs/ ← per-rule logs β€” always check here first on errors

After annotate

output_dir/annotation/eggnog/ ← EggNOG-mapper functional annotation
output_dir/annotation/gtdbtk/ ← GTDB-tk taxonomic annotation

After cluster

output_dir/dereplicated_bins/ ← final dereplicated representative MAGs

18Debugging & Testing

Finding error messages

All log files are in output_dir/logs/. Each file is named after the rule that generated it.

# Example: SPAdes ran out of memory
cat output_dir/logs/run_spades.log

# List all log files
ls output_dir/logs/

run_tests_at_cmr β€” full expensive test suite

Must be run from a GPU interactive session. Start one with: mqinteractive gpu
# Recommended: submit via mqsub to control resources
mqsub -t 32 -m 250 --hours 12 pixi run run-tests-at-cmr

# OR: run directly (each test still submits its own job)
pixi run run-tests-at-cmr
  • β€’ Collects all @expensive and @qsub pytest tests
  • β€’ Submits each as a separate mqsub job (16 threads, 64 GB, 4 h)
  • β€’ GPU tests (taxvamb, comebin, semibin) are submitted with --A100
  • β€’ Waits for all jobs and reports failures

run_samples_at_cmr β€” benchmark across 9 real samples

pixi run -e dev postinstall                    # install dev environment
pixi run -e dev aviary build                   # build aviary in dev environment
pixi run -e dev python test/run_samples_at_cmr
  • β€’ Runs aviary recover --binning-only on 9 samples (Gut/Soil/Ocean) with both MEGAHIT and MetaSPAdes
  • β€’ Jobs dispatched via GNU parallel (-j 18) with aqua Snakemake profile
  • β€’ Output: timestamped directory per git commit under $PIXI_PROJECT_ROOT/aviary_test_samples/<COMMIT>/
  • β€’ Summary: {OUTPUT_DIR}/summary.tsv (columns: Env, Sample, Assembler, Score, Genomes)
  • β€’ Quality threshold: completeness βˆ’ (5 Γ— contamination) β‰₯ 50

Running tests locally

pixi run -e dev pytest test/                                       # standard tests only
pixi run -e dev pytest test/ --run-expensive                       # include expensive tests
pixi run -e dev pytest test/ --run-qsub                            # include qsub tests
pixi run -e dev pytest test/ --profile /path/to/snakemake-profile/ # use a cluster profile

19Tips, Gotchas & Common Errors

  • 01/tmp filling up is the most common error (Error in prepare_binning_files). CoverM mapping during binning uses /tmp. Fix: --tmpdir /scratch/tmp/ or aviary configure --tmpdir /scratch/tmp/.
  • 02SPAdes "Error code: -9" almost always means out of memory. Increase with -m (GB).
  • 03qsub + pysam ModuleNotFoundError: Add -V to your qsub command to pass environment variables: --snakemake-cmds '--cluster "qsub -V" '
  • 04Trailing space in --snakemake-cmds: The space after qsub in '--cluster qsub ' is required due to a Python argparse quirk.
  • 05--request-gpu on a local machine: First install the cuda package into your conda environment. GPU-capable programs will detect it automatically.
  • 06Resuming a run: Snakemake automatically skips completed rules. Just re-run the exact same command with the same -o output directory.
  • 07Default fasta extension for annotate is .fna, not .fasta. If your bins have a different extension, always specify -x.
  • 08aviary complete does NOT run cluster. You must always run aviary cluster separately after all samples have been processed.
  • 09--binning-only in recover skips CheckM2 QC and GTDB-tk β€” useful when you want fast MAG binning and plan to run aviary annotate separately.
  • 10--cluster-retries is highly recommended on HPC. Failed jobs are retried with progressively more memory and time, up to --max-memory / --max-threads caps.
  • 11Setting GTDB path: Point GTDBTK_DATA_PATH to the db/ folder inside the GTDB download directory, not the download root itself.
  • 12GPU binners require a GPU node. If using --request-gpu with a PBS/SLURM profile, ensure the profile is configured to submit GPU jobs to a GPU partition/queue.