Skip to content

Autocycler Tutorial

minaminii edited this page Oct 13, 2026 · 8 revisions

Applies to: NosoGraph v0.3.x (current: 0.3.0-rc.1). See the Changelog for what changed in each version.

--pipeline autocycler builds a consensus assembly from long reads with Autocycler (Ryan Wick). Instead of trusting one assembler, it assembles several read subsamples with several assemblers and keeps what they agree on. This page covers what it does, how to run it, and how to choose and configure the assembler stack.

It runs Autocycler's fully automated assembly path. The manual curation steps from Autocycler's wiki are not part of the pipeline.


When to use it

bacterial-assembly (default) autocycler
Assembly One assembler (Flye, Canu or Unicycler) Several assemblers × several subsamples, reconciled into one consensus
Polishing Racon, optional Pilon (short reads) None; consensus only
QC QUAST + CheckM2 (+ BLAST with --blast_db) QUAST always; CheckM2 with --checkm2_db; BLAST with --blast_db
Knowledge-graph export (kg/) Yes Yes (Assembly.assembler = autocycler)
Cost One assembly job assemblers × subsamples assembly jobs (12 by default)

Use Autocycler when contiguity and structural accuracy matter more than run time, for example closing a chromosome and its plasmids for a reference isolate. For routine, high-volume surveillance samples, bacterial-assembly is much cheaper.


How it works

flowchart TD
    LR([Long reads<br/>FASTQ]) --> GS{"--genome_size<br/>set?"}
    GS -- no --> EST["autocycler helper genome_size<br/>estimate from reads"]
    GS -- yes --> SUB
    EST --> SUB["autocycler subsample<br/>--subsample_count read subsets"]

    SUB --> A1["flye × each subsample"]
    SUB --> A2["miniasm × each subsample"]
    SUB --> A3["raven × each subsample"]

    A1 --> CMP["autocycler compress<br/>unitig graph of all assemblies"]
    A2 --> CMP
    A3 --> CMP

    CMP --> CL["autocycler cluster<br/>group contigs into genomic units"]
    CL --> TR["autocycler trim + resolve<br/>one job per cluster"]
    TR --> CB["autocycler combine"]
    CB --> OUT[("consensus_assembly<br/>.fasta + .gfa")]

    OUT --> QUAST["QUAST<br/>always"]
    OUT -.-> CM2["CheckM2<br/>with --checkm2_db"]
    OUT -.-> BLAST["BLAST<br/>with --blast_db"]
    OUT --> KG["kg_export.py<br/>Neo4j CSVs"]
    CM2 -.-> KG
    BLAST -.-> KG
    KG --> CSVS[("sample_id/assembly/autocycler/kg/<br/>Neo4j CSVs")]
Loading
Step Process What it does
1 AUTOCYCLER_EST_GENOMESIZE Runs only when --genome_size is not given. Estimates genome size from the reads.
2 AUTOCYCLER_SUBSAMPLE Splits the reads into --subsample_count independent subsets.
3 AUTOCYCLER_ASSEMBLE One job per (assembler, subsample) pair, all in parallel, via autocycler helper <assembler>.
4 AUTOCYCLER_COMPRESS Merges every assembly into one unitig graph.
5 AUTOCYCLER_CLUSTER Groups contigs into clusters, each a putative replicon (chromosome, plasmid). Only clusters that pass QC go on.
6 AUTOCYCLER_TRIM_RESOLVE Trims overlaps and resolves a consensus for each cluster, one job per cluster.
7 AUTOCYCLER_COMBINE Joins the resolved clusters into the final assembly.
8 ASSEMBLY_QC:QUAST Assembly statistics. Always runs; adds read-mapping stats from --long_reads and reference stats with --reference.
9 ASSEMBLY_QC:CHECKM2 Completeness and contamination. Only with --checkm2_db.
10 ASSEMBLY_QC:BLAST Best hit per contig, recorded as Contig.accession. Only with --blast_db.
11 KG_EXPORT Writes <outdir>/<sample_id>/assembly/<run_name>/kg/ CSVs, using CheckM2 and BLAST results when they ran.

