Main Content

bowtie2

Map sequence reads to reference sequence

Description

example

bowtie2(indexBaseName,reads1,reads2,outputFileName) maps the sequencing reads from reads1 and reads2 against the reference sequence and writes the results to the output file outputFileName. The input indexBaseName represents the base name (prefix) of the reference index files.

bowtie2 requires the Bowtie 2 Support Package for Bioinformatics Toolbox™. If this support package is not installed, then the function provides a download link. For details, see Bioinformatics Toolbox Software Support Packages.

example

bowtie2(___,alignOptions) uses the additional options specified by alignOptions. Specify these options after all other input arguments.

example

flag = bowtie2(___) returns an exit flag of the function using any of the input arguments in the previous syntaxes.

Examples

collapse all

Build a set of index files for the Drosophila genome. An error message appears if you do not have the Bowtie 2 Support Package for Bioinformatics Toolbox installed when you run the function. Click the provided link to download the package from the Add-on menu.

For this example, the reference sequence Dmel_chr4.fa is already provided with the toolbox.

status = bowtie2build('Dmel_chr4.fa', 'Dmel_chr4_index');

If the index build is successful, the function returns 0 and creates the index files (*.bt2) in the current folder. The files have the prefix 'Dmel_chr4_index'.

Sometimes the index files exist, and you want to know the reference sequence used to build the index. In this case, use the bowtie2inspect function to get more information about the reference.

bowtie2inspect('Dmel_chr4', 'Dmel_chr4_retrieved.fa');

By default, the output file Dmel_chr4_retrieved.fa contains the sequence of the reference. You can also get a summary information about the reference name and lengths instead of the actual sequence. For details on the available options, see Bowtie2InspectOptions.

Once the index is ready, map the read sequences to the reference using the bowtie2 function. The paired-end read files (SRR6008575_10k_1.fq and SRR6008575_10k_2.fq) are already provided with the toolbox.

bowtie2('Dmel_chr4','SRR6008575_10k_1.fq','SRR6008575_10k_2.fq','SRR6008575_10k_chr4.sam');

The output is a SAM-formatted file that contains the mapping results.

You can specify different alignment options by passing in a Bowtie 2 syntax string or using a Bowtie2AlignOptions object.

Suppose you want to trim some residues from the 3' end before aligning. First, create a Bowtie2AlignOptions object.

 alignOpt = Bowtie2AlignOptions;

Trim four residues from the 3' end before aligning.

 alignOpt.Trim3 = 4;

Map reads to the reference using the specified alignment option.

flag = bowtie2('Dmel_chr4','SRR6008575_10k_1.fq','SRR6008575_10k_2.fq','SRR6008575_10k_chr4_trimmed.sam',alignOpt);

Input Arguments

collapse all

Base name (prefix) of the reference index files, specified as a character vector or string. The index files are in the BT2 or BT21 format.

Example: 'Dmel_chr4'

Data Types: char | string

Names of files with the first mate reads or single-end reads, specified as a string array or cell array of character vectors.

For paired-end data, sequences in reads1 must correspond file-for-file and read-for-read to sequences in reads2.

Example: 'SRR6008575_10k_1.fq'

Data Types: char | string

Names of files with the second mate reads, specified as a string array or cell array of character vectors.

Specify reads2 as an empty character vector or string ('' or "") if the data consists of single-end reads only.

Example: 'SRR6008575_10k_2.fq'

Data Types: char | string

Output file name, specified as a character vector or string. This file contains the mapping results.

Example: 'SRR6008575_10k_chr4.sam'

Data Types: char | string

Alignment options, specified as a character vector, string, or Bowtie2AlignOptions object. The character vector or string must be in the Bowtie 2 option syntax (prefixed by one or two dashes) [1].

For a Bowtie2AlignOptions object, only the modified properties are used to run the function.

Example: '--trim5 10 -s 5'

Output Arguments

collapse all

Exit status of the function, returned as an integer. flag is 0 if the function runs without errors or warning. Otherwise, it is nonzero.

References

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

Version History

Introduced in R2018a