BinAC2/Software/fastp
|
The main documentation is available on the cluster via |
| Description | Content |
|---|---|
| module load | bio/fastp/1.4.0 |
| License | MIT - see [1] |
| Citing | Shifu Chen. fastp 1.0: An ultra-fast all-round tool for FASTQ data quality control and preprocessing. iMeta 4(5) (2025): e70078 |
| Links | fastp Documentation: [2] fastp Repository: [3] |
Description
This page describes fastp 1.4.0 (module bio/fastp/1.4.0). All recommendations below were measured with this version.
fastp cleans up short read sequencing data (FASTQ files) before further analysis. In one pass it checks the quality, finds and removes adapter sequences, cuts or removes low quality reads, and writes a report as HTML (to look at in a web browser) and as JSON (for tools such as MultiQC). It works with paired-end and single-end data and reads and writes gzip compressed files directly.
You only need to load this one module. fastp works on all BinAC 2 compute nodes and automatically uses the fastest instructions the processor of the node offers; you do not have to choose anything.
fastp is designed for short reads. For long reads (Nanopore, PacBio) upstream provides a separate tool, fastplong.
Which settings should I use?
The best setting depends on what matters to you. All three use --mem=2G.
| Goal | fastp option | Slurm | Why |
|---|---|---|---|
| One sample, result fast | -w 16 |
--cpus-per-task=16 |
fast: about 43 s for 20 million read pairs, about 21 min for a 30x human genome (estimate) |
| Many samples (job array) | -w 8 |
--cpus-per-task=8 |
on a full node about 60% more samples per hour than jobs with 16 CPUs, each sample still finishes in reasonable time |
| Lowest energy use | -w 4 |
--cpus-per-task=4 |
lowest energy per sample and the most samples per hour, but each sample takes longest |
-w sets the number of fastp worker threads. Set it to the same number as --cpus-per-task, but not higher than 16. Slurm on BinAC 2 counts hardware threads as CPUs (2 per physical core), and fastp is 7% to 10% faster when it uses both hardware threads of a core (see Hyperthreading).
Quick start
One sample
Paired-end gzip FASTQ files, adapters are detected automatically. Run the job from a workspace or your project directory (see Storage).
#!/bin/bash
#SBATCH --job-name=fastp
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=16
#SBATCH --mem=2G
#SBATCH --time=01:00:00
module load bio/fastp/1.4.0
fastp -i sample_R1.fastq.gz -I sample_R2.fastq.gz \
-o sample_R1.trimmed.fastq.gz -O sample_R2.trimmed.fastq.gz \
--detect_adapter_for_pe -w 16 \
-j sample.fastp.json -h sample.fastp.html
Many samples (job array)
samples.txt contains one sample name per line, for example sample01 for the files sample01_R1.fastq.gz and sample01_R2.fastq.gz. Set --array to the number of lines. For the lowest energy use, change to --cpus-per-task=4 and -w 4 and allow more time.
#!/bin/bash
#SBATCH --job-name=fastp-array
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=8
#SBATCH --mem=2G
#SBATCH --time=02:00:00
#SBATCH --array=1-20
module load bio/fastp/1.4.0
S=$(sed -n "${SLURM_ARRAY_TASK_ID}p" samples.txt)
fastp -i ${S}_R1.fastq.gz -I ${S}_R2.fastq.gz \
-o ${S}_R1.trimmed.fastq.gz -O ${S}_R2.trimmed.fastq.gz \
--detect_adapter_for_pe -w 8 \
-j ${S}.fastp.json -h ${S}.fastp.html
Benchmarks
All values were measured with fastp 1.4.0 (bio/fastp/1.4.0) on BinAC 2 Zen 3 nodes (2 x AMD EPYC 7543). The Zen 5 nodes were not benchmarked.
Data: human whole genome sequencing of NA12878, run ERR194147, paired-end 2 x 101 bp Illumina, gzip compressed, options --detect_adapter_for_pe and otherwise the defaults. The files are on BinAC 2 in
/pfs/10/project/benchmark_data/wgs/giab_NA12878_truseq_30x/ERR194147/
(ERR194147_1.fastq.gz and ERR194147_2.fastq.gz). The smaller inputs are the first 10, 20 and 40 million read pairs of these files.
Threads
One fastp job alone on a node, 20 million read pairs, mean of 2 to 4 runs (1 run for -w 35 and more). Here -w was half of --cpus-per-task (one worker per physical core); see Hyperthreading for -w equal to --cpus-per-task.
| -w | --cpus-per-task | Wall time | Speedup vs -w 2 |
|---|---|---|---|
| 2 | 4 | 98 s | 1.0 |
| 4 | 8 | 62 s | 1.6 |
| 6 | 12 | 52 s | 1.9 |
| 8 | 16 | 47 s | 2.1 |
| 12 | 24 | 40 s | 2.5 |
| 16 | 32 | 40 s | 2.5 |
| 35 | 128 | 55 s | 1.8 |
| 70 | 128 | 58 s | 1.7 |
| 128 | 128 | 64 s | 1.5 |
-w 12with--cpus-per-task=24is the fastest setting, but only about 15% faster than-w 8for 50% more CPUs.- More than
-w 16makes fastp slower, not faster.
Many jobs on one node
Several fastp jobs running at the same time on one node, all 64 cores busy, 20 million read pairs per job, 2 runs each:
| Jobs x -w | --cpus-per-task | Wall time per job | Read pairs per second (whole node) |
|---|---|---|---|
| 32 x 2 | 4 | 115 s | 5.5 million |
| 16 x 4 | 8 | 69 s | 4.6 million |
| 8 x 8 | 16 | 50 s | 3.2 million |
With -w 2 the node processes about 70% more data per hour than with -w 8, with -w 4 about 45% more. Each single job gets a bit slower when the node is full (18% for -w 2).
In this test all jobs read the same input file. Real array jobs read different files, which was not tested.
Hyperthreading
Each physical core has two hardware threads, and Slurm counts both as CPUs. The question is whether fastp should use both. Same data, 20 million read pairs, 2 runs each. The recommended settings are marked green.
| Situation | --cpus-per-task | -w | Wall time per job | Read pairs per second (whole node) |
|---|---|---|---|---|
| one job alone | 16 | 8 | 47 s | 0.42 million |
| one job alone | 16 | 16 | 43 s | 0.47 million |
| node full (32 jobs) | 4 | 2 | 115 s | 5.5 million |
| node full (32 jobs) | 4 | 4 | 107 s | 6.0 million |
| node full (16 jobs) | 8 | 4 | 69 s | 4.6 million |
| node full (16 jobs) | 8 | 8 | 62 s | 5.1 million |
With -w equal to --cpus-per-task fastp is 7% to 10% faster and needs 4% to 11% less energy per sample than with -w at half of --cpus-per-task. More than -w 16 was not tested in this way; above 16 threads fastp gets slower (see Threads).
Energy
Energy was measured on the CPUs (RAPL counters of both processors) and for the whole node (IPMI, power reading of the node, includes memory, fans and power supply). Same data as above, 20 million read pairs, mean of 2 runs.
| Situation | --cpus-per-task | -w | Energy per sample (whole node) | Energy per sample (CPUs only) |
|---|---|---|---|---|
| node full (32 jobs) | 4 | 4 | 2.2 kJ | 1.4 kJ |
| node full (32 jobs) | 4 | 2 | 2.3 kJ | 1.5 kJ |
| node full (16 jobs) | 8 | 8 | 2.2 kJ | 1.5 kJ |
| node full (16 jobs) | 8 | 4 | 2.5 kJ | 1.6 kJ |
| node full (8 jobs) | 16 | 8 | 3.1 kJ | 2.1 kJ |
| one job alone on the node | 16 | 16 | 13 kJ | 8.2 kJ |
| one job alone on the node | 16 | 8 | 15 kJ | 9.0 kJ |
- A node uses a lot of power even when it does nothing: about 260 W for the whole node, 150 W of it for the CPUs alone. When many jobs share a node, this power is divided between them. That is why one sample costs about 5 times less energy on a full node than alone on an empty node.
- On a full node, small jobs need less energy per sample: 4 or 8 CPUs per job need about 30% less than 16 CPUs per job (measured with
-w 8). - BinAC 2 nodes are normally shared by several jobs, so for the energy recommendation the values for a full node apply.
Job size and time
One job alone on a node, with -w 8 and --cpus-per-task=16:
| Read pairs | Input (gzip, R1 + R2) | Wall time |
|---|---|---|
| 10 million | 1.3 GB | 32 s |
| 20 million | 2.7 GB | 47 s |
| 40 million | 5.2 GB | 79 s |
| 766 million (30x human genome) | 103 GB | 23 min |
Rule of thumb (estimates from these runs), plus a few seconds to start:
- one job, 16 CPUs,
-w 16: about 1.7 seconds per million read pairs - full node, 8 CPUs per job,
-w 8: about 3.1 seconds per million read pairs - full node, 4 CPUs per job,
-w 4: about 5.4 seconds per million read pairs
Add a safety margin to --time.
Memory
fastp needed 1.3 GiB of memory in every run with -w 2 to -w 16, no matter if the input had 10 million or 766 million read pairs. A full 30x human genome finished with --mem=2G, so --mem=2G is enough.
With many threads fastp needs more memory: 2.7 GiB at -w 128.
Storage
BinAC 2 has several places to keep data, see File Systems.
A single fastp job was equally fast with input and output on project storage (/pfs/10/project), in a workspace (/pfs/10/work) or in the job's local $TMPDIR (40 million read pairs, all combinations between 76 s and 79 s). fastp reads and writes only about 70 MB/s per job, so the file system does not slow it down. Copying the input to $TMPDIR first does not make fastp faster.
The compressed output is about as large as the input (103 GB for a 30x human genome). Make sure there is enough space where you write the output.
Pitfalls
- Too many threads: more than
-w 16is slower, not faster. Do not use-w ${SLURM_CPUS_PER_TASK}with a large number of CPUs. - Some report values depend on -w: the insert size (histogram and peak) is calculated from the reads of only one worker thread, and the list of removed adapter sequences is limited per thread. These values change slightly when you change
-w. The cleaned reads and all read, base and filter counts do not depend on-w(checked for-w 2to-w 16). - Report file names: without
-jand-hfastp writesfastp.jsonandfastp.htmlinto the current directory. Give every sample its own names, otherwise the reports overwrite each other. - Output file names:
-oand-Omust be different files.
Support
See BinAC2 Support.