nf-core pipeline · bamtofastq, conversion, cramtofastq
nf-core/bamtofastq
Converts mapped and unmapped BAM or CRAM files into FASTQ reads with integrated quality control.
What nf-core/bamtofastq is
nf-core/bamtofastq is a bioinformatics workflow that converts aligned or unaligned BAM and CRAM files into compressed FASTQ format (fq.gz). Originally created by Friederike Hanssen, ported to Nextflow DSL2 by Susanne Jodoin, and maintained by Famke Bäuerle, it standardises the retrieval of raw sequencing reads from alignment archives.
Reprocessing genomic datasets often requires returning to original sequence reads to perform new alignments, update variant calling, or run different downstream analysis pipelines. The pipeline streamlines this conversion while performing read pairing checks, collation, extraction, file validation, and quality assessment across both the original alignments and the generated FASTQ files.
What the pipeline does
The workflow accepts BAM or CRAM files registered in a comma-separated samplesheet. It begins by performing initial quality control on the alignment files with FastQC, calculating alignment statistics, and querying the data with Samtools to automatically identify whether the sequencing reads are single-end or paired-end. For mapped alignments, the user can restrict processing to reads matching a specified chromosome or genomic region.
Reads are subsequently ordered using samtools collate and written to gzipped FASTQ files using samtools fastq. Once extraction finishes, fastq_utils confirms that the output FASTQ files are structurally valid, FastQC evaluates sequence quality, and MultiQC combines statistics from both pre- and post-conversion stages into a single report.
Key facts
- Input formats
- BAM, CRAM (mapped or unmapped; with or without index files)
- Output formats
- FASTQ (fq.gz), MultiQC HTML report
- Core tools
- Samtools, FastQC, fastq_utils, MultiQC
- Workflow framework
- Nextflow DSL2
- Latest release
- 2.2.1
What you can use it for
- Reprocessing archived sequencing datasets
- Restores compressed BAM or CRAM alignment files into gzipped FASTQ files to enable re-alignment or alternative downstream analysis.
- Region-specific read extraction
- Extracts reads mapping exclusively to specific genomic regions or chromosomes from mapped BAM or CRAM files.
- Conversion quality auditing
- Evaluates data metrics before and after extraction using FastQC and MultiQC, while verifying the integrity of resulting FASTQ files with fastq_utils.
Run it here
The research agent runs nf-core/bamtofastq with Nextflow on its own machine — up to 32 cores, 256 GiB of memory and 24 hours per run, which covers the test profile and real single-sample runs. It builds the samplesheet, checks it against the pipeline's schema and reads the results back. When a run is too big for one machine, it gives you the exact command for your own cluster instead.
Strengths and limits
Good at
- Automatically identifies whether input alignment files contain single-end or paired-end sequencing reads.
- Provides comparative quality metrics across both input alignments and output FASTQ files via FastQC and MultiQC.
- Verifies the structural validity of all generated FASTQ files using fastq_utils.
- Permits targeted read extraction by chromosome or specific genomic coordinates for mapped data.
Watch out for
- Targeted extraction by genomic coordinates or chromosome is restricted to mapped alignments and cannot be applied to unmapped inputs.
- Requires inputs to be structured in a standardised comma-separated samplesheet defining sample names, file paths, indices, and file types.
Questions
Can I run nf-core/bamtofastq without my own cluster?
The research agent runs nf-core/bamtofastq with Nextflow on its own machine — up to 32 cores, 256 GiB of memory and 24 hours per run, which covers the test profile and real single-sample runs. It builds the samplesheet, checks it against the pipeline's schema and reads the results back. When a run is too big for one machine, it gives you the exact command for your own cluster instead.
What licence is nf-core/bamtofastq under?
MIT, like every nf-core pipeline.
Can the pipeline detect whether reads are single-end or paired-end automatically?
Yes. The pipeline evaluates the BAM or CRAM input files with Samtools to determine whether they contain single-end or paired-end data before extraction.
Can reads be extracted from only one chromosome?
Yes. When supplying mapped BAM or CRAM files, read extraction can be restricted to a specific chromosome or defined genomic region.
What tools handle the conversion from BAM to FASTQ?
Reads are sorted using samtools collate and extracted into FASTQ format using samtools fastq.
How does the pipeline verify output quality and integrity?
The pipeline runs fastq_utils to check that generated FASTQ files are valid, computes FastQC reports before and after conversion, and aggregates all statistics into a MultiQC report.
How to cite it
Philip Ewels, Alexander Peltzer, Sven Fillinger, Harshil Patel, Johannes Alneberg, Andreas Wilm, Maxime Ulysse Garcia, Paolo Di Tommaso & Sven Nahnsen. The nf-core framework for community-curated bioinformatics pipelines. Nat Biotechnol. 2020 Feb 13. doi: 10.1038/s41587-020-0439-x.
Written from nf-core/bamtofastq's own README. Statements citing a figure that does not appear there are removed before publication. Licence and running details come from our registry.