BactiSeq: Usage
Table of contents
- Introduction
- Samplesheet input
- Input Data Types & Requirements
- Running the pipeline
- Core Nextflow arguments
- Processes/tools with pre-set setting
- Custom tool/module configuration
- Nextflow CPU and Memory limits
- Running in the background
- Nextflow memory requirements
Introduction
BactiSeq is a Nextflow-based bioinformatics pipeline for bacterial whole-genome sequencing analysis. It provides end-to-end processing from raw sequencing reads to annotated variants and quality reports, following best practices for reproducibility and scalability. Basic Command
nextflow run main.nf -profile plato/docker/conda/mamba/singularity/arm/podman/shifter/apptainer/charliecloud/wave --input samplesheet.csv --outdir /path/to/output/directory/

The profile used depends on the avilable environments available to your device.
Pipeline arguments
| Argument | Description | Example |
|---|---|---|
--input | Path to the input samplesheet (CSV/TSV) | samplesheet.csv |
--aligned | (optional) Whether given BAM/SAM files have alignment information | true or false, default false |
--hyrbid_assembler | (optional) Which assembler to use for hybrid assmebly | spades or unicycler, default null |
--illumina_adapters | (optional) path to file of adapters for bbduk | path to file, default null |
--polish | (optional) Whether to polish at all despite what’s set in the samplesheet | true or false, default true |
⚠️ WARNING: UNICYCLER Automatically carries out multiple rounds of polishing with RACON. Consider this when setting polishing settings for hybrid assembly using Unicycler.
Samplesheet input
You will need to create a samplesheet with information about the samples you would like to analyse before running the pipeline. Use this parameter to specify its location. It has to be a comma-separated file with 7 columns, and a header row as shown in the examples below.
--input '[path to samplesheet file]'
Full samplesheet
The pipeline will auto-detect whether a sample is single- or paired-end using the information provided in the samplesheet. As well as attempt to auto-detect whether they long reads are Nanopore, or PacBio long reads or pre-assembled genome files. However, there is a strict requirement for certain inputs and certain types of valid file extensions. Examples below of the rules for input
Quick Reference: One-line Rules
- Hybrid:
short_fastq1 + long_fastq, no assembly - Illumina:
short_fastq1 + short_fastq2, no long, no assembly - Long-read:
long_fastqonly, no short, no assembly - Pre-assembled:
assemblyonly, no reads
Input Data Types & Requirements
Table 1: Input Combinations
| Type | Description | Required Fields | Disallowed Fields |
|---|---|---|---|
| Hybrid Assembly | Short + long reads for hybrid assembly | sample, short_fastq1, long_fastq | assembly (must be "assemblyNA/empty") |
| Illumina-only | Paired-end short read assembly | sample, short_fastq1, short_fastq2 | assembly (must be "assemblyNA/empty"), long_fastq (must be "longNA/empty") |
| Long-read-only | Long read assembly (Nanopore/PacBio) | sample, long_fastq | assembly (must be "assemblyNA/empty"), short_fastq1, short_fastq2 (must be "short1NA"/"short2NA"/empty) |
| Pre-assembled | Already assembled genome | sample, assembly | short_fastq1, short_fastq2, long_fastq (must be NA/empty values) |
Table 2: Valid File Extensions
| Field | Required Extensions | Example Files |
|---|---|---|
short_fastq1, short_fastq2 | .fastq.gz, .fq.gz | sample_R1.fastq.gz, reads.fq.gz |
long_fastq | .fastq.gz, .fq.gz | ont_reads.fastq.gz |
assembly | .fasta, .fa, .fna, .gbk, .gb, .gbff, .genbank, .embl, .gff, .gff3 | genome.fasta, annotation.gff, assembly.gbff |
Table 3: Example Valid Configurations
| Type | Sample Row Example |
|---|---|
| Hybrid | sample01,reads_R1.fq.gz,reads_R2.fq.gz,ont.fq.gz,,short, |
| Illumina-only | sample02,ill_R1.fastq.gz,ill_R2.fastq.gz,,,, |
| Long-read-only | sample03,short1NA,short2NA,pacbio.fq.gz,,long, |
| Pre-assembled | sample04,short1NA,short2NA,longNA,genome.fasta,, |
Example of a csv file
sample,short_fastq1,short_fastq2,long_fastq,assembly,polish,ONT_basecaller
pacbio1,,,./testPac/OS0131AD_EA076372_bc2074.hifi.fq.gz,,long,
pacbio37,,,./testPac/SRR33769408.fastq.gz,,,
NANOPORE08720179,SRR29751147_1.fastq.gz,SRR29751147_2.fastq.gz,,,short,
NANOPORE08720180,SRR29751252_1.fastq.gz,SRR29751252_2.fastq.gz,,,,
Nanopore2,,,nanoporeSRR10074455.fastq.gz,,long,
Illumina087201792,SRR29751147_1.fastq.gz,SRR29751147_2.fastq.gz,,,,
Illumina087201802,SRR29751252_1.fastq.gz,SRR29751252_2.fastq.gz,,,,
⚠️ WARNING: If no basecaller mode is declared, medaka for polishing will default to the model
r1041_e82_400bps_sup_v5.2.0.
💡 TIP: To ensure the long read data gets properly identified as either Nanopore or Pacbio. BactiSeq checks for certain file extensions, words within filenames, header data within the reads, and sample names. To ensure the data gets identified correctly - Putting Pacbio in the filename of reads/samplename or Nanopore in read file or samplename is suggested.
| Column | Description |
|---|---|
sample | Sample identifier (no spaces allowed). |
short_fastq1 | Path to gzipped R1 Illumina reads (*.fastq.gz). |
short_fastq2 | Path to gzipped R2 Illumina reads (*.fastq.gz). |
long_fastq | Path to gzipped long reads (*.fastq.gz). |
assembly | Path to pre-assembled genome file (multiple formats supported). |
polish | Polishing method: "short", "long", or "NA/Empty". |
ONT_basecaller | Nanopore basecaller metadata (optional). Default for the tool Medaka is r1041_e82_400bps_sup_v5.2.0 |
Running the pipeline
The typical command for running the pipeline is as follows:
nextflow run main.nf -profile plato/docker/conda/mamba/singularity/arm/podman/shifter/apptainer/charliecloud/wave --input samplesheet.csv --outdir /path/to/output/directory/
This will launch the pipeline with the docker configuration profile. See below for more information about profiles.
Note that the pipeline will create the following files in your working directory:
work # Directory containing the nextflow working files
<OUTDIR> # Finished results in specified location (defined with --outdir)
.nextflow_log # Log file from Nextflow
# Other nextflow hidden files, eg. history of pipeline runs and old logs.
If you wish to repeatedly use the same parameters for multiple runs, rather than specifying each flag in the command, you can specify these in a params file.
Pipeline settings can be provided in a yaml or json file via -params-file <file>.
Do not use
-c <file>to specify parameters as this will result in errors. Custom config files specified with-cmust only be used for tuning process resource specifications, other infrastructural tweaks (such as output directories), or module arguments (args).
The above pipeline run specified with a params file in yaml format:
nextflow run main.nf -profile docker -params-file params.yaml
with:
```yaml title=”params.yaml” input: ‘./samplesheet.csv’ outdir: ‘./results/’ polish: false <…>
You can also generate such "YAML"/"JSON" files via [nf-core/launch](https://nf-co.re/launch).
### Updating the pipeline
When you run the command bellow, Nextflow automatically pulls the pipeline code from GitHub and stores it as a cached version. When running the pipeline after this, it will always use the cached version if available - even if the pipeline has been updated since. To make sure that you're running the latest version of the pipeline, make sure that you regularly update the cached version of the pipeline:
```bash
nextflow pull Sylvial-00/bactiseq
Reproducibility
It is a good idea to specify the pipeline version when running the pipeline on your data. This ensures that a specific version of the pipeline code and software are used when you run your pipeline. If you keep using the same tag, you’ll be running the same version of the pipeline, even if there have been changes to the code since.
First, go to the nf-core/bactiseq releases page and find the latest pipeline version - numeric only (eg. 1.3.1). Then specify this when running the pipeline with -r (one hyphen) - eg. -r 1.3.1. Of course, you can switch to another version by changing the number after the -r flag.
This version number will be logged in reports when you run the pipeline, so that you’ll know what you used when you look back in the future. For example, at the bottom of the MultiQC reports.
To further assist in reproducibility, you can use share and reuse parameter files to repeat pipeline runs with the same settings without having to write out a command with every single parameter.
💡 TIP: If you wish to share such profile (such as upload as supplementary material for academic publications), make sure to NOT include cluster specific paths to files, nor institutional specific profiles.
Core Nextflow arguments
✏️ NOTE: These options are part of Nextflow and use a single hyphen (pipeline parameters use a double-hyphen)
-profile
Use this parameter to choose a configuration profile. Profiles can give configuration presets for different compute environments.
Several generic profiles are bundled with the pipeline which instruct the pipeline to use software packaged using different methods (Docker, Singularity, Podman, Shifter, Charliecloud, Apptainer, Conda) - see below.
❗IMPORTANT ❗ We highly recommend the use of Docker or Singularity containers for full pipeline reproducibility, however when this is not possible, Conda is also supported.
The pipeline also dynamically loads configurations from https://github.com/nf-core/configs when it runs, making multiple config profiles for various institutional clusters available at run time. For more information and to check if your system is supported, please see the nf-core/configs documentation.
Note that multiple profiles can be loaded, for example: -profile test,docker - the order of arguments is important! They are loaded in sequence, so later profiles can overwrite earlier profiles.
If -profile is not specified, the pipeline will run locally and expect all software to be installed and available on the PATH. This is not recommended, since it can lead to different results on different machines dependent on the computer environment.
test- A profile with a complete configuration for automated testing
- Includes links to test data so needs no other parameters
docker- A generic configuration profile to be used with Docker
singularity- A generic configuration profile to be used with Singularity
podman- A generic configuration profile to be used with Podman
shifter- A generic configuration profile to be used with Shifter
charliecloud- A generic configuration profile to be used with Charliecloud
apptainer- A generic configuration profile to be used with Apptainer
wave- A generic configuration profile to enable Wave containers. Use together with one of the above (requires Nextflow ` 24.03.0-edge` or later).
conda- A generic configuration profile to be used with Conda. Please only use Conda as a last resort i.e. when it’s not possible to run the pipeline with Docker, Singularity, Podman, Shifter, Charliecloud, or Apptainer.
plato- A generic configuration profile to be used within PLATO at the University of Sasktchewan. Allows proper binding of the temporary directory
-resume
Specify this when restarting a pipeline. Nextflow will use cached results from any pipeline steps where the inputs are the same, continuing from where it got to previously. For input to be considered the same, not only the names must be identical but the files’ contents as well. For more info about this parameter, see this blog post.
You can also supply a run name to resume a specific run: -resume [run-name]. Use the nextflow log command to show previous run names.
-c
Specify the path to a specific config file (this is a core Nextflow command). See the nf-core website documentation for more information.
Resource requests
Whilst the default requirements set within the pipeline will hopefully work for most people and with most input data, you may find that you want to customise the compute resources that the pipeline requests. Each step in the pipeline has a default set of requirements for number of CPUs, memory and time. For most of the pipeline steps, if the job exits with any of the error codes specified here it will automatically be resubmitted with higher resources request (2 x original, then 3 x original). If it still fails after the third attempt then the pipeline execution is stopped.
To change the resource requests, please see the max resources and tuning workflow resources section of the nf-core website.
Custom Containers
In some cases, you may wish to change the container or conda environment used by a pipeline steps for a particular tool. Often Nextflow pipelines use containers and software from the biocontainers or bioconda projects. However, in some cases the pipeline specified version maybe out of date.
To use a different container from the default container or conda environment specified in a pipeline, please see the updating tool versions section of the nf-core website.
Custom Tool Arguments
A pipeline might not always support every possible argument or option of a particular tool used in pipeline. Fortunately, Nextflow pipelines provide some freedom to users to insert additional parameters that the pipeline does not include by default.
To learn how to provide additional arguments to a particular tool of the pipeline, please see the customising tool arguments section of the nf-core website.
In general, you need to edit the conf/modules.config file to add parameters to tools.
##Below are the possible modules within BactiSeq that allow additional parameters.
Some tools come with pre-selected parameters for the workflows
Processes/tools with pre-set setting
Table 1: Bactiseq Pipeline: Processes with pre-set settings
| Process | Pre-set settings |
|---|---|
| Bakta | --database --type full |
| Chopper | -q 10 --minlength 1000 |
| bbduk | ktrim=r k=23 mink=11 hdist=1 tpe tbo maq=10 trim1=6 qtrim=r minlength=31 |
| abricate | --db vfdb --minid 80 --mincov 80 |
| Cgview | --feature_labels T |
| GATK4 SamtoFastq | --VALIDATION_STRINGENCY SILENT |
Custom tool/module configuration
Nextflow pipelines allow users to customize the parameters used by specific tools/modules through the configuration folder.
** steps to customize **
- Navigate to the pipeline directory and edit the file:
pipeline_directory/conf/modules.config, the pipeline directory is where you pulled the pipeline into. - Locate or add the module configuration section
- Insert custom arguments in the
ext.argsparameterExample Configuration:
withName: CGVIEW { ext.args = '-feature_labels T ' publishDir = [ path: { "${params.outdir}/${meta.id}/visualizations/cgview" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename } ] }Nextflow CPU and Memory limits
Nextflow pipelines, including BactiSeq, manage computational resources through configuration files. Resource limits for CPU cores, memory allocation, and maximum runtime are defined in the pipeline’s configuration files, primarily in conf/base.config.
The main resource configuration file (conf/base.config) uses a label-based system to categorize processes by their resource requirements:
Example of base.config
process {
// Default settings for all processes
cpus = { 1 * task.attempt }
memory = { 6.GB * task.attempt }
time = { 4.h * task.attempt }
// Process-specific resource requirements using labels
withLabel:process_single {
cpus = { 1 }
memory = { 6.GB * task.attempt }
time = { 4.h * task.attempt }
}
withLabel:process_low {
cpus = { 8 * task.attempt }
memory = { 12.GB * task.attempt }
time = { 4.h * task.attempt }
}
withLabel:process_medium {
cpus = { 10 * task.attempt }
memory = { 10.GB * task.attempt }
time = { 8.h * task.attempt }
}
withLabel:process_high {
cpus = { 20 * task.attempt }
memory = { 128.GB * task.attempt }
time = { 48.h * task.attempt }
}
withLabel:process_long {
time = { 20.h * task.attempt }
}
withLabel:process_high_memory {
memory = { 200.GB * task.attempt }
}
Running in the background
Nextflow handles job submissions and supervises the running jobs. The Nextflow process must run until the pipeline is finished.
The Nextflow -bg flag launches Nextflow in the background, detached from your terminal so that the workflow does not stop if you log out of your session. The logs are saved to a file.
Alternatively, you can use screen / tmux or similar tool to create a detached session which you can log back into at a later time. Some HPC setups also allow you to run nextflow within a cluster job submitted your job scheduler (from where it submits more jobs).
Nextflow memory requirements
In some cases, the Nextflow Java virtual machines can start to request a large amount of memory. We recommend adding the following line to your environment to limit this (typically in ~/.bashrc or ~./bash_profile):
NXF_OPTS='-Xms1g -Xmx4g'