10x Genomics

Converting 10x Genomics BAM Files to FASTQ

bamtofastq is a tool for converting 10x Genomics BAM files back into FASTQ files that can be used as inputs to re-run analysis. The FASTQs will be output into a directory structure identical to the mkfastq or bcl2fastq tools, so they are ready to input into the next pipeline (e.g. cellranger count, spaceranger count).

Background

10x Genomics pipelines require FASTQs (with embedded barcodes) as input, so we developed bamtofastq to help users who want to reanalyze 10x Genomics data but only have access to BAM files. For example, some users may want to store BAM files only. Others might have downloaded our BAM data from NCBI SRA. The location of the 10x Genomics barcode varies depending on product and reagent version. bamtofastq determines the appropriate way to construct the original read sequence from the sequences and tags in the BAM file.

bamtofastq works with BAM files output by the following 10x Genomics pipelines:

Download and Installation

bamtofastq is available for Linux and is compatible with RedHat/CentOS 5.2 or later, and Ubuntu 8.04 or later.

bamtofastq is a single executable that can be run directly and requires no compilation or installation. Place the executable file in a directory that is on your PATH, and make sure to chmod 700 to make it executable.

Running the Tool

10x Genomics BAMs produced by Cell Ranger v1.2+, Cell Ranger ATAC v1.0+, Cell Ranger ARC v1.0+, Space Ranger v1.0+, Cell Ranger DNA v1.0+, and Long Ranger v2.1+ contain header fields that permit automatic conversion to the correct FASTQ sequences. BAMs produced by older 10x Genomics pipelines may require special arguments or have some caveats, see known issues for details.

The FASTQ files output by bamtofastq contain the same set of sequences that were input to the original pipeline run, although the original order will not be preserved. 10x Genomics pipelines are generally insensitive to the order of the input data, so you can expect nearly identical results when re-running pipelines with bamtofastq outputs.

The usage of the bamtofastq command is as follows:

bamtofastq [options] [bam-path] [output-path]

Replace [bam-path] with the path to the input BAM, [output-path] with the path to the output directory, and include any relevant [options] (listed below). For example, if your BAM file is located at /path/to/mydata.bam, you want the output in /path/to/home/directory, and you want to use eight threads, the command would be:

bamtofastq --nthreads=8 /path/to/mydata.bam /path/to/home/directory

You can also print the options from the command line:

bamtofastq --help

Run times for full-coverage WGS BAMs may be several hours.

Options

OptionDescription
--nthreads=nThreads to use for reading BAM file. Default: 4
--locus=locusOptional. Only include read pairs mapping to locus. Use chrom:start-end format.
--reads-per-fastq=NNumber of reads per FASTQ chunk. Default: 50000000
--gemcodeConvert a BAM produced from GemCode data (Longranger 1.0 - 1.3)
--lr20Convert a BAM produced by Longranger 2.0
--cr11Convert a BAM produced by Cell Ranger 1.0-1.1
--bx-list=LOnly include BX values listed in text file L. Requires BX-sorted and indexed BAM file (see Long Ranger support for details).
--helpShow the help screen

Known Issues and Limitations

PackageVersionPipelinesExtra ArgumentsComplete FASTQs
Cell Ranger1.3+countnoneYes
Cell Ranger1.2countnoneReads without a valid barcode will be absent from FASTQ. (These reads are ignored by Cell Ranger)
Cell Ranger1.0-1.1count--cr11 Reads without a valid barcode will be absent from FASTQ. (These reads are ignored by Cell Ranger)
Cell Ranger ARC1.0.0+countnoneAny sequenced bases in the i5 index read that are not part of the 10x Genomics barcode are dropped from the FASTQ output.
Cell Ranger ATAC1.0.0+countnoneAny sequenced bases in the i5 index read that are not part of the 10x Genomics barcode are dropped from the FASTQ output.
Cell Ranger DNA1.0.0+cnvnoneYes
Long Ranger2.1.3+wgs, targeted, align, basicnoneYes
Long Ranger2.1.0 - 2.1.2wgs, targetednoneYes
Long Ranger2.0wgs, targeted--lr20Yes
Long Ranger2.0.0 - 2.1.2align, basicNot SupportedN/A
Long Ranger1.3 (GemCode)wgs, targeted--gemcodeReads without a valid barcode will be absent from FASTQ. This will result in a ~5-10% loss of coverage.