Bowtie2

Introduction

Bowtie 2 is an ultra-fast and memory-efficient tool for aligning sequencing reads to long reference sequences, for example a genome (Langmead and Salzberg 2012). It is particularly good at aligning reads of about 50 up to 100s or 1,000s of characters, and particularly good at aligning to relatively long genomes.

For more detailed information, please visit the manual.

When to use Bowtie2 vs. other aligners: As a rule of thumb (this is not a strict rule, the right choice depends on your specific data and question), Bowtie2 and BWA are typical starting points for general-purpose or microbial short-read mapping (e.g. mapping Illumina reads to a bacterial genome or a set of contigs). If you are working with eukaryotic RNA-seq and have a good reference genome/annotation with introns, splice-aware aligners like STAR are usually a better fit. If you are working with long reads (e.g. Nanopore or PacBio), minimap2 is generally the better choice. The main things that actually drive the choice are read length, whether splicing needs to be modeled, and reference quality, not the tool name itself.

Installation

Installed on crunchomics: Yes, Bowtie v2.4.1 is installed. If you want to install it yourself, the command below installs the version verified on Crunchomics. Before running it, check the install notes for a newer version and swap the version number if one is available.

mamba create -n bowtie_2.5.3
mamba install -n bowtie_2.5.3 -c bioconda bowtie2=2.5.3
mamba activate bowtie_2.5.3

Usage

Indexing

To perform the Bowtie2 alignment, an index is required. The index is analogous to the index in a book. By indexing the reference sequence, we organize it in a manner that allows for an efficient search and retrieval of matches of the query (sequence read) to the reference sequences.

The basic syntax is for building an index for a genome called GCF_000385215.fna is as follows:

bowtie2-build GCF_000385215.fna GCF_000385215

In the command above GCF_000385215.fna is the input file of sequence reads in fasta format, and GCF_000385215 is the prefix of the generated index files.

Read alignment

After generating the index, we can align some short Illumina reads against our genome index. Notice, that Bowtie 2 does not generate log summary files and this information gets printed to screen. To save this output in a file we use the 2> operator.

Required inputs:

  • Single-end and paired-end files in fasta or fastq format (can be compressed)

Generated output:

  • The output from the Bowtie2 is an unsorted SAM file (i.e. Sequence Alignment/Map format)). The SAM file is a tab-delimited text file that contains information for each individual read and its alignment to the genome. To learn how to work with this file format, see the samtools page.

Bowtie2’s SAM output is uncompressed plain text and can get large fast, especially for big datasets. It is good practice to convert it into the compressed BAM format and sort it with samtools rather than keeping the SAM file around, both to save disk space and because most downstream tools expect a sorted, indexed BAM file anyway. We’ll first show the basic Bowtie2 command on its own, and then further down show how to combine it with samtools in a single step.

If you have a single-end file, you can run:

bowtie2 -p 2 -q \
    -x GCF_000385215 \
    -U sample1.fastq.gz \
    -S sample1_mapped.sam 2> bowtie2.log

For paired-end data you can do:

bowtie2 -p 2 -q \
    -x GCF_000385215 \
    -1 sample1_R1.fastq.gz \
    -2 sample1_R2.fastq.gz \
    -S sample1_mapped.sam 2> bowtie2.log

Basic options, for a fool list, go here:

  • -p: number of processors/cores
  • -q: reads are in FASTQ format
  • -x: /path/to/genome_indices_directory
  • -U: /path/to/FASTQ_file
  • -S: /path/to/output/SAM_file

Combining Bowtie2 with samtools

The commands above write a SAM file to disk, which you would then need to convert to a sorted BAM file yourself as a separate step (see the samtools view and samtools sort sections on the samtools page). Once you are comfortable with the basic Bowtie2 command, you can skip the intermediate SAM file entirely by connecting Bowtie2 and samtools sort with a pipe (|), so the alignment output is streamed directly into samtools sort:

bowtie2 -p 2 -q \
    -x GCF_000385215 \
    -U sample1.fastq.gz 2> bowtie2.log \
    | samtools sort -o sample1_sorted.bam -

Notice:

  • The -S sample1_mapped.sam option is dropped. Instead of writing a SAM file, Bowtie2 writes its output to screen (this is called “stdout”), and the pipe sends that output directly into samtools sort as its input.
  • The trailing - after -o sample1_sorted.bam tells samtools sort to read its input from the pipe rather than from a file.
  • The result, sample1_sorted.bam, is already a sorted BAM file, ready for indexing (see samtools index on the samtools page), no intermediate SAM file is ever created on disk.

A note on multi-mapping reads

A read that matches more than one place in the reference (common for repeats, paralogous genes, or closely related transcripts/isoforms) is called a multi-mapper. By default, Bowtie2 does not try to find and report all of these locations. Instead, for each read it searches for a good alignment and reports one, picked semi-randomly among the best-scoring locations it found, and gives that alignment a low mapping quality (MAPQ) score to flag that the placement is not unique (see the MAPQ field description on the samtools page). This is worth keeping in mind for:

  • Transcriptomics: reads from genes with shared exons, close paralogs, or multiple transcript isoforms can multi-map, which can distort read counts per gene/isoform if not accounted for. If this matters for your analysis, either filter on MAPQ, or use a tool designed to handle multi-mapping properly (e.g. one that distributes multi-mapped reads probabilistically) rather than relying on Bowtie2’s default single, semi-random pick.
  • Assembly-adjacent uses (e.g. mapping reads back to contigs/bins for coverage estimation): multi-mapping reads can artificially inflate the apparent coverage of repeated or similar regions across contigs.

If you want Bowtie2 to search harder and report multiple alignments per read instead of just one, see the -k and -a options in the manual.

A note on clipping

By default, Bowtie2 runs in end-to-end alignment mode: the entire read must be involved in the alignment, from its first base to its last, with no trimming allowed. If a read does not align well end-to-end (e.g. because of adapter sequence at one end, or because it runs past the edge of a short reference/contig), it will simply get a lower alignment score, or may not be reported as aligned at all, rather than being clipped.

Bowtie2 also offers a local alignment mode (--local), which is not the default and has to be requested explicitly. In local mode, Bowtie2 is allowed to trim (“soft-clip”) bases off the start and/or end of a read if that improves the alignment score. Soft-clipped bases are not deleted: they are still present in the SEQ field of the SAM record, but excluded from the alignment, and are marked with an S operation in the CIGAR string (see the CIGAR field description on the samtools page).

This matters because:

  • If you are seeing unexpectedly low alignment rates near read ends (e.g. leftover adapter sequence, or reads mapping right at the edge of a short contig), switching to --local can rescue alignments that end-to-end mode would otherwise score poorly or discard, at the cost of allowing partial/clipped alignments.
  • For assembly polishing or variant calling, clipped alignments (only relevant if you used --local) can inflate or distort apparent read support near contig ends, so it is worth knowing which mode was used when interpreting coverage there.
  • Since end-to-end is the default, if you have not passed --local yourself, you generally do not need to worry about clipping artifacts in your SAM/BAM file.

See the manual for the full comparison between the two modes.

References

Langmead, Ben, and Steven L Salzberg. 2012. “Fast Gapped-Read Alignment with Bowtie 2.” Nature Methods 9 (4): 357–59. https://doi.org/10.1038/nmeth.1923.