Steps 8–10 are the processes of the assembly-qc-iden module, the same ones bacterial-assembly uses.

The number of step-6 jobs is only known at run time, because it depends on how many replicons Autocycler finds.


Quick start

1. Check the wiring (no tools, no data)

./nosograph assembly autocycler -stub-run -profile test \
    --sample_id S01 \
    --long_reads dummy.fastq.gz \
    --genome_size 5m \
    --outdir /tmp/nf_test_autocycler

Expect [SUCCESS] completed=20 failed=0 with the defaults: 12 AUTOCYCLER_ASSEMBLE jobs (3 assemblers × 4 subsamples), the other Autocycler steps, ASSEMBLY_QC:QUAST and KG_EXPORT. Add --checkm2_db x --blast_db y to see ASSEMBLY_QC:CHECKM2 and ASSEMBLY_QC:BLAST join (22 jobs).

2. Real run

./nosograph assembly autocycler -profile micromamba \
    --sample_id   BAC_S001 \
    --long_reads  /data/reads/BAC_S001_long.fastq.gz \
    --genome_size 5.5m \
    --threads     16 \
    --checkm2_db  /data/checkm2_db/CheckM2_database/uniref100.KO.1.dmnd \
    --outdir      results

Drop --checkm2_db to skip CheckM2; add --blast_db /data/blast/nt for per-contig identification.

These commands use the nosograph command from the repo root. ./nosograph assembly autocycler sets --pipeline autocycler and passes everything else to nextflow run. To choose the assemblers, list them after autocycler: ./nosograph assembly autocycler,flye,raven,canu ... is the same as --assemblers flye,raven,canu. The plain Nextflow form, nextflow run main.nf --pipeline autocycler ..., still works.

Always pass --threads. NosoGraph's global default is 1, which makes every assembly job single-threaded.

Outputs are per sample. Everything goes under <outdir>/<sample_id>/, so several samples can share one --outdir.

3. Try it on the Autocycler demo data

A small ONT dataset from the Autocycler authors (about 75 Mbp of reads, 242 kb genome):

curl -L -o autocycler-demo-dataset.tar \
  https://github.com/rrwick/Autocycler/releases/download/v0.1.0/autocycler-demo-dataset.tar
tar -xf autocycler-demo-dataset.tar          # -> reads.fastq.gz, truth.fasta

./nosograph assembly autocycler -profile micromamba \
    --sample_id demo --long_reads reads.fastq.gz \
    --genome_size 242000 --threads 16 --outdir results

The result, results/demo/assembly/autocycler/01_assembly/autocycler_out/consensus_assembly.fasta, should be a roughly 242 kb assembly you can compare against truth.fasta.


Parameters

Parameter Description Default
--pipeline autocycler; set for you by nosograph assembly autocycler bacterial-assembly
--sample_id Sample identifier; names the kg/ bundle and BLAST files, and namespaces contig IDs required
--run_name Names the run's folder, <outdir>/<sample_id>/assembly/<run_name>/, and its assembly and contig IDs. Set it to keep two Autocycler runs (e.g. different stacks) of one sample autocycler
--long_reads Long-read FASTQ (gzipped or plain) required
--genome_size e.g. 5.5m, 242000. If unset, it is estimated from the reads (an extra step). estimated
--assemblers Comma-separated assembler stack; see Choosing assemblers. With nosograph, name it after autocycler, instead. flye,miniasm,raven
--subsample_count Number of read subsamples 4
--threads Threads per job 1 (NosoGraph global)
--outdir Output directory; each sample goes in <outdir>/<sample_id>/ results
--checkm2_db CheckM2 database (uniref100.KO.1.dmnd); enables CheckM2 —
--blast_db BLAST nucleotide DB prefix; enables per-contig identification —
--reference Reference FASTA for QUAST reference-based stats —
--tech nanopore or pacbio; only picks QUAST's read-mapping flag nanopore
--container_registry / --container_tag Image location for -profile singularity ghcr.io/minaminii / latest
--singularity_binds Extra Singularity bind flags, e.g. -B /db empty

