HISAT is an ultrafast and memory-efficient tool for aligning sequencing reads to long reference sequences. It is particularly good at aligning reads of about 50 up to 100s or 1,000s of characters to relatively long (e.g. mammalian) genomes. Bowtie 2 indexes the genome with an FM Index (based on the Burrows-Wheeler Transform or BWT) to keep its memory footprint small: for the human genome, its memory footprint is typically around 3.2 gigabytes of RAM. Bowtie 2 supports gapped, local, and paired-end alignment modes. Multiple processors can be used simultaneously to achieve greater alignment speed. Bowtie 2 outputs alignments in SAM format, enabling interoperation with a large number of other tools (e.g. SAMtools, GATK) that use SAM. Bowtie 2 is distributed under the GPLv3 license, and it runs on the command line under Windows, Mac OS X and Linux.
Bowtie 2 is often the first step in pipelines for comparative genomics, including for variation calling, ChIP-seq, RNA-seq, BS-seq. Bowtie 2 and Bowtie (also called "Bowtie 1" here) are also tightly integrated into some tools, including TopHat: a fast splice junction mapper for RNA-seq reads, Cufflinks: a tool for transcriptome assembly and isoform quantitiation from RNA-seq reads, Crossbow: a cloud-enabled software tool for analyzing reseuqncing data, and Myrna: a cloud-enabled software tool for aligning RNA-seq reads and measuring differential gene expression.
Download Bowtie 2 sources and binaries from the Download section of the Sourceforge site. Binaries are available for Intel architectures (i386
and x86_64
) running Linux, and Mac OS X. A 32-bit version is available for Windows. If you plan to compile Bowtie 2 yourself, make sure to get the source package, i.e., the filename that ends in "-source.zip".
Building Bowtie 2 from source requires a GNU-like environment with GCC, GNU Make and other basics. It should be possible to build Bowtie 2 on most vanilla Linux installations or on a Mac installation with Xcode installed. Bowtie 2 can also be built on Windows using Cygwin or MinGW (MinGW recommended). For a MinGW build the choice of what compiler is to be used is important since this will determine if a 32 or 64 bit code can be successfully compiled using it. If there is a need to generate both 32 and 64 bit on the same machine then a multilib MinGW has to be properly installed. MSYS, the zlib library, and depending on architecture pthreads library are also required. We are recommending a 64 bit build since it has some clear advantages in real life research problems. In order to simplify the MinGW setup it might be worth investigating popular MinGW personal builds since these are coming already prepared with most of the toolchains needed.
First, download the source package from the sourceforge site. Make sure you're getting the source package; the file downloaded should end in -source.zip
. Unzip the file, change to the unzipped directory, and build the Bowtie 2 tools by running GNU make
(usually with the command make
, but sometimes with gmake
) with no arguments. If building with MinGW, run make
from the MSYS environment.
Bowtie 2 is using the multithreading software model in order to speed up execution times on SMP architectures where this is possible. On POSIX platforms (like linux, Mac OS, etc) it needs the pthread library. Although it is possible to use pthread library on non-POSIX platform like Windows, due to performance reasons bowtie 2 will try to use Windows native multithreading if possible.
By adding your new Bowtie 2 directory to your PATH environment variable, you ensure that whenever you run bowtie2
, bowtie2-build
or bowtie2-inspect
from the command line, you will get the version you just installed without having to specify the entire path. This is recommended for most users. To do this, follow your operating system's instructions for adding the directory to your PATH.
If you would like to install Bowtie 2 by copying the Bowtie 2 executable files to an existing directory in your PATH, make sure that you copy all the executables, including bowtie2
, bowtie2-align
, bowtie2-build
and bowtie2-inspect
.
The reporting mode governs how many alignments Bowtie 2 looks for, and how to report them. Bowtie 2 has three distinct reporting modes. The default reporting mode is similar to the default reporting mode of many other read alignment tools, including BWA. It is also similar to Bowtie 1's -M
alignment mode.
In general, when we say that a read has an alignment, we mean that it has a valid alignment. When we say that a read has multiple alignments, we mean that it has multiple alignments that are valid and distinct from one another.
Two alignments for the same individual read are "distinct" if they map the same read to different places. Specifically, we say that two alignments are distinct if there are no alignment positions where a particular read offset is aligned opposite a particular reference offset in both alignments with the same orientation. E.g. if the first alignment is in the forward orientation and aligns the read character at read offset 10 to the reference character at chromosome 3, offset 3,445,245, and the second alignment is also in the forward orientation and also aligns the read character at read offset 10 to the reference character at chromosome 3, offset 3,445,245, they are not distinct alignments.
Two alignments for the same pair are distinct if either the mate 1s in the two paired-end alignments are distinct or the mate 2s in the two alignments are distinct or both.
By default, Bowtie 2 searches for distinct, valid alignments for each read. When it finds a valid alignment, it generally will continue to look for alignments that are nearly as good or better. It will eventually stop looking, either because it exceeded a limit placed on search effort (see [-D
] and -R
) or because it already knows all it needs to know to report an alignment. Information from the best alignments are used to estimate mapping quality (the MAPQ
SAM field) and to set SAM optional fields, such as AS:i
and XS:i
. Bowtie 2 does not gaurantee that the alignment reported is the best possible in terms of alignment score.
See also: [-D
], which puts an upper limit on the number of dynamic programming problems (i.e. seed extensions) that can "fail" in a row before Bowtie 2 stops searching. Increasing [-D
] makes Bowtie 2 slower, but increases the likelihood that it will report the correct alignment for a read that aligns many places.
See also: -R
, which sets the maximum number of times Bowtie 2 will "re-seed" when attempting to align a read with repetitive seeds. Increasing -R
makes Bowtie 2 slower, but increases the likelihood that it will report the correct alignment for a read that aligns many places.
In -k
mode, Bowtie 2 searches for up to N distinct, valid alignments for each read, where N equals the integer specified with the -k
parameter. That is, if -k 2
is specified, Bowtie 2 will search for at most 2 distinct alignments. It reports all alignments found, in descending order by alignment score. The alignment score for a paired-end alignment equals the sum of the alignment scores of the individual mates. Each reported read or pair alignment beyond the first has the SAM 'secondary' bit (which equals 256) set in its FLAGS field. See the SAM specification for details.
Bowtie 2 does not "find" alignments in any specific order, so for reads that have more than N distinct, valid alignments, Bowtie 2 does not gaurantee that the N alignments reported are the best possible in terms of alignment score. Still, this mode can be effective and fast in situations where the user cares more about whether a read aligns (or aligns a certain number of times) than where exactly it originated.
When Bowtie 2 finishes running, it prints messages summarizing what happened. These messages are printed to the "standard error" ("stderr") filehandle. For datasets consisting of unpaired reads, the summary might look like this:
20000 reads; of these:
20000 (100.00%) were unpaired; of these:
1247 (6.24%) aligned 0 times
18739 (93.69%) aligned exactly 1 time
14 (0.07%) aligned >1 times
93.77% overall alignment rate
For datasets consisting of pairs, the summary might look like this:
10000 reads; of these:
10000 (100.00%) were paired; of these:
650 (6.50%) aligned concordantly 0 times
8823 (88.23%) aligned concordantly exactly 1 time
527 (5.27%) aligned concordantly >1 times
----
650 pairs aligned concordantly 0 times; of these:
34 (5.23%) aligned discordantly 1 time
----
616 pairs aligned 0 times concordantly or discordantly; of these:
1232 mates make up the pairs; of these:
660 (53.57%) aligned 0 times
571 (46.35%) aligned exactly 1 time
1 (0.08%) aligned >1 times
96.70% overall alignment rate
The indentation indicates how subtotals relate to totals.
The bowtie2
executable is actually a Perl wrapper script that calls the compiled bowtie2-align
binary. It is recommended that you always run the bowtie2
wrapper and not run bowtie2-align
directly.
Use 64-bit version if possible
The 64-bit version of Bowtie 2 is faster than the 32-bit version, owing to its use of 64-bit arithmetic. If possible, download the 64-bit binaries for Bowtie 2 and run on a 64-bit computer. If you are building Bowtie 2 from sources, you may need to pass the -m64
option to g++
to compile the 64-bit version; you can do this by including BITS=64
in the arguments to the make
command; e.g.: make BITS=64 bowtie2
. To determine whether your version of bowtie is 64-bit or 32-bit, run bowtie2 --version
.
If your computer has multiple processors/cores, use -p
The -p
option causes Bowtie 2 to launch a specified number of parallel search threads. Each thread runs on a different processor/core and all threads find alignments in parallel, increasing alignment throughput by approximately a multiple of the number of threads (though in practice, speedup is somewhat worse than linear).
Some Bowtie 2 options specify a function rather than an individual number or setting. In these cases the user specifies three parameters: (a) a function type F
, (b) a constant term B
, and (c) a coefficient A
. The available function types are constant (C
), linear (L
), square-root (S
), and natural log (G
). The parameters are specified as F,B,A
- that is, the function type, the constant term, and the coefficient are separated by commas with no whitespace. The constant term and coefficient may be negative and/or floating-point numbers.
For example, if the function specification is L,-0.4,-0.6
, then the function defined is:
f(x) = -0.4 + -0.6 * x
If the function specification is G,1,5.4
, then the function defined is:
f(x) = 1.0 + 5.4 * ln(x)
See the documentation for the option in question to learn what the parameter x
is for. For example, in the case if the --score-min
option, the function f(x)
sets the minimum alignment score necessary for an alignment to be considered valid, and x
is the read length.
bowtie2 [options]* -x <bt2-idx> {-1 <m1> -2 <m2> | -U <r>} -S [<hit>]
|
The basename of the index for the reference genome. The basename is the name of any of the index files up to but not including the final |
|
Comma-separated list of files containing mate 1s (filename usually includes |
|
Comma-separated list of files containing mate 2s (filename usually includes |
|
Comma-separated list of files containing unpaired reads to be aligned, e.g. |
|
File to write SAM alignments to. By default, alignments are written to the "standard out" or "stdout" filehandle (i.e. the console). |
|
Reads (specified with |
|
Reads (specified with |
|
Reads (specified with |
|
Reads (specified with |
|
The read sequences are given on command line. I.e. |
|
Skip (i.e. do not align) the first |
|
Align the first |
|
Trim |
|
Trim |
|
Input qualities are ASCII chars equal to the Phred quality plus 33. This is also called the "Phred+33" encoding, which is used by the very latest Illumina pipelines. |
|
Input qualities are ASCII chars equal to the Phred quality plus 64. This is also called the "Phred+64" encoding. |
|
Convert input qualities from Solexa (which can be negative) to Phred (which can't). This scheme was used in older Illumina GA Pipeline versions (prior to 1.3). Default: off. |
|
Quality values are represented in the read input file as space-separated ASCII integers, e.g., |
|
Sets a function governing the maximum number of ambiguous characters (usually |
|
When calculating a mismatch penalty, always consider the quality value at the mismatched position to be the highest possible, regardless of the actual value. I.e. input is treated as though all quality values are high. This is also the default behavior when the input doesn't specify quality values (e.g. in |
|
If |
|
In this mode, Bowtie 2 requires that the entire read align from one end to the other, without any trimming (or "soft clipping") of characters from either end. The match bonus |
|
In this mode, Bowtie 2 does not require that the entire read align from one end to the other. Rather, some characters may be omitted ("soft clipped") from the ends in order to achieve the greatest possible alignment score. The match bonus |
|
Sets the match bonus. In |
|
Sets the maximum ( |
|
Sets penalty for positions where the read, reference, or both, contain an ambiguous character such as |
|
Sets the read gap open ( |
|
Sets the reference gap open ( |
|
Sets a function governing the minimum alignment score needed for an alignment to be considered "valid" (i.e. good enough to report). This is a function of read length. For instance, specifying |
|
By default, When Note: Bowtie 2 is not designed with large values for |
|
Like Note: Bowtie 2 is not designed with |
|
The minimum fragment length for valid paired-end alignments. E.g. if The larger the difference between Default: 0 (essentially imposing no minimum) |
|
The maximum fragment length for valid paired-end alignments. E.g. if The larger the difference between Default: 500. |
|
The upstream/downstream mate orientations for a valid paired-end alignment against the forward reference strand. E.g., if |
|
By default, when |
|
By default, |
|
If the mates "dovetail", that is if one mate alignment extends past the beginning of the other such that the wrong mate begins upstream, consider that to be concordant. See also: Mates can overlap, contain or dovetail each other. Default: mates cannot dovetail in a concordant alignment. |
|
If one mate alignment contains the other, consider that to be non-concordant. See also: Mates can overlap, contain or dovetail each other. Default: a mate can contain the other in a concordant alignment. |
|
If one mate alignment overlaps the other at all, consider that to be non-concordant. See also: Mates can overlap, contain or dovetail each other. Default: mates can overlap in a concordant alignment. |
|
Print the wall-clock time required to load the index files and align the reads. This is printed to the "standard error" ("stderr") filehandle. Default: off. |
|
Write unpaired reads that fail to align to file at |
|
Write unpaired reads that align at least once to file at |
|
Write paired-end reads that fail to align concordantly to file(s) at |
|
Write paired-end reads that align concordantly at least once to file(s) at |
|
Print nothing besides alignments and serious errors. |
|
Write |
|
Write |
|
Write a new |
|
Suppress SAM records for reads that failed to align. |
|
Suppress SAM header lines (starting with |
|
Suppress |
|
Set the read group ID to |
|
Add |
|
When printing secondary alignments, Bowtie 2 by default will write out the |
|
Override the offrate of the index with |
|
Launch |
|
Guarantees that output SAM records are printed in an order corresponding to the order of the reads in the original input file, even when |
|
Use memory-mapped I/O to load the index, rather than typical file I/O. Memory-mapping allows many concurrent |
|
Filter out reads for which the QSEQ filter field is non-zero. Only has an effect when read format is |
|
Use |
|
Normally, Bowtie 2 re-initializes its pseudo-random generator for each read. It seeds the generator with a number derived from (a) the read name, (b) the nucleotide sequence, (c) the quality sequence, (d) the value of the |
|
Print version information and quit. |
|
Print usage information and quit. |
Following is a brief description of the SAM format as output by bowtie2
. For more details, see the SAM format specification.
By default, bowtie2
prints a SAM header with @HD
, @SQ
and @PG
lines. When one or more --rg
arguments are specified, bowtie2
will also print an @RG
line that includes all user-specified --rg
tokens separated by tabs.
Each subsequnt line describes an alignment or, if the read failed to align, a read. Each line is a collection of at least 12 fields separated by tabs; from left to right, the fields are:
Name of read that aligned.
Note that the SAM specification disallows whitespace in the read name. If the read name contains any whitespace characters, Bowtie 2 will truncate the name at the first whitespace character. This is similar to the behavior of other tools.
Sum of all applicable flags. Flags relevant to Bowtie are:
|
The read is one of a pair |
|
The alignment is one end of a proper paired-end alignment |
|
The read has no reported alignments |
|
The read is one of a pair and has no reported alignments |
|
The alignment is to the reverse reference strand |
|
The other mate in the paired-end alignment is aligned to the reverse reference strand |
|
The read is mate 1 in a pair |
|
The read is mate 2 in a pair |
Thus, an unpaired read that aligns to the reverse reference strand will have flag 16. A paired-end read that aligns and is the first mate in the pair will have flag 83 (= 64 + 16 + 2 + 1).
Name of reference sequence where alignment occurs
1-based offset into the forward reference strand where leftmost character of the alignment occurs
Mapping quality
CIGAR string representation of alignment
Name of reference sequence where mate's alignment occurs. Set to =
if the mate's reference sequence is the same as this alignment's, or *
if there is no mate.
1-based offset into the forward reference strand where leftmost character of the mate's alignment occurs. Offset is 0 if there is no mate.
Inferred fragment length. Size is negative if the mate's alignment occurs upstream of this alignment. Size is 0 if the mates did not align concordantly. However, size is non-0 if the mates aligned discordantly to the same chromosome.
Read sequence (reverse-complemented if aligned to the reverse strand)
ASCII-encoded read qualities (reverse-complemented if the read aligned to the reverse strand). The encoded quality values are on the Phred quality scale and the encoding is ASCII-offset by 33 (ASCII char !
), similarly to a FASTQ file.
Optional fields. Fields are tab-separated. bowtie2
outputs zero or more of these optional fields for each alignment, depending on the type of the alignment:
The
|
|
A comma-separated list of FASTA files containing the reference sequences to be aligned to, or, if |
|
The basename of the index files to write. By default, |
|
The reference input files (specified as |
|
The reference sequences are given on the command line. I.e. |
|
Disable the default behavior whereby |
|
Use a packed (2-bits-per-nucleotide) representation for DNA strings. This saves memory but makes indexing 2-3 times slower. Default: off. This is configured automatically by default; use |
|
The maximum number of suffixes allowed in a block. Allowing more suffixes per block makes indexing faster, but increases peak memory usage. Setting this option overrides any previous setting for |
|
The maximum number of suffixes allowed in a block, expressed as a fraction of the length of the reference. Setting this option overrides any previous setting for |
|
Use |
|
Disable use of the difference-cover sample. Suffix sorting becomes quadratic-time in the worst case (where the worst case is an extremely repetitive reference). Default: off. |
|
Do not build the |
|
Build only the |
|
To map alignments back to positions on the reference sequences, it's necessary to annotate ("mark") some or all of the Burrows-Wheeler rows with their corresponding location on the genome. |
|
The ftab is the lookup table used to calculate an initial Burrows-Wheeler range with respect to the first |
|
Use |
|
Index only the first |
|
|
|
Print usage information and quit. |
|
Print version information and quit. |
bowtie2-inspect
index inspectorbowtie2-inspect
extracts information from a Bowtie index about what kind of index it is and what reference sequences were used to build it. When run without any options, the tool will output a FASTA file containing the sequences of the original references (with all non-A
/C
/G
/T
characters converted to N
s). It can also be used to extract just the reference sequence names using the -n
/--names
option or a more verbose summary using the -s
/--summary
option.
Usage:
bowtie2-inspect [options]* <bt2_base>
|
The basename of the index to be inspected. The basename is name of any of the index files but with the |
|
When printing FASTA output, output a newline character every |
|
Print reference sequence names, one per line, and quit. |
|
Print a summary that includes information about index settings, as well as the names and lengths of the input sequences. The summary has this format:
Fields are separated by tabs. Colorspace is always set to 0 for Bowtie 2. |
|
Print verbose output (for debugging). |
|
Print version information and quit. |
|
Print usage information and quit. |
Bowtie 2 comes with some example files to get you started. The example files are not scientifically significant; we use the Lambda phage reference genome simply because it's short, and the reads were generated by a computer program, not a sequencer. However, these files will let you start running Bowtie 2 and downstream tools right away.
First follow the manual instructions to obtain Bowtie 2. Set the BT2_HOME
environment variable to point to the new Bowtie 2 directory containing the bowtie2
, bowtie2-build
and bowtie2-inspect
binaries. This is important, as the BT2_HOME
variable is used in the commands below to refer to that directory.
To create an index for the Lambda phage reference genome included with Bowtie 2, create a new temporary directory (it doesn't matter where), change into that directory, and run:
$BT2_HOME/bowtie2-build $BT2_HOME/example/reference/lambda_virus.fa lambda_virus
The command should print many lines of output then quit. When the command completes, the current directory will contain four new files that all start with lambda_virus
and end with .1.bt2
, .2.bt2
, .3.bt2
, .4.bt2
, .rev.1.bt2
, and .rev.2.bt2
. These files constitute the index - you're done!
You can use bowtie2-build
to create an index for a set of FASTA files obtained from any source, including sites such as UCSC, NCBI, and Ensembl. When indexing multiple FASTA files, specify all the files using commas to separate file names. For more details on how to create an index with bowtie2-build
, see the manual section on index building. You may also want to bypass this process by obtaining a pre-built index. See using a pre-built index below for an example.
Stay in the directory created in the previous step, which now contains the lambda_virus
index files. Next, run:
$BT2_HOME/bowtie2 -x lambda_virus -U $BT2_HOME/example/reads/reads_1.fq -S eg1.sam
This runs the Bowtie 2 aligner, which aligns a set of unpaired reads to the Lambda phage reference genome using the index generated in the previous step. The alignment results in SAM format are written to the file eg1.sam
, and a short alignment summary is written to the console. (Actually, the summary is written to the "standard error" or "stderr" filehandle, which is typically printed to the console.)
To see the first few lines of the SAM output, run:
head eg1.sam
You will see something like this:
@HD VN:1.0 SO:unsorted
@SQ SN:gi|9626243|ref|NC_001416.1| LN:48502
@PG ID:bowtie2 PN:bowtie2 VN:2.0.1
r1 0 gi|9626243|ref|NC_001416.1| 18401 42 122M * 0 0 TGAATGCGAACTCCGGGACGCTCAGTAATGTGACGATAGCTGAAAACTGTACGATAAACNGTACGCTGAGGGCAGAAAAAATCGTCGGGGACATTNTAAAGGCGGCGAGCGCGGCTTTTCCG +"@6<:27(F&5)9)"B:%B+A-%5A?2$HCB0B+0=D<7E/<.03#!.F77@6B==?C"7>;))%;,3-$.A06+<-1/@@?,26">=?*@'0;$:;??G+:#+(A?9+10!8!?()?7C> AS:i:-5 XN:i:0 XM:i:3 XO:i:0 XG:i:0 NM:i:3 MD:Z:59G13G21G26 YT:Z:UU
r2 0 gi|9626243|ref|NC_001416.1| 8886 42 275M * 0 0 NTTNTGATGCGGGCTTGTGGAGTTCAGCCGATCTGACTTATGTCATTACCTATGAAATGTGAGGACGCTATGCCTGTACCAAATCCTACAATGCCGGTGAAAGGTGCCGGGATCACCCTGTGGGTTTATAAGGGGATCGGTGACCCCTACGCGAATCCGCTTTCAGACGTTGACTGGTCGCGTCTGGCAAAAGTTAAAGACCTGACGCCCGGCGAACTGACCGCTGAGNCCTATGACGACAGCTATCTCGATGATGAAGATGCAGACTGGACTGC (#!!'+!$""%+(+)'%)%!+!(&++)''"#"#&#"!'!("%'""("+&%$%*%%#$%#%#!)*'(#")(($&$'&%+&#%*)*#*%*')(%+!%%*"$%"#+)$&&+)&)*+!"*)!*!("&&"*#+"&"'(%)*("'!$*!!%$&&&$!!&&"(*"$&"#&!$%'%"#)$#+%*+)!&*)+(""#!)!%*#"*)*')&")($+*%%)!*)!('(%""+%"$##"#+(('!*(($*'!"*('"+)&%#&$+('**$$&+*&!#%)')'(+(!%+ AS:i:-14 XN:i:0 XM:i:8 XO:i:0 XG:i:0 NM:i:8 MD:Z:0A0C0G0A108C23G9T81T46 YT:Z:UU
r3 16 gi|9626243|ref|NC_001416.1| 11599 42 338M * 0 0 GGGCGCGTTACTGGGATGATCGTGAAAAGGCCCGTCTTGCGCTTGAAGCCGCCCGAAAGAAGGCTGAGCAGCAGACTCAAGAGGAGAAAAATGCGCAGCAGCGGAGCGATACCGAAGCGTCACGGCTGAAATATACCGAAGAGGCGCAGAAGGCTNACGAACGGCTGCAGACGCCGCTGCAGAAATATACCGCCCGTCAGGAAGAACTGANCAAGGCACNGAAAGACGGGAAAATCCTGCAGGCGGATTACAACACGCTGATGGCGGCGGCGAAAAAGGATTATGAAGCGACGCTGTAAAAGCCGAAACAGTCCAGCGTGAAGGTGTCTGCGGGCGAT 7F$%6=$:9B@/F'>=?!D?@0(:A*)7/>9C>6#1<6:C(.CC;#.;>;2'$4D:?&B!>689?(0(G7+0=@37F)GG=>?958.D2E04C<E,*AD%G0.%$+A:'H;?8<72:88?E6((CF)6DF#.)=>B>D-="C'B080E'5BH"77':"@70#4%A5=6.2/1>;9"&-H6)=$/0;5E:<8G!@::1?2DC7C*;@*#.1C0.D>H/20,!"C-#,6@%<+<D(AG-).?�.00'@)/F8?B!&"170,)>:?<A7#1(A@0E#&A.*DC.E")AH"+.,5,2>5"2?:G,F"D0B8D-6$65D<D!A/38860.*4;4B<*31?6 AS:i:-22 XN:i:0 XM:i:8 XO:i:0 XG:i:0 NM:i:8 MD:Z:80C4C16A52T23G30A8T76A41 YT:Z:UU
r4 0 gi|9626243|ref|NC_001416.1| 40075 42 184M * 0 0 GGGCCAATGCGCTTACTGATGCGGAATTACGCCGTAAGGCCGCAGATGAGCTTGTCCATATGACTGCGAGAATTAACNGTGGTGAGGCGATCCCTGAACCAGTAAAACAACTTCCTGTCATGGGCGGTAGACCTCTAAATCGTGCACAGGCTCTGGCGAAGATCGCAGAAATCAAAGCTAAGT(=8B)GD04*G%&4F,1'A>.C&7=F$,+#6!))43C,5/5+)?-/0>/D3=-,2/+.1?@->;)00!'3!7BH$G)HG+ADC'#-9F)7<7"$?&.>0)@5;4,!0-#C!15CF8&HB+B==H>7,/)C5)5*+(F5A%D,EA<(>G9E0>7&/E?4%;#'92)<5+@7:A.(BG@BG86@.G AS:i:-1 XN:i:0 XM:i:1 XO:i:0 XG:i:0 NM:i:1 MD:Z:77C106 YT:Z:UU
r5 0 gi|9626243|ref|NC_001416.1| 48010 42 138M * 0 0 GTCAGGAAAGTGGTAAAACTGCAACTCAATTACTGCAATGCCCTCGTAATTAAGTGAATTTACAATATCGTCCTGTTCGGAGGGAAGAACGCGGGATGTTCATTCTTCATCACTTTTAATTGATGTATATGCTCTCTT 9''%<D)A03E1-*7=),:F/0!6,D9:H,<9D%:0B(%'E,(8EFG$E89B$27G8F*2+4,-!,0D5()&=(FGG:5;3*@/.0F-G#5#3->('FDFEG?)5.!)"AGADB3?6(@H(:B<>6!>;>6>G,."?% AS:i:0 XN:i:0 XM:i:0 XO:i:0 XG:i:0 NM:i:0 MD:Z:138 YT:Z:UU
r6 16 gi|9626243|ref|NC_001416.1| 41607 42 72M2D119M * 0 0 TCGATTTGCAAATACCGGAACATCTCGGTAACTGCATATTCTGCATTAAAAAATCAACGCAAAAAATCGGACGCCTGCAAAGATGAGGAGGGATTGCAGCGTGTTTTTAATGAGGTCATCACGGGATNCCATGTGCGTGACGGNCATCGGGAAACGCCAAAGGAGATTATGTACCGAGGAAGAATGTCGCT 1H#G;H"$E*E#&"*)2%66?=9/9'=;4)4/>@%+5#@#$4A*!<D=="8#1*A9BA=:(1+#C&.#(3#H=9E)AC*5,AC#E'536*2?)H14?>9'B=7(3H/B:+A:8%1-+#(E%&$$&14"76D?>7(&20H5%*&CF8!G5B+A4F$7(:"'?0$?G+$)B-?2<0<F=D!38BH,%=8&5@+ AS:i:-13 XN:i:0 XM:i:2 XO:i:1 XG:i:2 NM:i:4 MD:Z:72^TT55C15A47 YT:Z:UU
r7 16 gi|9626243|ref|NC_001416.1| 4692 42 143M * 0 0 TCAGCCGGACGCGGGCGCTGCAGCCGTACTCGGGGATGACCGGTTACAACGGCATTATCGCCCGTCTGCAACAGGCTGCCAGCGATCCGATGGTGGACAGCATTCTGCTCGATATGGACANGCCCGGCGGGATGGTGGCGGGG -"/@*7A0)>2,AAH@&"%B)*5*23B/,)90.B@%=FE,E063C9?,:26$-0:,.,1849'4.;F>FA;76+5&$<C":$!A*,<B,<)@<'85D%C*:)30@85;?.B$05=@95DCDH<53!8G:F:B7/A.E':434> AS:i:-6 XN:i:0 XM:i:2 XO:i:0 XG:i:0 NM:i:2 MD:Z:98G21C22 YT:Z:UU
The first few lines (beginning with @
) are SAM header lines, and the rest of the lines are SAM alignments, one line per read or mate. See the Bowtie 2 manual section on SAM output and the SAM specification for details about how to interpret the SAM file format.
To align paired-end reads included with Bowtie 2, stay in the same directory and run:
$BT2_HOME/bowtie2 -x lambda_virus -1 $BT2_HOME/example/reads/reads_1.fq -2 $BT2_HOME/example/reads/reads_2.fq -S eg2.sam
This aligns a set of paired-end reads to the reference genome, with results written to the file eg2.sam
.
To use local alignment to align some longer reads included with Bowtie 2, stay in the same directory and run:
$BT2_HOME/bowtie2 --local -x lambda_virus -U $BT2_HOME/example/reads/longreads.fq -S eg3.sam
This aligns the long reads to the reference genome using local alignment, with results written to the file eg3.sam
.
SAMtools is a collection of tools for manipulating and analyzing SAM and BAM alignment files. BCFtools is a collection of tools for calling variants and manipulating VCF and BCF files, and it is typically distributed with SAMtools. Using these tools together allows you to get from alignments in SAM format to variant calls in VCF format. This example assumes that samtools
and bcftools
are installed and that the directories containing these binaries are in your PATH environment variable.
Run the paired-end example:
$BT2_HOME/bowtie2 -x $BT2_HOME/example/index/lambda_virus -1 $BT2_HOME/example/reads/reads_1.fq -2 $BT2_HOME/example/reads/reads_2.fq -S eg2.sam
Use samtools view
to convert the SAM file into a BAM file. BAM is a the binary format corresponding to the SAM text format. Run:
samtools view -bS eg2.sam > eg2.bam
Use samtools sort
to convert the BAM file to a sorted BAM file.
samtools sort eg2.bam eg2.sorted
We now have a sorted BAM file called eg2.sorted.bam
. Sorted BAM is a useful format because the alignments are (a) compressed, which is convenient for long-term storage, and (b) sorted, which is conveneint for variant discovery. To generate variant calls in VCF format, run:
samtools mpileup -uf $BT2_HOME/example/reference/lambda_virus.fa eg2.sorted.bam | bcftools view -bvcg - > eg2.raw.bcf
Then to view the variants, run:
bcftools view eg2.raw.bcf
See the official SAMtools guide to Calling SNPs/INDELs with SAMtools/BCFtools for more details and variations on this process.