Skip to content
Data & utilitieslatest-release

bamtofastq

nf-core/bamtofastq

Workflow converts one or multiple bam/cram files to fastq format

version2.2.18a295860c0May 13, 2026 Upstream Usage docs

Key tools

FastQCfastq_utilsMultiQCSAMtools

Run it

nfclaw
nfclaw run bamtofastq --input samplesheet.csv --outdir results -profile docker
raw nextflow
nextflow run pipelines/bamtofastq/upstream -profile docker --input samplesheet.csv --outdir results
demo · bundled test profile
nfclaw run bamtofastq --demo --outdir results # adds the upstream test profile (-profile test,docker)

Inputs

columntyperequiredallowed valuesconstraints
sample_idstringyesmatches ^\S+$
mappedstring (file path)yesmatches ^\S+\.(bam|cram)$
indexstring (file path)nomatches ^\S+\.(bai|crai)$
file_typestringyesbam, cram

--input must match ^\S+\.csv$.

The samplesheet is a CSV with this header (the columns the schema requires); fill each value per the table above and reference.md (no example value is invented here):

csv
sample_id,mapped,file_type

Any of the optional columns above may be appended to the header when your data needs them: index.

From data files. --input may also be the data files — a directory (searched recursively), a quoted glob, or files (--input once per file) — from which nfclaw writes this samplesheet: sample_id from file names; mapped, index from files matching their patterns, by sample name. Set the required columns no file determines with --sheet-set COLUMN=VALUE (a constant or a {sample}/{lane} template): file_type (one of bam, cram). Preview it with --check; a run records it in <outdir>/provenance/ for replay.

Reference genome

No reference genome is set by default: supply your own reference. The schema declares AWS iGenomes at s3://ngi-igenomes/igenomes/; selecting --genome <id> uses the paths in the pipeline's reference configuration. Access to that remote source is required. To supply your own reference, use e.g. --fasta; the reference_genome_options group in reference.md lists every reference option. Set --igenomes-ignore true to disable the lookup entirely. Confirm the selected reference's paths and source in the pinned upstream/nextflow.config and upstream/conf/ before running.

Resources

Resource requests follow the pipeline's configs and selected profiles. nf-core's resource labels often assume a server — a single step can request far more memory than a workstation has, and retry rules can increase requests. If a run fails with Process requirement exceeds available memory (or CPUs), cap every request, and every retry, at what this machine actually has:

bash
nfclaw run bamtofastq --input samplesheet.csv --outdir results -profile docker \
--limit-cpus 4 --limit-memory 15.GB

nfclaw turns those into Nextflow's process.resourceLimits and passes them as a -c config — the mechanism nf-core prescribes for exactly this (docs). Set them to the machine's real capacity. --limit-time DURATION also caps how long any one task may run: a task that needs longer is stopped, and so is every retry, so set it only as a deliberate ceiling, never as a guess at how long the analysis takes. The generated config is kept in <outdir>/provenance/, so commands.sh replays the run under the same ceiling.

Nextflow engine

This release declares nextflowVersion = '!>=25.10.4'.

To pin this release's declared minimum engine — useful when a newer Nextflow has incompatible config parsing:

bash
nfclaw run bamtofastq ... --nxf-ver 25.10.4

--nxf-ver is recorded in <outdir>/provenance/, so the replay uses the same engine. See known-issues.

Demo

bash
nfclaw run bamtofastq --demo --outdir results # adds the upstream test profile (-profile test,docker)

This pinned test profile omits its required reference. For the bundled demo input, nfclaw supplies the matched chr22:1-40001 test FASTA from immutable test-datasets commit 618f1541382c4ad49eff566dadf13d5ccbd0ebb4 and records it in params/provenance. Explicit --fasta or params-file values override it. Your own input, genome, test-data base, extra profiles or --config disable this demo default; choose a reference matched to your data. The correction applies only to the bundled test plus engine profiles. Its two-sample demo sheet is staged from immutable test-datasets commit e228f0e5412ed0bed20e7a99e1588cbf95f65102 (the same bytes as the moving branch it names) and bundled in provenance, so a replay reads the recorded sheet. Other releases retain their own defaults.