--assembler (singular), --read1/--read2 and the polishing parameters belong to bacterial-assembly and are ignored here.

Example config files

Rather than long command lines, you can keep settings in a config file and pass it with -c. Ready-to-copy examples are in example/nextflow-config/: a single workstation, SLURM, a canu stack with its own limits, a frozen conda env, and a pinned container image.

./nosograph assembly autocycler -profile micromamba \
    -c example/nextflow-config/autocycler-workstation.config \
    --sample_id BAC_S001 --long_reads /data/reads/BAC_S001.fastq.gz --outdir results

Plain nosograph assembly autocycler uses the assemblers set in the file; naming a stack on the command line (autocycler,flye,canu) overrides it. Choose the engine with -profile, and set a SLURM partition as process.queue in the file. Neither params.engine nor params.queue takes effect from a -c file.


Choosing assemblers

Autocycler's strength comes from diversity: assemblers that fail in different ways make the shared consensus more trustworthy. Total assembly jobs = number of assemblers × --subsample_count.

Available out of the box

These are installed in the pipeline's environment (conda env and container image):

Assembler Speed Notes
flye Medium Strong all-rounder; default.
miniasm Fast Overlap-layout only; the helper polishes it with Minipolish/Racon. Default.
raven Fast Default.
canu Slow Accurate and good at small plasmids, but much slower and memory-hungry. Needs a genome size (always passed by this pipeline).
plassembler Medium Plasmid-focused. Needs a Plassembler database the pipeline does not provide; see below.

Recommended stacks

Goal --assemblers Jobs at 4 subsamples
Fast, sensible default flye,miniasm,raven 12
Better plasmid recovery flye,miniasm,raven,canu 16
Closest to Autocycler's own automated script canu,flye,miniasm,raven,plassembler + the assemblers below 20+

With nosograph, put the stack after autocycler,, e.g. ./nosograph assembly autocycler,flye,miniasm,raven,canu ....

Assemblers Autocycler supports but this pipeline does not install

autocycler helper also supports metamdbg, necat, nextdenovo, hifiasm, lja, myloasm, redbean and ilesta. Autocycler's own fully automated script uses canu flye metamdbg miniasm necat nextdenovo plassembler raven.

To use one of these, it has to be added to the module's environment upstream in bioinformatics-workflows (containers/envs/autocycler.yaml) and pulled in with a vendor-bump. Do not edit modules/vendor/autocycler/ in NosoGraph; local edits are overwritten by the next bump.

Read type

Autocycler's helper assumes ONT R10 reads by default, and this pipeline does not currently pass --read_type. That is right for R10 and PacBio HiFi data. For ONT R9 or PacBio CLR, avoid hifiasm, lja, myloasm and metamdbg, which Autocycler warns may work poorly on lower-accuracy reads.

Plassembler database

autocycler helper plassembler looks for its database in $CONDA_PREFIX/plassembler_db or the path in $PLASSEMBLER_DB. The pipeline does not download or mount one, so adding plassembler without setting this up will fail. To try it (not yet tested with this pipeline):

  1. Download the database once with plassembler download -d /data/plassembler_db.
  2. export PLASSEMBLER_DB=/data/plassembler_db before running the pipeline.
  3. Under -profile singularity, also pass --singularity_binds "-B /data/plassembler_db".

Resources

Default per-job requests, from modules/vendor/autocycler/nextflow.config:

Jobs Label CPUs Memory Time
Assembly (each assembler × subsample) autocycler_assembly --threads 32 GB 24 h
Genome size, subsample, compress, cluster, trim/resolve, combine autocycler --threads 16 GB 4 h

Override them with your own config file rather than editing the vendored module (see also the example configs):

// my-resources.config
process {
    withLabel: 'autocycler_assembly' { memory = 16.GB; time = 8.h }
}
./nosograph assembly autocycler ... -c my-resources.config

