# NextITS > A Nextflow pipeline for metabarcoding fungi and other eukaryotes with full-length ITS (PacBio) and short-read (Illumina) data. NextITS runs in two steps: Step1 processes each sequencing run separately, Step2 pools the Step1 results and clusters them into OTUs. An agent skill for NextITS is described on the AI agents page. # Getting started # NextITS A Nextflow pipeline for metabarcoding fungi and other eukaryotes with full-length ITS from PacBio (Illumina paired-end reads are also supported). Raw reads to a curated OTU table in two steps, with every tool in a container. [Get started]() [Installation]() [GitHub]() [Docker Hub]() [AI agents]() ![NextITS logo]() Long reads Full-length ITS from PacBio HiFi, as BAM or FASTQ, with symmetric, asymmetric or single barcodes. Homopolymer correction Fixes indels in homopolymer runs, the main error type in HiFi reads and common in fungal ITS. Tag-jump removal The UNCROSS2 algorithm removes cross-sample contamination within each sequencing run. Chimera detection Reference-based and *de novo* detection, with rescue of false positives that occur as non-chimeric sequences elsewhere. Denoising and clustering UNOISE, DADA2, SWARM, VSEARCH and taxon-aware OptimOTU, followed by LULU-style curation. Reproducible Docker, Podman, Singularity or Apptainer, from a laptop to HPC. Every run writes reports, a methods summary and software versions. ## How it works Step 1 · per sequencing run Quality control, demultiplexing, primer trimming, ITS extraction, homopolymer correction, chimera detection and tag-jump removal. [![NextITS workflow, Step-1]()]() Step 2 · across runs Pooling of Step-1 results from all runs, filtering, optional denoising, clustering into OTUs and curation of the OTU table. [![NextITS workflow, Step-2]()]() Tag switching happens within a sequencing run, so that is where it is removed. New runs can be added to a project without reprocessing the old ones. Click a figure to enlarge it. ## Citation Mikryukov V., Anslan S., Tedersoo L. NextITS: a pipeline for metabarcoding fungi and other eukaryotes with full-length ITS sequenced with PacBio. Zenodo. DOI: [10.5281/zenodo.15074881]() Please also cite the tools NextITS uses. They are listed, with references, in `pipeline_info/README_Step1_Methods.txt` and `README_Step2_Methods.txt` in your output folder. NextITS is released under the Apache-2.0 license. # Installation NextITS runs on Linux. On Windows, use the [Windows Subsystem for Linux (WSL)](). macOS works with Docker, but it is not tested regularly. You only need to install two things yourself: | Requirement | Version | | --- | --- | | [Nextflow]() (needs Java 17–26) | **26.04.0 or later** | | A container engine: [Docker](), [Podman](), [Singularity]() or [Apptainer]() | any recent version | Nextflow downloads the pipeline and its container image on the first run. Every bioinformatics tool the pipeline uses is inside that image. ## Nextflow Install Java with [SDKMAN!](), then Nextflow: ```bash curl -s https://get.sdkman.io | bash # open a new terminal, then: sdk install java 21-tem curl -s https://get.nextflow.io | bash chmod +x nextflow mkdir -p ~/bin && mv nextflow ~/bin/ ``` ```bash mamba create -n nextflow -c conda-forge -c bioconda nextflow mamba activate nextflow ``` Check the installation: ```bash nextflow -version ``` If you already have Nextflow, update it with `nextflow self-update`. For details, see the [Nextflow installation guide](). ## Container engine Pick one. Docker or Podman is usually the simplest choice on a workstation. On a shared HPC cluster, Singularity or Apptainer is usually the only one available. Select the engine at run time with `-profile docker`, `-profile podman`, `-profile singularity` or `-profile apptainer`. Follow the [Docker Engine installation guide]() for your distribution. Then let your user run Docker without `sudo`: ```bash sudo groupadd docker sudo usermod -aG docker $USER newgrp docker ``` Podman is available in the package repositories of most distributions: ```bash sudo apt install podman # Debian/Ubuntu ``` See the [Apptainer]() or [SingularityCE]() installation guides. On Ubuntu, Apptainer is available from a PPA: ```bash sudo add-apt-repository -y ppa:apptainer/ppa sudo apt update && sudo apt install -y apptainer ``` > [!TIP] > > **On an HPC cluster** > > The engine is usually installed as an environment module. Find and load it with: > > ```bash > module avail singularity apptainer > module load apptainer > ``` ### Container image All profiles use one image from Docker Hub, [`vmikk/nextits`](). Nextflow pulls it on the first run. Singularity and Apptainer convert it to a `.sif` file and cache it. On a cluster, put the cache on a shared file system so the image is converted only once: ```bash export NXF_SINGULARITY_CACHEDIR="/shared/path/singularity_cache" # -profile singularity export NXF_APPTAINER_CACHEDIR="/shared/path/apptainer_cache" # -profile apptainer ``` > [!NOTE] > > **Pull the image manually (e.g., for offline nodes)** > > ```bash > # Docker > docker pull vmikk/nextits:1.2.4 > > # Singularity / Apptainer > singularity pull nextits-1.2.4.sif docker://vmikk/nextits:1.2.4 > ``` > > To use a local `.sif` file, point Nextflow to it in a custom config (see [Configuring runs]()): > > ```groovy > // three slashes are required for an absolute path > process.container = 'file:///path/to/nextits-1.2.4.sif' > ``` > [!NOTE] > > **Build the image yourself** > > ```bash > git clone https://github.com/vmikk/NextITS > cd NextITS/containerfiles > > # Docker > docker build --tag nextits:local --file NextITS.dockerfile . > > # Singularity / Apptainer > singularity build --fakeroot nextits.sif NextITS.def > ``` ## Databases ### Chimera database Reference-based chimera detection (enabled by default) needs a database in VSEARCH's UDB format. We provide one built from [EUKARYOME]() v1.9.3: full-length ITS sequences of 100–800 bp, extracted with ITSx. [Download the database]() From the command line: ```bash wget -O Eukaryome_1.9.3_241222_FullITS_100-800.udb \ "https://owncloud.ut.ee/owncloud/public.php/dav/files/PkasGDNDimNssm3" ``` Pass the path to the file with `--chimera_db`. The default value is a bare file name, `Eukaryome_1.9.3_241222_FullITS_100-800.udb`, which Nextflow looks for in the directory you launch the pipeline from. Using an absolute path avoids surprises: ```bash --chimera_db "/path/to/Eukaryome_1.9.3_241222_FullITS_100-800.udb" ``` If you don't need reference-based chimera detection, use `--chimera_methods denovo` (or `none`, which disables chimera detection completely). ## Test the installation Run Step-1 on a small built-in dataset (replace `docker` with your engine): ```bash nextflow run vmikk/NextITS -r main -profile test,docker ``` Results are written to `NextITS_Test_Step1/`. Other test profiles: | Profile | What it tests | | --- | --- | | `test` (or `test1`) | Step-1, PacBio, multiplexed | | `test2` | Step-2 (UNOISE + VSEARCH) | > [!TIP] > > **Pin a version** > > `-r main` runs the latest code. For reproducible analyses, pin a release tag instead, (`-r `), and report it in your methods. List the available tags with `git ls-remote --tags https://github.com/vmikk/NextITS`. # Quick start This page assumes you have [installed]() Nextflow and a container engine, and downloaded the [chimera database](). The examples use Docker; swap `-profile docker` for `singularity`, `apptainer` or `podman` as needed. NextITS runs in two steps: 1. **Step-1** processes each sequencing run separately: QC, demultiplexing, ITS extraction, chimera detection and tag-jump removal. 2. **Step-2** pools the Step-1 results of all runs and clusters the sequences into OTUs. ## Step-1: process a sequencing run For a multiplexed PacBio run you need a FASTQ (or BAM) file, a FASTA file with sample barcodes, and the primer sequences: ```bash nextflow run vmikk/NextITS -r main \ -profile docker \ -resume \ --step Step1 \ --input "$(pwd)/Input/Run01/Run01.fastq.gz" \ --barcodes "$(pwd)/Input/Run01/Run01_barcodes.fasta" \ --primer_forward "TACACACCGCCCGTCG" \ --primer_reverse "CCTSCSCTTANTDATATGC" \ --chimera_db "/path/to/Eukaryome_1.9.3_241222_FullITS_100-800.udb" \ --outdir "Step1_Results/Run01" ``` Check your barcode file format and primer orientation in [Running the pipeline]() before the first run. To process several runs, repeat the command for each one with its own `--input`, `--barcodes` and `--outdir`. See [Processing many runs](<#processing-many-runs>) below for a script that does this. > [!TIP] > > **Check the data first** > > `--step seqstats` takes the same input options. It runs only QC, demultiplexing and the primer check, and writes a short HTML report. It gives you a quick look at a new run before the full analysis. ## Step-2: pool runs and cluster Point `--data_path` to the folder with all Step-1 results: ```bash nextflow run vmikk/NextITS -r main \ -profile docker \ -resume \ --step Step2 \ --data_path "$(pwd)/Step1_Results" \ --clustering vsearch \ --otu_id 0.98 \ --outdir "Step2_Results" ``` This clusters sequences at 98% similarity with VSEARCH, then curates the OTU table with LULU. The final tables are in `Step2_Results/05.LULU/`; see [Output files]() for the full output. Other clustering strategies only change the last few options: Single-linkage clustering with a local threshold, instead of a global one: ```bash --clustering swarm --swarm_d 1 ``` Denoise first, then cluster the denoised sequences: ```bash --preclustering unoise --clustering vsearch --otu_id 0.98 ``` Exact sequence variants without OTU clustering: ```bash --preclustering dada2 --clustering none ``` See [Denoising and clustering]() for how to choose. ## Processing many runs If your data are organised with one sub-directory per sequencing run, each holding one FASTQ file and one barcode file: ```text Input/ ├── Run01/ │ ├── Run01.fastq.gz │ └── Run01_barcodes.fasta ├── Run02/ │ ├── Run02.fastq.gz │ └── Run02_barcodes.fasta └── Run03/ ├── ... ``` then a small script can run Step-1 for each run. Each run is launched from its own directory (`Step1_WorkDirs/`), which holds that run's Nextflow cache and work files. This keeps `-resume` working per run and lets several runs execute in parallel. run\_step1.sh ```bash #!/bin/bash # Usage: ./run_step1.sh set -euo pipefail RUN="$1" BASEDIR="$(pwd)" mkdir -p "$BASEDIR"/Step1_WorkDirs/"$RUN" cd "$BASEDIR"/Step1_WorkDirs/"$RUN" nextflow run vmikk/NextITS -r main \ -profile docker \ -resume \ --step Step1 \ --input "$BASEDIR"/Input/"$RUN"/*.fastq.gz \ --barcodes "$BASEDIR"/Input/"$RUN"/*.fasta \ --primer_forward "TACACACCGCCCGTCG" \ --primer_reverse "CCTSCSCTTANTDATATGC" \ --chimera_db "/path/to/Eukaryome_1.9.3_241222_FullITS_100-800.udb" \ --outdir "$BASEDIR"/Step1_Results/"$RUN" \ | tee "$BASEDIR"/Nextflow_"$RUN".log ``` Run it for each sub-directory of `Input/`: ```bash chmod +x run_step1.sh for run in Input/*/; do ./run_step1.sh "$(basename "$run")" done ``` With [GNU parallel]() you can run several at once. Each Nextflow run already uses all available CPUs, so keep `-j` small: ```bash ls Input/ | parallel -j 2 ./run_step1.sh {} ``` Once a run has finished and you have checked its results, you can delete its `Step1_WorkDirs/` folder. Before you do, read the note on [storage mode](). ## Next steps - [Running the pipeline](): input formats, barcodes, primers and the choice of clustering method. - [Parameters](): every option with its default. - [Running on HPC](): Slurm and other schedulers. # User guide # Running the pipeline A typical NextITS command looks like this: ```bash nextflow run vmikk/NextITS -r main \ -profile docker \ -resume \ --step Step1 \ --input "pacbio_ccs.fastq.gz" \ --barcodes "sample_barcodes.fasta" \ --primer_forward "TACACACCGCCCGTCG" \ --primer_reverse "CCTSCSCTTANTDATATGC" \ --chimera_db "Eukaryome_1.9.3_241222_FullITS_100-800.udb" \ --outdir "Step1_Results/Run01" ``` Options with **one dash** (`-profile`, `-resume`, `-work-dir`) belong to Nextflow. Options with **two dashes** (`--input`, `--step`, …) are pipeline [parameters](). ## Pipeline steps `--step` selects what to run: | `--step` | Input | What it does | | --- | --- | --- | | `Step1` (default) | Raw reads of one sequencing run | QC, demultiplexing, primer trimming, ITS extraction, homopolymer correction, chimera detection, tag-jump removal | | `Step2` | Step-1 results of one or more runs | Pooling, filtering, optional denoising, clustering, LULU curation | | `seqstats` | Same as `Step1` | QC, demultiplexing and primer check only, with a summary report. Use it for a quick look at a new run. | ### Workflow overview ``` flowchart TD A[Raw reads
FASTQ / BAM] --> B[Quality filtering
VSEARCH, max EE, homopolymers] B --> C[Demultiplexing
lima · cutadapt for Illumina] C --> D[Primer check & reorientation
cutadapt] D --> E[Primer trimming & dereplication] E -.->|--long_chimera| F[Long-chimera removal
Infernal] E --> G[ITS extraction
ITSx / ITSx2] F -.-> G G --> H[Homopolymer correction] H --> I[Chimera detection
reference + de novo, with rescue] I --> J[Tag-jump removal
UNCROSS2] J --> K[(Sequence table
Seqs.parquet)] ``` ``` flowchart TD A[(Step-1 tables
of all runs)] --> B[Pooling & filtering
de novo chimeras, length] B --> C[Dereplication] C -.->|--chunking_n| D[Split into chunks
MMseqs2] C --> E[Denoising / pre-clustering
UNOISE · DADA2 · SWARM d1] D -.-> E E --> F[Clustering
VSEARCH · SWARM · OptimOTU] F --> G[OTU table
low-quality singleton filtering] G --> H[Post-clustering curation
LULU] H --> I[(OTU table + sequences
rRNA parts)] ``` Dashed arrows mark optional steps that are off by default. Most steps can be switched off, e.g. `--hp false`, `--chimera_methods none`, `--tj false`, `--lulu false`. ### Where results are stored Nextflow runs every task in a sub-folder of the work directory (`work/` by default, or the path given by `-work-dir`). By default (`--storagemode rellink`), the files in `--outdir` are relative links to files in `work/`. This saves disk space, but **deleting `work/` breaks the results**. If you plan to delete the work directory, run with `--storagemode copy`, or copy the results with dereferenced links first: ```bash cp -rL Step1_Results Step1_Results_copy ``` `-resume` reuses the results of tasks that have not changed, so add it every time. After a crash or a parameter change, only the affected steps run again. ## Input data One file with all reads of a sequencing run and a FASTA file with the sample barcodes: ```bash --input "Run01.fastq.gz" \ --barcodes "Run01_barcodes.fasta" ``` `--input` can also be an unaligned BAM file (e.g., `Run01.hifi_reads.bam`). The PacBio index (`Run01.hifi_reads.bam.pbi`) must be in the same folder. If your reads are already split by sample, point `--input` to a folder of per-sample files and skip `--barcodes`: ```bash --demultiplexed true \ --input "/path/to/demultiplexed_reads/" ``` Files must end in `.fastq.gz`, `.fastq`, `.fq.gz` or `.fq`. The sample name is the file name up to the **first dot**, so `Run01__S1.fastq.gz` becomes `Run01__S1`. Don't use dots elsewhere in file names. > [!WARNING] > > **Experimental** > > Illumina support is new and its parameters may change between releases. Multiplexed reads, with tags on the reads: ```bash --seqplatform Illumina \ --input_R1 "Run01_R1.fastq.gz" \ --input_R2 "Run01_R2.fastq.gz" \ --barcodes "Run01_barcodes.fasta" \ --illumina_barcodetype dual_symmetric ``` Reads already split by sample: ```bash --seqplatform Illumina \ --demultiplexed true \ --input "/path/to/demultiplexed_reads/" \ --illumina_pe_pattern "*_R{1,2}*.{fastq,fq}.gz" ``` For per-sample files, the sample name is taken from the file name. Illumina suffixes such as `_S1_L001` are removed, and names with dots are rejected. Read pairs are reoriented, then merged with USEARCH (`--pe_merger usearch`, default) or VSEARCH. USEARCH is not included in the current container (`vmikk/nextits:1.2.4`), so use `--pe_merger vsearch` with it. **Quality presets.** Use a profile that matches your instrument's quality scores. These presets set the QC and merging thresholds: | Profile | Instruments | Quality scores | | --- | --- | --- | | `-profile miseq,docker` | MiSeq and other four-colour chemistry | continuous | | `-profile novaseq,docker` | NovaSeq, NextSeq and other two-colour chemistry | binned; poly-G tails trimmed | **Unmerged pairs.** By default, read pairs that don't overlap are discarded. `--illumina_keep_notmerged true` joins them with a run of `N`s instead. It requires `--its_region none` and `--hp false`. See the [Illumina parameters]() for tag search and merging settings. ### Barcodes Sample barcodes (also called tags or indices) are given in a FASTA file. The sequence name is the sample name: ```text >Run01__Sample_01 ACAACACTCCGA >Run01__Sample_02 ACAAGTGCTGCT >Run01__PosControl ACACAGTCCTGA ``` For dual barcodes that differ between the two ends, write both barcodes separated by `...`. Give both in the **same orientation, 5′ → 3′**, as they were ordered: ```text >Run01__Sample_01 ACAACACTCCGA...TGCTAGCTAGCT >Run01__Sample_02 ACAAGTGCTGCT...GCATGCATGCAT ``` Set the barcoding scheme with `--lima_barcodetype` (PacBio) or `--illumina_barcodetype` (Illumina): | Scheme | Description | | --- | --- | | `dual_symmetric` (default) | Same barcode at both ends | | `dual_asymmetric` | Different barcodes at the two ends (`FWD...REV` format) | | `dual` | A mix of symmetric and asymmetric pairs (PacBio only) | | `single` | Barcode at one end only | For PacBio data, the barcode score threshold (`--lima_minscore`, default 93) assumes 12-bp barcodes. For shorter barcodes, lower it; see the [lima FAQ](). **Sample names.** We recommend `RunID__SampleID`, with a **double underscore** between the run and sample parts. With this convention, you can trace every sequence back to its sequencing run. It is also what lets `--merge_replicates` pool a sample that was sequenced in several runs. Before demultiplexing, NextITS checks the barcode file and cleans up sample names: - Non-ASCII letters are transliterated (`ö` → `o`). - Any character that is not a letter or digit (including `-`, `.` and spaces) is replaced with `_`. - Repeated underscores are collapsed, except for the first `__`. - Duplicated names get a numeric suffix (`_1`, `_2`). Renamed samples are listed in `01_Demux/tag_names_renamed.tsv`. To keep the names you expect, use only letters, digits and `_`. > [!WARNING] > > **Barcodes must be unique** > > Two samples with the same barcode (or barcode combination) stop the pipeline with an error. For asymmetric pairs, `A...B` and `B...A` count as the same combination. ### Primers ```bash --primer_forward "TACACACCGCCCGTCG" \ --primer_reverse "CCTSCSCTTANTDATATGC" ``` - Write both primers **5′ → 3′**, as ordered (do not reverse-complement the reverse primer). - IUPAC ambiguity codes (`N`, `S`, `D`, …) are allowed. - Reads may come in either orientation. After the primer check, all reads are turned to the forward-primer orientation. - Reads without both primers are discarded. Reads with extra primer copies inside (multi-primer artefacts) are removed. The defaults are the universal eukaryote primers ITS9mun (`TACACACCGCCCGTCG`) and ITS4ngsUni (`CCTSCSCTTANTDATATGC`) ([Tedersoo & Lindahl 2016]()). To exclude plant sequences, the ITS1catta forward primer (`ACCWGCGGARGGATCATTA`) is a good alternative ([Tedersoo & Anslan 2019]()). It sits at the very end of the SSU, so ITSx often can't find the SSU boundary; use `--its_region ITS1_5.8S_ITS2` with it. > [!TIP] > > **Low ITSx yield?** > > Because reads are already oriented by the primers, ITSx (v1.x) only searches the forward strand by default (`--ITSx_complement F`). If many reads have no ITS detected (see `03_ITSx/_no_detections.txt`), try `--ITSx_complement T`. Alternatively, use `--itsx_tool ITSx2`, which is faster and covers all eukaryotes. ## Denoising and clustering Step-2 can denoise sequences, cluster them, or do both. You choose with two parameters: - `--preclustering` (default `none`): denoising or pre-clustering applied first. Options: `unoise`, `dada2`, `swarm_d1`, `homopolymer`. - `--clustering` (default `vsearch`): OTU clustering. Options: `vsearch`, `swarm`, `optimotu`, `none`. | Method | Options | When to use | | --- | --- | --- | | VSEARCH | `--clustering vsearch --otu_id 0.98` | Classic OTUs at a fixed similarity threshold. A robust default. | | SWARM | `--clustering swarm --swarm_d 1` | Clusters built by single-linkage of close neighbours, with no global threshold | | UNOISE | `--preclustering unoise` | Denoising into zero-radius OTUs (zOTUs); combine with `--clustering vsearch` or `none` | | DADA2 | `--preclustering dada2` | Error-model-based ASVs; the PAPA2 engine (`--dada2_engine papa2`) is the default | | SWARM d1 | `--preclustering swarm_d1` | Fast lossless pre-clustering to shrink large datasets before OptimOTU or VSEARCH | | None | `--preclustering none --clustering none` | Dereplicated sequences only (LULU must be disabled with `--lulu false`) | > [!NOTE] > > **UNOISE and homopolymers** > > UNOISE was designed for Illumina reads. On PacBio data, homopolymer-length differences look like real variants to it, so keep homopolymer correction on in Step-1 (`--hp true`, the default) when using UNOISE. **Large datasets.** `--chunking_n 10` splits the sequences into 10 chunks of similar sequences with MMseqs2, and clusters each chunk separately. This reduces memory use and run time. Sequences more similar than `--chunking_id` (default 0.9) always end up in the same chunk. **Post-clustering curation.** By default, NextITS merges OTUs that look like errors of a more abundant, co-occurring OTU with the LULU algorithm ([Frøslev et al. 2017]()), using the [MUMU]() implementation. The default similarity threshold (`--lulu_match 97`) is stricter than the original LULU default (84%), which suits full-length ITS. ## Configuring runs ### Parameter files Instead of a long command line, you can keep parameters in a YAML (or JSON) file: params\_step2.yml ```yaml step: "Step2" data_path: "/path/to/Step1_Results" outdir: "Step2_Results" preclustering: "unoise" clustering: "vsearch" otu_id: 0.97 lulu: true ``` ```bash nextflow run vmikk/NextITS -r main -profile docker -resume -params-file params_step2.yml ``` Use the parameter's type in the file: numbers without quotes, `true`/`false` for switches, and quoted strings. Command-line options override values from the file. See the [Nextflow docs]() for details. ### Built-in help ```bash nextflow run vmikk/NextITS --help # main parameters nextflow run vmikk/NextITS --help chimera_db # one parameter nextflow run vmikk/NextITS --helpFull # all parameters nextflow run vmikk/NextITS --version ``` Parameter values are checked before the run starts. A misspelled parameter name produces a warning. ### Process resources Every step has default CPU and memory settings. To change them, write a small config file and pass it with `-c`: custom.config ```groovy process { withName: 'S1:ITS_EXTRACTION:itsx' { cpus = 16 memory = 16.GB } withName: 'S2:CLUSTERING:cluster_vsearch' { cpus = 32 } } ``` ```bash nextflow run vmikk/NextITS -r main -profile docker -c custom.config ... ``` Process names are listed in `pipeline_info/execution_trace_*.txt`. For cluster setups, see [Running on HPC](). # Output files All paths are relative to `--outdir`. `` stands for a sample name. Some folders appear only when the step that creates them is enabled; this is noted in the tables. > [!WARNING] > > **Results are links by default** > > With the default `--storagemode rellink`, files in `--outdir` are links into Nextflow's `work/` directory. See [Where results are stored]() before deleting `work/`. ## Step-1 > [!TIP] > > **Start here** > > - `08_RunSummary/Step1_report.html`: interactive report with read counts at every step, per sample and per run > - `07_SeqTable/Seqs.parquet`: the final sequence table, which is the input to Step-2 > [!NOTE] > > **Folder structure** > > ```text > Step1_Results/Run01/ > ├── 00_BAM2FASTQ/ # BAM input only > ├── 01_Demux/ > ├── 02_PrimerCheck/ > ├── 03_ITSx/ # or 03_PrimerTrim/ with --its_region none > ├── 03_ITSx_PooledParts/ > ├── 03_LongChimera/ # --long_chimera true only > ├── 04_Homopolymer/ > ├── 05_Chimera/ > ├── 06_TagJumpFiltration/ > ├── 07_SeqTable/ > ├── 08_RunSummary/ > ├── 09_DB/ > └── pipeline_info/ > ``` | Folder | Contents | | --- | --- | | `00_BAM2FASTQ/` | Reads converted from BAM to FASTQ (BAM input only) | | `01_Demux/` | **PacBio:** per-sample reads (`LIMA/.fq.gz`) and lima reports (`lima.lima.summary`, `.counts`, `.report.gz`). `tag_names_renamed.tsv` appears if sample names were changed.
**Illumina:** per-sample read pairs (`Demux/`), merged reads (`Merged/`), and tables with demultiplexing, reorientation and merging statistics | | `02_PrimerCheck/` | Reads with both primers, reoriented (`_PrimerChecked.fq.gz`), and multi-primer artefacts (`_PrimerArtefacts.fq.gz`) | | `03_ITSx/` | Dereplicated, primer-trimmed reads (`_derep.fasta.gz`) and the extracted regions: `.full.fasta.gz`, `.ITS1.`, `.5_8S.`, `.ITS2.`, `.SSU.`, `.LSU.`. Also ITSx summaries and positions, and `_no_detections.txt`. Sequence IDs are SHA1 hashes of the sequences. | | `03_PrimerTrim/` | Replaces `03_ITSx/` with `--its_region none`: primer-trimmed, dereplicated reads | | `03_ITSx_PooledParts/` | `rRNA_parts.parquet`: the rRNA regions (SSU, ITS1, 5.8S, ITS2, LSU, full ITS) of every unique sequence in the run. Step-2 uses it to export the parts of OTU representatives. | | `03_LongChimera/` | Removed long chimeras (`_LongChimera.fa.gz`) and their rRNA hits (`.tsv.gz`) | | `04_Homopolymer/` | Homopolymer-corrected sequences per sample and their cluster membership (`.uc.gz`) | | `05_Chimera/` | Per sample: non-chimeric (`_NoChimera.fa.gz`), reference-based chimeras (`_Chimera.fa.gz`), rescued chimeras (`_RescuedChimera.fa.gz`), and *de novo* chimera scores (`_DeNovoChim.txt`) | | `06_TagJumpFiltration/` | Sequence table after tag-jump removal (`Seq_tab_TagJumpFiltered.txt.gz`), UNCROSS scores (`TagJump_scores.qs`) and a diagnostic plot (`TagJump_plot.pdf`) | | `07_SeqTable/` | **Final Step-1 table:** `Seqs.parquet`, the same data as a long tab-separated table (`Seqs.txt.gz`), and all sequences in FASTA (`Seqs.fa.gz`) | | `08_RunSummary/` | `Step1_report.html`, `Run_summary.xlsx`, `per_sample.tsv`, `per_run.tsv`, read counts after each process (`PerProcessStats/`), and MultiQC-compatible tables (`MultiQC/`) | | `09_DB/` | `SeqQualities.parquet`: sequences and quality scores of all reads. Step-2 uses it to export full-length sequences of OTU representatives. | | `pipeline_info/` | See [below](<#pipeline_info>) | **Sequence table columns.** Each row of `07_SeqTable/Seqs.parquet` is one unique sequence in one sample: | Column | Description | | --- | --- | | `SampleID` | Sample name | | `SeqID` | SHA1 hash of the sequence | | `Abundance` | Number of reads | | `SeqLen` | Sequence length | | `PhredScore`, `MaxEE`, `MEEP` | Quality of the representative read: average Phred score, expected number of errors, and expected errors as a percentage of length | | `DeNovo_Chimera`, `DeNovo_Chimera_Score` | *De novo* chimera flag and score. These sequences are removed in Step-2 (`--max_ChimeraScore`). | | `Sequence` | The sequence | ## Step-2 > [!TIP] > > **Start here** > > - `06.Report/Step2_report.html`: summary of filtering and clustering > - `05.LULU/OTU_table_LULU.txt.gz` and `05.LULU/OTUs_LULU.fa.gz`: the final OTU table and OTU sequences, after LULU curation > - `04.PooledResults/`: the same before LULU (and the final results when `--lulu false`) > [!NOTE] > > **Folder structure** > > ```text > Step2_Results/ > ├── 01.Dereplicated/ > ├── 02.UNOISE/ # --preclustering unoise > ├── 02.DADA2/ # --preclustering dada2 > ├── 02.Preclustered_SWARM_d1/ # --preclustering swarm_d1 > ├── 02.Homopolymer/ # --preclustering homopolymer > ├── 03.Clustered_VSEARCH/ # --clustering vsearch > ├── 03.Clustered_SWARM/ # --clustering swarm > ├── 03.Clustered_OptimOTU/ # --clustering optimotu > ├── 04.PooledResults/ > │ └── rRNA_parts/ > ├── 05.LULU/ # --lulu true > │ └── rRNA_parts/ > ├── 06.Report/ > └── pipeline_info/ > ``` | Folder | Contents | | --- | --- | | `01.Dereplicated/` | Unique sequences pooled across all runs (`Dereplicated.fa.gz`) and their membership (`Dereplicated.uc.gz`) | | `02.*/` | Output of the denoising or pre-clustering step: representative sequences (`.fa.gz`) and membership (`.uc.gz`). DADA2 also writes `DADA2_denoising_summary.txt`. | | `03.Clustered_*/` | OTU representatives (`Clustered.fa.gz` or `SWARM_representatives.fa.gz`) and membership (`.uc.gz`). OptimOTU also writes `OptimOTU_otu_taxonomy.tsv.gz`. | | `04.PooledResults/` | OTU table in long (`OTU_table_long.txt.gz`) and wide (`OTU_table_wide.txt.gz`) format, the same tables as R objects (`.RData`), OTU sequences (`OTUs.fa.gz`), and the membership of every sequence (`UC_Pooled.parquet`) | | `04.PooledResults/rRNA_parts/` | OTU representatives split into rRNA regions: `SSU.fa.gz`, `ITS1.fa.gz`, `5_8S.fa.gz`, `ITS2.fa.gz`, `LSU.fa.gz`, `ITS_Full.fa.gz`, plus the full sequence (`OTUs_FullSeq.fa.gz`), a table (`rRNA_parts.parquet`) and a summary. Created when `--rrna_parts true`. | | `05.LULU/` | OTU table after LULU, in wide format (`OTU_table_LULU.txt.gz`), OTU sequences (`OTUs_LULU.fa.gz`), which OTUs were merged (`LULU_merging_statistics.txt.gz`), and the match list used (`LULU_match_list.txt.gz`). `rRNA_parts/` holds the region files for the curated OTUs. | | `06.Report/` | `Step2_report.html`, `Step2_summary.tsv`, and MultiQC-compatible tables | | `pipeline_info/` | See [below](<#pipeline_info>) | **OTU tables.** The long table has three columns: `OTU`, `SampleID`, `Abundance`. The wide table has one row per OTU and one column per sample. The `.RData` files are gzip-compressed RDS files, despite the extension; the wide one holds a sparse matrix. ```r otu_long <- readRDS("04.PooledResults/OTU_table_long.RData") # data.table otu_wide <- readRDS("04.PooledResults/OTU_table_wide.RData") # sparse matrix # Step-1 sequence table library(arrow) seqs <- read_parquet("Step1_Results/Run01/07_SeqTable/Seqs.parquet") ``` ```python import pandas as pd otu = pd.read_csv("05.LULU/OTU_table_LULU.txt.gz", sep="\t") seqs = pd.read_parquet("Step1_Results/Run01/07_SeqTable/Seqs.parquet") ``` ```sql SELECT SampleID, COUNT(*) AS n_seqs, SUM(Abundance) AS n_reads FROM 'Step1_Results/*/07_SeqTable/Seqs.parquet' GROUP BY SampleID; ``` ## seqstats `--step seqstats` writes the same `00_BAM2FASTQ/`, `01_Demux/` and `02_PrimerCheck/` folders as Step-1, plus: | Folder | Contents | | --- | --- | | `03_Stats/` | `Seqstats_report.html`, `Run_summary.xlsx`, `per_sample.tsv`, `per_run.tsv` and read counts per process (`PerProcessStats/`) | ## pipeline\_info Every step writes a `pipeline_info/` folder (set a different location with `--tracedir`). Unlike the other outputs, these are regular files, not links. | File | Contents | | --- | --- | | `README_Step1_Methods.txt` / `README_Step2_Methods.txt` | Methods description of the run, with the tools used and their references. A starting point for the methods section of a paper. | | `software_versions.yml` | Versions of all tools used | | `pipeline_params.tsv` | All parameter values. Step-2 reads this file from each Step-1 run. | | `execution_command.txt` | The exact command used | | `execution_report_.html` | Nextflow report: run time, CPU and memory use per process | | `execution_timeline_.html` | Timeline of all tasks | | `execution_trace_.txt` | One line per task, with resources used | | `pipeline_dag_.svg` | Graph of the workflow | # Running on HPC Nextflow supports most HPC schedulers, including [Slurm](), PBS/Torque, SGE and LSF, so NextITS runs on a university cluster without changes to the pipeline. This page uses Slurm in its examples. If you don't know which scheduler your cluster uses, ask your HPC support team. Most clusters provide Singularity or Apptainer rather than Docker, so use `-profile singularity` or `-profile apptainer`. Set the image cache to a shared folder, so the image is downloaded and converted only once: ```bash export NXF_SINGULARITY_CACHEDIR="$HOME/singularity_cache" # or NXF_APPTAINER_CACHEDIR ``` ## Two ways to run **Single job.** You request one node (or part of one) and run the whole pipeline inside that job. Nextflow runs all tasks locally on the allocated CPUs. This is the simplest setup and works well for most datasets. **Scheduler mode.** Nextflow runs as a small, long-lived job and submits each task as a separate Slurm job with its own resources. Use it for very large datasets, or when a single node is not enough. The run takes longer when the queue is busy. > [!NOTE] > > **Further reading** > > [Best practices for deploying pipelines with HPC workload managers]() on the Nextflow blog. ## Single job Request the resources in the batch script, and tell Nextflow not to give any single task more than that. Nextflow's `resourceLimits` does this: limits.config ```groovy process.resourceLimits = [ cpus: 32, memory: 128.GB, time: 48.h ] ``` nextits\_step1.sh ```bash #!/bin/bash #SBATCH --job-name=NextITS_S1 #SBATCH --cpus-per-task=32 #SBATCH --mem=128G #SBATCH --time=48:00:00 module load apptainer # if needed; name depends on your cluster export NXF_APPTAINER_CACHEDIR="$HOME/apptainer_cache" export NXF_OPTS="-Xms1g -Xmx4g" # memory for Nextflow itself nextflow run vmikk/NextITS -r main \ -profile apptainer \ -c limits.config \ -resume \ --step Step1 \ --input "$PWD/Input/Run01/Run01.fastq.gz" \ --barcodes "$PWD/Input/Run01/Run01_barcodes.fasta" \ --chimera_db "$PWD/DB/Eukaryome_1.9.3_241222_FullITS_100-800.udb" \ --outdir "$PWD/Step1_Results/Run01" ``` ```bash sbatch nextits_step1.sh ``` > [!TIP] > > **The `hpc` profile** > > The default settings suit a workstation. On a large node, `-profile hpc,apptainer` gives the heavy steps (demultiplexing, ITS extraction, clustering) more CPUs. Combine it with `limits.config` so that no task asks for more than your allocation. ## Scheduler mode Create a config file that sets the executor and the resources of individual processes. The values below are a starting point; adjust them to your data and your cluster's limits. slurm.config ```groovy executor { name = 'slurm' queueSize = 100 // max jobs in the queue at once submitRateLimit = '10 sec' // be gentle with the scheduler } process { clusterOptions = '--partition=main' // partition, account, etc. // defaults for all processes cpus = 1 memory = 4.GB time = 4.h // retry tasks that ran out of memory or time errorStrategy = { task.exitStatus in [137,140,143] ? 'retry' : 'finish' } maxRetries = 2 // heavy steps withName: '(S1|seqstats):demux' { cpus = 12; memory = 8.GB } withName: 'S1:ITS_EXTRACTION:itsx' { cpus = 16; memory = 16.GB } withName: 'S1:CHIMERA_REMOVAL:chimera_ref' { cpus = 8; memory = 8.GB } withName: 'S2:dereplication' { cpus = 8; memory = 32.GB } withName: 'S2:CLUSTERING:cluster_vsearch' { cpus = 32; memory = 64.GB; time = 24.h } withName: 'S2:CLUSTERING:cluster_swarm' { cpus = 32; memory = 64.GB; time = 24.h } withName: 'S2:lulu' { cpus = 16; memory = 32.GB } } ``` Then start Nextflow itself as a small, long-running job: ```bash sbatch --cpus-per-task=2 --mem=8G --time=7-00:00:00 --wrap \ "nextflow run vmikk/NextITS -r main -profile apptainer -c slurm.config -resume --step Step2 --data_path $PWD/Step1_Results --outdir $PWD/Step2_Results" ``` The work directory (`-work-dir`, default `./work`) must be on a file system that all compute nodes can access. `-profile hpc_utslurm` is the configuration we use on the University of Tartu cluster. You can use [its config file]() as a template: it lists resources for every process. ## Choosing resources - **Run a pilot.** Process a few typical samples first, then look at `pipeline_info/execution_report_*.html`. It shows the CPU, memory and time each process actually used. - **Heavy steps.** ITS extraction (ITSx) takes most of the time in Step-1. In Step-2, clustering and dereplication of large pooled datasets need the most memory. - **Large Step-2 datasets.** Use `--chunking_n` to split the data and cluster the chunks in parallel. Each task then needs less memory. - **Don't over-request.** Asking for more than the job needs makes it wait longer in the queue and takes resources from other users. - **Clean up.** The work directory can grow large. Once you have the results, copy them (see [Where results are stored]()) and delete `work/`. # Reference # Parameters Set parameters on the command line with two dashes (`--its_region full`) or collect them in a [parameter file]() passed with `-params-file`. To print the description of a parameter from the pipeline itself, use `--help `. Each section below follows the order of the pipeline. A dash (–) in the Default column means the parameter is not set by default. ## General | Parameter | Default | Description | | --- | --- | --- | | `--step` | `Step1` | Part of the pipeline to run: `Step1`, `Step2` or `seqstats` | | `--outdir` | `results` | Output directory | | `--tracedir` | `/pipeline_info` | Directory for execution reports | | `--storagemode` | `rellink` | How results are placed in `--outdir` 1 | | `--gzip_compression` | `7` | GZIP compression level of output files, `1` (fastest) to `9` (smallest) | | `--max_cpus` | `80` | Upper limit of CPUs for a single task 2 | | `--max_memory` | `132.GB` | Upper limit of memory for a single task 2 | | `--max_time` | `240.h` | Upper limit of run time for a single task 2 | | `--validate_params` | `true` | Check parameter values before the run starts | | `--monochrome_logs` | `false` | Disable coloured terminal output | | `--help` | – | Show help; `--help ` shows help for one parameter | | `--helpFull` | `false` | Show help for all parameters | | `--showHidden` | `false` | Include hidden parameters in the help | | `--helpMsg` | `false` | Show the older plain-text help message | | `--version` | `false` | Print the pipeline version and exit | 1: `rellink` creates relative links into the work directory, `symlink` absolute links, `link` hard links; `copy` copies files and `move` moves them (`move` breaks `-resume`). With any link mode, results depend on the work directory; see [Where results are stored](). 2: Used by the `hpc_utslurm` profile to cap per-task resources. In your own configs, use Nextflow's [`process.resourceLimits`]() instead (see [Running on HPC]()). ## Step-1 ### Input | Parameter | Default | Description | | --- | --- | --- | | `--input` | – | Multiplexed reads as one FASTQ or BAM file, or a folder of per-sample FASTQ files (with `--demultiplexed true`) | | `--barcodes` | – | FASTA file with sample barcodes. Required for multiplexed input. | | `--demultiplexed` | `false` | Set to `true` if `--input` is a folder of per-sample files | | `--seqplatform` | `PacBio` | Sequencing platform: `PacBio` or `Illumina` | See [Input data]() for formats and naming rules. ### Quality filtering | Parameter | Default | Description | | --- | --- | --- | | `--qc_maxee` | – | Maximum number of expected errors per read | | `--qc_maxeerate` | `0.01` | Maximum expected errors per base | | `--qc_maxhomopolymerlen` | `25` | Remove reads with a homopolymer of this length or longer | | `--qc_maxn` | `4` | Maximum number of ambiguous bases (`N`) per read | Expected errors are computed from Phred scores ([Edgar & Flyvbjerg 2015]()). The homopolymer filter targets technical artefacts only: real fungal ITS often contains homopolymers longer than 10 bases ([Tedersoo et al. 2022]()). ### Demultiplexing (PacBio) Demultiplexing of PacBio reads is done with [lima](). | Parameter | Default | Description | | --- | --- | --- | | `--lima_barcodetype` | `dual_symmetric` | Barcoding scheme: `dual_symmetric`, `dual_asymmetric`, `dual` (mixed) or `single` | | `--lima_minscore` | `93` | Minimum barcode score (0–100) 1 | | `--lima_minendscore` | `50` | Minimum score of the second barcode (asymmetric and mixed schemes) | | `--lima_minrefspan` | `0.75` | Minimum fraction of the barcode covered by the read | | `--lima_minscoringregions` | `2` | Number of barcodes that must be found in dual schemes (`2` = both) | | `--lima_windowsize` | `70` | Window at the read ends to search for barcodes, bp | | `--lima_minlen` | `40` | Minimum read length after barcode removal | | `--lima_remove_unknown` | `false` | Discard reads with barcode combinations not listed in `--barcodes`. If `false`, they are kept as separate samples named after the barcodes. | 1: The score measures how well a barcode aligns to the read. The default suits 12-bp barcodes; lower it for shorter barcodes. See the [lima FAQ on barcode scores](). ### Illumina paired-end (experimental) > [!WARNING] > > **Experimental** > > These parameters apply with `--seqplatform Illumina` and may change between releases. The `-profile miseq` and `-profile novaseq` presets set suitable QC and merging values. | Parameter | Default | Description | | --- | --- | --- | | `--input_R1` | – | Multiplexed R1 reads (FASTQ.gz) | | `--input_R2` | – | Multiplexed R2 reads (FASTQ.gz) | | `--illumina_pe_pattern` | `*_R{1,2}*.{fastq,fq}.gz` | File pattern of per-sample read pairs in the `--input` folder (with `--demultiplexed true`) | | `--illumina_barcodetype` | `dual_symmetric` | Tag layout: `dual_symmetric` (same tag on both reads), `dual_asymmetric` (different tags, `FWD...REV` format) or `single` | | `--illumina_revtag_orient` | `auto` | Orientation of the reverse tag in the barcode file: `auto` (detected from the data), `forward` or `revcomp` | | `--illumina_demux_rescue` | `false` | Rescue read pairs where only one tag can be read (only for tags used by a single sample) | | `--barcode_window` | `30` | Search window for tags at the 5′ end of reads (`0` = tag must start the read) | | `--barcode_errors` | `2` | Maximum mismatches in a tag | | `--barcode_overlap` | `11` | Minimum overlap between read and tag | | `--barcode_minlen` | `50` | Minimum read length after tag removal | | `--pe_merger` | `usearch` | Tool for merging read pairs: `usearch` or `vsearch`. Use `vsearch` with the `vmikk/nextits:1.2.4` image, which does not include USEARCH. | | `--pe_maxdiffs` | `10` | Maximum mismatches in the overlap | | `--pe_pctid` | `80` | Minimum percent identity in the overlap | | `--pe_minoverlap` | `16` | Minimum overlap length | | `--pe_minlen` | `50` | Minimum length of a merged read | | `--pe_maxlen` | – | Maximum length of a merged read | | `--qc_polyglen` | `10` | Trim 3′ poly-G tails at least this long before merging (two-colour chemistry); `0` = no trimming | | `--qc_binned` | – | Expected quality score type (binned or not). Set by the presets; used only to warn about a mismatch with the data. | | `--illumina_keep_notmerged` | `false` | Join read pairs that can't be merged, with an `N` spacer. Requires `--its_region none` and `--hp false`. | | `--illumina_joinpadgap` | `NNNNNNNNNN` | Spacer sequence for joined pairs | | `--illumina_joinpadqual` | `IIIIIIIIII` | Quality string of the spacer | | `--trim_minlen` | `10` | Minimum sequence length after primer trimming (applies to all platforms) | ### Primers | Parameter | Default | Description | | --- | --- | --- | | `--primer_forward` | `TACACACCGCCCGTCG` | Forward primer, 5′ → 3′ (ITS9mun) | | `--primer_reverse` | `CCTSCSCTTANTDATATGC` | Reverse primer, 5′ → 3′ (ITS4ngsUni) | | `--primer_mismatches` | `2` | Maximum mismatches in a primer | | `--primer_foverlap` | primer length − 2 | Minimum overlap with the forward primer | | `--primer_roverlap` | primer length − 2 | Minimum overlap with the reverse primer | See [Primers]() for orientation rules and alternative primers. ### ITS extraction | Parameter | Default | Description | | --- | --- | --- | | `--its_region` | `full` | Region to extract: `full`, `ITS1`, `ITS2`, `ITS1_5.8S_ITS2`, `SSU`, `LSU` or `none` | | `--itsx_tool` | `ITSx` | Extraction tool: `ITSx` (v1.x, HMMER) or `ITSx2` (Infernal; faster, covers all eukaryotes) | | `--ITSx_tax` | `all` | Taxonomic profiles to use (ITSx 1.x only) 1 | | `--ITSx_evalue` | `0.1` | E-value cutoff (ITSx 1.x only) | | `--ITSx_partial` | `0` | Keep partial sequences at least this long; `0` = off (ITSx 1.x only) | | `--ITSx_complement` | `F` | Search both strands (`T`) or only the forward strand (`F`) (ITSx 1.x only) 2 | | `--ITSx_heuristics` | `false` | Use HMM filtering heuristics (ITSx 1.x only) | | `--ITSx_chunk_size` | `9999` | Unique sequences per extraction task; `0` = one task per sample | | `--ITSx_to_parquet` | `true` | Collect the extracted regions of all samples into `03_ITSx_PooledParts/rRNA_parts.parquet`. Needed for `--rrna_parts` in Step-2. | The conserved SSU and LSU flanks don't separate species, so random errors in them inflate the number of OTUs. They are also where chimera breakpoints are hard to detect ([Lindahl et al. 2013](), [Tedersoo et al. 2022]()). NextITS therefore extracts the ITS with ITSx ([Bengtsson-Palme et al. 2013]()) before clustering. | `--its_region` | Result | | --- | --- | | `full` | Full-length ITS (ITS1–5.8S–ITS2) as detected by ITSx | | `ITS1_5.8S_ITS2` | Full ITS assembled from the separately detected ITS1, 5.8S and ITS2. Use it when ITSx can't find the SSU end, e.g. with the ITS1catta primer. | | `ITS1`, `ITS2` | One spacer only | | `SSU`, `LSU` | The flanking 18S or 28S fragment | | `none` | No extraction; primers are trimmed only | 1: A comma-separated list (no spaces) of lowercase group names, or `all` (e.g., `--ITSx_tax fungi` or `--ITSx_tax fungi,metazoa`). Accepted names: `alveolata`, `amoebozoa`, `bacillariophyta`, `bryophyta`, `chlorophyta`, `euglenozoa`, `eustigmatophyceae`, `fungi`, `haptophyceae`, `marchantiophyta`, `metazoa`, `oomycota`, `parabasalia`, `phaeophyceae`, `raphidophyceae`, `rhizaria`, `rhodophyta`, `synurophyceae`, `tracheophyta`. 2: Reads are already oriented by the primers, so one strand is enough. If ITSx detects the ITS in few reads, try `T`. ### Long-chimera removal | Parameter | Default | Description | | --- | --- | --- | | `--long_chimera` | `false` | Remove sequences with rRNA genes in both orientations (inverted chimeras) or repeated rRNA regions (e.g., two copies of 5.8S). Runs after primer trimming. | | `--long_chimera_minbits` | `50` | Minimum bit score of an rRNA hit | | `--long_chimera_mincov` | `0.4` | Minimum fraction of the rRNA model covered by a hit | ### Homopolymer correction | Parameter | Default | Description | | --- | --- | --- | | `--hp` | `true` | Correct homopolymer errors | | `--hp_similarity` | `0.999` | Similarity threshold for clustering homopolymer-compressed sequences (0.8–1) | | `--hp_iddef` | `2` | Sequence identity definition (VSEARCH `--iddef`, 0–4) | PacBio HiFi reads are accurate, but most of their remaining errors are extra or missing bases in homopolymers, which are common in fungal ITS. These errors inflate the number of OTUs and slow down clustering. NextITS compresses homopolymers, clusters sequences that become identical, and keeps the most abundant original variant within each sample. [![Homopolymer correction]()]() Homopolymer correction (n = number of reads) ### Chimera detection | Parameter | Default | Description | | --- | --- | --- | | `--chimera_methods` | `ref,denovo` | Methods to use: `ref`, `denovo`, `ref,denovo` or `none` | | `--chimera_db` | `Eukaryome_1.9.3_241222_FullITS_100-800.udb` | Reference database in UDB format ([download]()) | | `--chimera_rescueoccurrence` | `2` | Rescue a reference-based chimera if it is found as non-chimeric in at least this many samples | | `--chimeranov_abskew` | `2.0` | *De novo* detection: `abskew` | | `--chimeranov_dn` | `1.4` | *De novo* detection: `dn` | | `--chimeranov_mindiffs` | `3` | *De novo* detection: `mindiffs` | | `--chimeranov_mindiv` | `0.8` | *De novo* detection: `mindiv` | | `--chimeranov_minh` | `0.28` | *De novo* detection: `minh` | | `--chimeranov_xn` | `8.0` | *De novo* detection: `xn` | - **Reference-based** detection (VSEARCH `uchime_ref`) removes chimeras. A sequence flagged as chimeric is rescued if it occurs as non-chimeric in other samples, because a real sequence is more likely than a repeated chimera. - **De novo** detection (VSEARCH `uchime_denovo`) only scores sequences in Step-1. Filtering by score happens in Step-2 (`--max_ChimeraScore`), where data from all runs are available to recover false positives. ### Tag-jump removal | Parameter | Default | Description | | --- | --- | --- | | `--tj` | `true` | Remove tag-jumps | | `--tj_f` | `0.01` | UNCROSS parameter `f`: expected rate of tag-jumps | | `--tj_p` | `1` | Power `p` in the UNCROSS score; values below 1 (e.g., `0.5`) make the score curve steeper | | `--tj_id` | `1` | Similarity for grouping sequences before scoring; `1` = identical sequences only, below `1` = pre-cluster at this similarity | | `--tj_iddef` | `2` | Sequence identity definition for pre-clustering (0–4) | Tag-jumps (also called index switching or cross-talk) assign reads to the wrong sample. Usually 0.01–0.1% of reads are affected ([Tedersoo et al. 2022]()). NextITS scores each occurrence with the [UNCROSS2]() algorithm ([Edgar 2018]()) and removes those likely to be tag-jumps. ## Step-2 ### Input and filtering | Parameter | Default | Description | | --- | --- | --- | | `--data_path` | `Step1_Results` | Folder with Step-1 results: one run, or a parent folder with one sub-folder per run | | `--merge_replicates` | `false` | Pool samples with the same `SampleID` across runs (requires `RunID__SampleID` names) | | `--max_ChimeraScore` | `0.6` | Remove sequences with a *de novo* chimera score above this value | | `--recover_denovochimeras` | `true` | Keep a *de novo* chimera if it occurs as non-chimeric in other samples | | `--max_MEEP` | `0.5` | Maximum expected errors per 100 bp for singletons 1 | | `--recover_lowqsingletons` | `true` | Keep a low-quality singleton if the same sequence occurs in other samples | | `--ampliconlen_min` | – | Minimum sequence length | | `--ampliconlen_max` | – | Maximum sequence length | 1: MEEP is the expected number of errors as a percentage of sequence length; 0.5 corresponds to an average Phred score of about 23. Singletons with a higher MEEP are removed, unless rescued by `--recover_lowqsingletons`. ### Chunking | Parameter | Default | Description | | --- | --- | --- | | `--chunking_n` | – | Split the data into this many chunks of similar sequences (with MMseqs2) and process them in parallel; `2` or more enables it | | `--chunking_id` | `0.9` | Sequences at least this similar are placed in the same chunk | ### Denoising and pre-clustering | Parameter | Default | Description | | --- | --- | --- | | `--preclustering` | `none` | Method applied before clustering: `none`, `unoise`, `dada2`, `swarm_d1` or `homopolymer` | See [Denoising and clustering]() for how to choose a method. **UNOISE** ([Edgar 2016]()). A rare sequence that is very similar to an abundant one is treated as its error. | Parameter | Default | Description | | --- | --- | --- | | `--unoise_alpha` | `6.0` | Alpha parameter: how strongly abundance must differ for a similar sequence to be treated as an error | | `--unoise_minsize` | `1` | Minimum total abundance of a sequence | UNOISE was developed for Illumina reads. On PacBio data, use it only with homopolymer correction enabled in Step-1 (`--hp true`), otherwise indels in homopolymers are kept as real variants (see the [USEARCH manual]()). **DADA2** ([Callahan et al. 2016]()). Learns an error model from the data and infers exact sequence variants. | Parameter | Default | Description | | --- | --- | --- | | `--dada2_engine` | `papa2` | Implementation: `papa2` (Python reimplementation) or `dada2` (original R package) | | `--dada2_error_estimation` | `shared` | With chunking: learn one error model from a subset of all chunks (`shared`) or one per chunk (`per_bucket`) | | `--dada2_nbases` | `5e8` | Number of bases used to learn the error model | | `--dada2_minsize` | `2` | Minimum abundance for denoising. Rarer sequences (and those with ambiguous bases) are mapped to the resulting ASVs afterwards. | | `--dada2_mapback_id` | `0.99` | Minimum similarity for mapping excluded sequences to ASVs | | `--dada2_mapback_unmapped` | `keep` | Excluded sequences that match no ASV: `keep` or `discard` | | `--dada2_bandsize` | `16` | Band size for alignment | | `--dada2_detectsingletons` | `true` | Allow ASVs supported by a single read | | `--dada2_omegaA` | `1e-20` | P-value threshold for forming a new ASV | | `--dada2_omegaC` | `1e-40` | P-value threshold for correcting a read | | `--dada2_omegaP` | `1e-4` | P-value threshold for prior-based ASVs | | `--dada2_maxconsist` | `10` | Maximum iterations of the self-consistency loop | | `--dada2_match` | `4` | Alignment match score | | `--dada2_mismatch` | `-5` | Alignment mismatch penalty | | `--dada2_gappenalty` | `-8` | Alignment gap penalty | ### Clustering | Parameter | Default | Description | | --- | --- | --- | | `--clustering` | `vsearch` | Clustering method: `vsearch`, `swarm`, `optimotu` or `none` | **VSEARCH** ([Rognes et al. 2016]()). Greedy clustering at a fixed similarity threshold. | Parameter | Default | Description | | --- | --- | --- | | `--otu_id` | `0.98` | Similarity threshold | | `--otu_iddef` | `2` | Sequence identity definition (1–4); also used by UNOISE and DADA2 map-back | | `--otu_qmask` | `dust` | Masking of low-complexity regions | | `--vsearch_gapopen` | `20I/2E` | Gap opening penalties | | `--vsearch_gapext` | `2I/1E` | Gap extension penalties | **SWARM** ([Mahé et al. 2022]()). Clusters grow by linking sequences that differ by at most `d` positions, with no global threshold. | Parameter | Default | Description | | --- | --- | --- | | `--swarm_d` | `1` | Maximum number of differences between linked sequences | | `--swarm_fastidious` | `true` | Attach small clusters to large ones nearby (only with `d = 1`) | | `--swarm_d1boundary` | `3` | Minimum abundance of a "large" cluster in fastidious mode | ### Post-clustering curation (LULU) | Parameter | Default | Description | | --- | --- | --- | | `--lulu` | `true` | Run post-clustering curation | | `--lulu_match` | `97.0` | Minimum similarity (%) between an OTU and its potential parent | | `--lulu_ratio` | `1.0` | Minimum abundance ratio between parent and daughter OTU | | `--lulu_ratiotype` | `min` | Abundance ratio type: `min` or `avg` | | `--lulu_relcooc` | `0.95` | Fraction of the daughter's samples in which the parent must also occur | | `--lulu_maxhits` | `0` | Maximum number of potential parents to consider; `0` = unlimited | LULU ([Frøslev et al. 2017]()) merges an OTU into a more abundant, similar OTU that occurs in nearly all of the same samples. Such an OTU is most likely an error variant of that parent. NextITS uses [MUMU](), a fast C++ implementation of LULU. The default `--lulu_match` of 97% is stricter than the 84% of the original LULU. ### rRNA parts | Parameter | Default | Description | | --- | --- | --- | | `--rrna_parts` | `true` | Export the rRNA regions (SSU, ITS1, 5.8S, ITS2, LSU) and full-length sequences of OTU representatives. Requires `--ITSx_to_parquet true` in Step-1. | # AI agents # AI agents If you use an AI agent such as Claude Code to set up your analyses, give it the NextITS skill. A skill is a short instruction file that the agent reads when a task needs it. The NextITS skill tells the agent how the pipeline is organised, which questions to ask you before a run (barcodes, primers, platform), and the mistakes that most often lead to a failed or wrong run. For parameters and defaults it points the agent to this documentation, so it stays up to date with the pipeline. ## Install the skill For all your projects: ```bash mkdir -p ~/.claude/skills/nextits curl -fsSL -o ~/.claude/skills/nextits/SKILL.md \ https://raw.githubusercontent.com/Next-ITS/nextits.github.io/main/docs/agents/nextits/SKILL.md ``` For one project only, use `.claude/skills/nextits/` in the project folder instead. Claude Code picks up the skill in the next session; check with `/skills`. The skill follows the [Agent Skills]() format, which many coding agents support. Save `SKILL.md` as `nextits/SKILL.md` in the skills folder named in your agent's documentation. If your assistant does not support skills, attach `SKILL.md` to the conversation or paste its text at the start of the chat. To update the skill, download it again. ## Documentation for agents The documentation is also published as plain Markdown, which agents read more reliably than web pages: - [`llms.txt`](): an index of all pages with links to their Markdown versions - [`llms-full.txt`](): all pages in one file - The **Copy as Markdown** button at the top of each page copies that page for pasting into a chat. ## Example requests With the skill installed, you can describe the task in your own words, for example: - *Set up NextITS Step-1 for the three PacBio runs in `Input/`. Barcodes are dual asymmetric.* - *Write a Slurm script that runs Step-2 on `Step1_Results/` with UNOISE and VSEARCH at 98%.* - *Step-1 of Run02 failed. Find out why.* - *Draft the methods section from the NextITS output in `Step2_Results/`.* > [!WARNING] > > **Check before you run** > > Read the commands the agent proposes before running them, especially jobs that use a lot of cluster time and commands that delete files. Results in `--outdir` are links into the `work/` directory by default, so deleting `work/` breaks them (see [Where results are stored]()). ## The skill > [!NOTE] > > **SKILL.md** > > ````markdown > --- > name: nextits > description: >- > Set up, run, troubleshoot and interpret the NextITS Nextflow pipeline for metabarcoding of fungi > and other eukaryotes (full-length ITS from PacBio HiFi, and Illumina paired-end ITS). > Use this skill whenever the user mentions NextITS, or wants to process ITS or rRNA amplicon reads > into an OTU/ASV table with Nextflow: demultiplexing with sample barcodes, primer trimming, ITSx, > chimera or tag-jump removal, VSEARCH/SWARM/UNOISE/DADA2/OptimOTU clustering, LULU curation, > running on Slurm/HPC, reading Step1/Step2 output folders, debugging a failed NextITS run, > or writing a methods section for such an analysis. Use it even if NextITS is not named but the task > is PacBio ITS metabarcoding. > --- > > # NextITS > > NextITS is a Nextflow pipeline (`vmikk/NextITS`) that turns raw amplicon reads into a curated OTU table. > All tools run inside a container; the user only needs Nextflow and Docker, Podman, Singularity or Apptainer. > > It runs in two steps: > > - **Step1** runs once per sequencing run: QC, demultiplexing, primer check, ITS extraction, > homopolymer correction, chimera detection, tag-jump removal. Output: a sequence table per run. > - **Step2** pools the Step1 results of one or more runs: filtering, optional denoising, clustering, > LULU curation. Output: OTU table and sequences. > - `--step seqstats` takes the same inputs as Step1 and runs only QC, demultiplexing and the primer check. > It is a quick check of a new run. > > Tag jumps happen within a sequencing run, so Step1 must process each run separately. Do not merge > FASTQ files of different runs before Step1. > > ## Where the facts are > > This skill holds the workflow and the common mistakes. It does not list parameters or defaults, > because they change between releases. Look them up instead of relying on memory: > > - Documentation as Markdown: (index) and > (all pages in one file). Individual pages: > [installation](https://next-its.github.io/installation/index.md), > [quick start](https://next-its.github.io/quickstart/index.md), > [running the pipeline](https://next-its.github.io/usage/index.md), > [parameters](https://next-its.github.io/parameters/index.md), > [output files](https://next-its.github.io/output/index.md), > [HPC](https://next-its.github.io/HPC/index.md). > - Built-in help: `nextflow run vmikk/NextITS --help `, `--helpFull` for all parameters. > - Changes between versions: . > > Check every parameter name you write in a command or params file against `--help` or the parameters page. > A misspelled parameter only produces a warning, and the run then uses the default. > If this skill disagrees with the docs or `--help`, the docs and `--help` are correct. > > ## Setting up a run > > 1. **Ask the user for the facts only they know.** Do not guess them; a wrong guess runs for hours and > produces a plausible but wrong table. > - Platform (PacBio or Illumina) and whether reads are multiplexed or already split by sample. > - Barcode file and barcoding scheme (symmetric, asymmetric, mixed, single). > - Primer sequences and the amplified region (full ITS, ITS1-5.8S-ITS2 without SSU, longer rRNA amplicon). > - Where it runs: workstation or HPC cluster, and which container engine is available. > 2. **Check prerequisites:** `nextflow -version` (the version required is on the installation page) > and the container engine. On a new installation, run `-profile test,` first. > 3. **Check a new run with `--step seqstats`** if the user is unsure about barcodes or primers. > Its report shows how many reads were demultiplexed and passed the primer check. > 4. **Run Step1 once per sequencing run**, each with its own `--outdir` and its own launch directory > (so `-resume` and the `work/` cache are kept per run). The quick start page has a script for many runs. > 5. **Run Step2** with `--data_path` set to the folder that contains all Step1 output folders. > 6. For reproducibility, put parameters in a YAML file (`-params-file params.yml`; numbers unquoted, > `true`/`false` for switches) and pin a release with `-r ` instead of `-r main`. > > Skeletons (replace the angle brackets; use absolute paths): > > ```bash > nextflow run vmikk/NextITS -r -profile -resume \ > --step Step1 \ > --input \ > --barcodes \ > --primer_forward --primer_reverse \ > --chimera_db \ > --outdir > > nextflow run vmikk/NextITS -r -profile -resume \ > --step Step2 \ > --data_path \ > --clustering vsearch --otu_id 0.98 \ > --outdir > ``` > > ## Common mistakes > > - **One dash vs two.** `-profile`, `-resume`, `-c`, `-work-dir`, `-params-file` are Nextflow options; > `--step`, `--input` and the rest are pipeline parameters. > - **Deleting `work/` breaks the results.** By default (`--storagemode rellink`) files in `--outdir` > are links into `work/`. Before deleting `work/`, copy results with `cp -rL`, or run with > `--storagemode copy`. Warn the user before any cleanup of `work/`. > - **Barcode file.** FASTA; the sequence name is the sample name. Asymmetric pairs are written > `FWD...REV`, both 5'→3' as ordered. Barcodes must be unique (`A...B` and `B...A` count as the same). > Name samples `RunID__SampleID` (double underscore), with letters, digits and `_` only; > other characters are replaced and the renames are listed in `01_Demux/tag_names_renamed.tsv`. > - **Pre-demultiplexed input** (`--demultiplexed true`): the sample name is the file name up to the first dot. > - **Primers** are written 5'→3' as ordered. Do not reverse-complement the reverse primer. > With a forward primer at the very end of SSU (e.g. ITS1catta), use `--its_region ITS1_5.8S_ITS2`. > - **Chimera database.** Reference-based chimera detection needs the UDB file from the installation page. > Pass an absolute path to `--chimera_db`; a bare file name is looked up in the launch directory. > Without the database, use `--chimera_methods denovo`. > - **Few reads with ITS detected** (`03_ITSx/_no_detections.txt`): try `--ITSx_complement T` > or `--itsx_tool ITSx2`. > - **Step2 combinations.** `--preclustering none --clustering none` needs `--lulu false`. > UNOISE on PacBio data needs homopolymer correction in Step1 (`--hp true`, the default). > OptimOTU needs full ITS from Step1, a reference set under `--db_dir`, and a CPU with AVX2. > - **Illumina support is experimental**; read the Illumina section of the usage page before use. > - **HPC.** Use `-profile singularity` or `apptainer` and set `NXF_SINGULARITY_CACHEDIR` or > `NXF_APPTAINER_CACHEDIR` to a shared folder. Choose between one batch job and Nextflow's Slurm > executor as described on the HPC page. Do not submit large jobs without the user's approval. > > ## Choosing a clustering method > > VSEARCH at a fixed threshold (`--clustering vsearch --otu_id 0.98`) followed by LULU is a robust default. > For other options (SWARM, UNOISE, DADA2 ASVs, OptimOTU, chunking of large datasets with `--chunking_n`), > read the "Denoising and clustering" section of the usage page and explain the trade-off to the user > before choosing. > > ## Results and failures > > - Step1: start with `08_RunSummary/Step1_report.html` (read counts per step and sample); > the final table is `07_SeqTable/Seqs.parquet`. > - Step2: start with `06.Report/Step2_report.html`; final OTU table and sequences are in `05.LULU/` > (or `04.PooledResults/` with `--lulu false`). The output page describes every folder and table. > - `pipeline_info/README_Step1_Methods.txt` and `README_Step2_Methods.txt` describe the run with the > tools used and their references. Use them as the basis for a methods section; do not write > methods from memory. > - When a run fails: read the error in the terminal or in `.nextflow.log` (launch directory). > It names the failed process and its work directory; there, `.command.err`, `.command.log` and > `.command.sh` show what ran. Fix the cause and rerun the same command with `-resume`. > ````