<!-- Generated from nf-core/bamtofastq@8a295860c0c9221337dec7f2620709a47cea254d. Do not edit by hand. -->

Samplesheet

A CSV with this header (the columns the schema requires). Fill each value per the constraints below; optional columns from the table may be appended.

samplesheet.csv header
sample_id,mapped,file_type
ColumnTypeRequiredAllowed / constraints
sample_idstringrequiredmatches ^\S+$
mappedstring (file path)requiredmatches ^\S+\.(bam|cram)$
indexstring (file path)optionalmatches ^\S+\.(bai|crai)$
file_typestringrequiredbamcram

Required parameters

--inputstring (file path)

Path to comma-separated file containing information about the samples in the experiment.

Constraint · matches ^\S+\.csv$

--outdirstring (directory path)

The output directory where the results will be saved. You have to use absolute paths to storage on Cloud infrastructure.

Parameter explorer

35 parameters · 5 groups

Every parameter from the pinned nextflow_schema.json. nfclaw checks explicit values before launch; complex rules use the pinned pipeline's runtime validation. Search, filter by group, and expand any parameter for its default, allowed values and constraints.

16 parameters · 19 hidden

Generic options6

Email address for completion summary.

Display the help message.

Display the full detailed help message.

Custom MultiQC yaml file containing HTML including a methods description.

MultiQC report title. Printed as page header, used for filename if not otherwise specified.

Display hidden parameters in the help message (only works when --help or --help_full are provided).

Input Output options2

Path to comma-separated file containing information about the samples in the experiment.

The output directory where the results will be saved. You have to use absolute paths to storage on Cloud infrastructure.

Main options5

Only use reads mapping to a specific chromosome/region. Has to be specified as in bam: i.e chr1, chr{1..22} (gets all reads mapping to chr1 to 22), 1, "X Y", incorrect naming will lead to a potentially silent error.

If specified, no quality control will be performed on extracted reads. Useful, if this is done anyways in the subsequent workflow.

If specified, skips all quality control and stats computation, including FastQC on both input bam and output reads, samtools flagstat, samtools idxstats, and samtools stats.

Reads to store in memory [default = '100000']. Only relevant for use with --samtools_collate_fast.

Uses fast mode for samtools collate in sortExtractMapped, sortExtractUnmapped and sortExtractSingleEnd.

Reference Genome options3

Path to FASTA genome file.

Path to FASTA FAI genome index file.

Name of iGenomes reference.

Outputs

Results land in --outdir; the files and directory layout depend on the selected workflow, parameters and publication settings. Run metadata is normally placed in <outdir>/pipeline_info/ (execution report, software versions), when those outputs are enabled. The pinned tree includes MultiQC support; a report is produced only when its workflow step runs. nfclaw run also writes <outdir>/provenance/ with the exact params file and the run log, <outdir>/provenance/logs/run.log — the whole launch, whose last line states the outcome (Nextflow's own log is <outdir>/.nextflow.log); unless --no-provenance it adds a run manifest (pinned version, commit and exact command), input/output SHA-256 checksums, and a replayable commands.sh. The exact output files and directory layout for this release are documented upstream: github.com/nf-core/bamtofastq/blob/2.2.1/docs/output.md Check a run — in the foreground or the background — with nfclaw status <outdir>: success, still running, how it ended (with the error), or stopped without an outcome; exit 0 success, 3 running, 1 otherwise.

Chaining

Run bamtofastq as one stage of a chain: nfclaw chain run starts each stage only after the one before it succeeded, and prepares its inputs from that stage's outputs. Every rule is checked against both pinned schemas.

Feeds into

  • rnaseq — bamtofastq publishes converted paired-end reads as reads/<sample>_1.merged.fastq.gz and _2; one rnaseq row per sample, strandedness detected by rnaseq (auto). Single-end conversions are published as reads/<sample>_other.fq.gz: a run with any fails this handoff instead of leaving them out, and needs an inline handoff.
nfclaw
nfclaw chain edges bamtofastq