On a single machine, the assembly jobs run in parallel up to the available CPUs, so 12 jobs × --threads 16 will queue rather than all start at once. Under -profile slurm, each job is submitted separately.


Execution environments

Profile How tools are provided Notes
micromamba Conda env solved on first run Much smaller download and disk use. The env is re-solved against current channels, so it can drift over time.
singularity (default) Frozen ghcr.io/minaminii/bioinf-autocycler image Reproducible, but the image is large (about 1.6 GB to download, more on disk once converted), mostly because of canu and plassembler dependencies.
test None For -stub-run wiring checks only.

On a machine with limited bandwidth or disk, -profile micromamba is the practical choice.

CPUs without AVX2 (older Xeons): the environment pins python=3.12, flye=2.9.5 and racon=1.4.20 because newer builds crash with Illegal instruction. Keep these pins on such hardware.


Outputs

<outdir>/
└── <sample_id>/
    └── assembly/
        └── autocycler/                        # --run_name (default: autocycler)
            ├── 01_assembly/
            │   ├── autocycler_out/
            │   │   ├── consensus_assembly.fasta   # final consensus assembly
            │   │   └── consensus_assembly.gfa     # same, as an assembly graph
            │   ├── assemblies/                    # <assembler>_<NN>.fasta, every input assembly
            │   └── subsampled_reads/
            │       └── subsampled_reads/          # sample_01.fastq … one per subsample
            ├── quast_results/                     # QUAST report (always)
            ├── checkm2_results/                   # quality_report.tsv (with --checkm2_db)
            ├── blast/                             # <sample_id>.contig_identification.tsv (with --blast_db)
            ├── versions/                          # tool versions for each QC step
            └── kg/                                # sample, assembly, biodata_files, contigs CSVs

Other assemblies of the same sample, e.g. nosograph assembly unicycler, land beside it in <sample_id>/assembly/unicycler/, so the consensus can be compared with a single-assembler run.

The intermediate Autocycler working directory (clusters, trimmed and resolved graphs) stays in Nextflow's work/ and is not published.

The kg/ bundle loads with the same Cypher templates as a bacterial-assembly run; see the Knowledge graph Tutorial. For Autocycler assemblies:

  • Assembly.assembler is autocycler; completeness and contamination are filled only when CheckM2 ran.
  • The assembly ID is <sample_id>_autocycler. Contigs are named 1, 2, … by Autocycler, so their IDs are <sample_id>:autocycler:1, <sample_id>:autocycler:2, … (with --run_name, that name replaces autocycler).
  • Contig.is_circular comes from Autocycler's circular=true/false FASTA header tags. Coverage is left blank, because the pipeline's autocycler combine step does not compute read depth.
  • Contig.accession is filled only when BLAST ran and found a hit.

Resume and re-running

./nosograph assembly autocycler ... -resume

With -resume and an intact work/, each (assembler, subsample) assembly is cached separately. Adding an assembler to the stack only runs the new assemblies, then redoes the cheaper compress → combine steps.

Reuse breaks if work/ is deleted, because subsampling is random and a fresh run draws different subsets, or if the environment or image changes.


Troubleshooting

Symptom Likely cause Fix
Illegal instruction (exit 132) Tool built for AVX2 on a CPU without it Keep the AVX2 pins; don't relax them on older hardware.
Flye fails with an AF_UNIX path too long socket error Long Nextflow work path used as $TMPDIR Already handled: the assembly steps set TMPDIR=/tmp. If it reappears, check that /tmp is writable inside the container.
plassembler jobs fail No Plassembler database See Plassembler database, or remove it from --assemblers.
Very slow run --threads left at 1, or canu in the stack Pass --threads; drop canu unless you need it.
Singularity pull takes very long or runs out of space Large bioinf-autocycler image Use -profile micromamba, or set NXF_SINGULARITY_CACHEDIR to a disk with room and pull once.
Missing required param: --sample_id --sample_id is required since QC and kg/ export were added Add --sample_id <name>.