1bwa(1)                       Bioinformatics tools                       bwa(1)
2
3
4

NAME

6       bwa - Burrows-Wheeler Alignment Tool
7

SYNOPSIS

9       bwa index ref.fa
10
11       bwa mem ref.fa reads.fq > aln-se.sam
12
13       bwa mem ref.fa read1.fq read2.fq > aln-pe.sam
14
15       bwa aln ref.fa short_read.fq > aln_sa.sai
16
17       bwa samse ref.fa aln_sa.sai short_read.fq > aln-se.sam
18
19       bwa sampe ref.fa aln_sa1.sai aln_sa2.sai read1.fq read2.fq > aln-pe.sam
20
21       bwa bwasw ref.fa long_read.fq > aln.sam
22
23

DESCRIPTION

25       BWA is a software package for mapping low-divergent sequences against a
26       large reference genome, such as the human genome. It consists of  three
27       algorithms:  BWA-backtrack,  BWA-SW and BWA-MEM. The first algorithm is
28       designed for Illumina sequence reads up to 100bp, while  the  rest  two
29       for longer sequences ranged from 70bp to 1Mbp. BWA-MEM and BWA-SW share
30       similar features such as long-read support  and  split  alignment,  but
31       BWA-MEM, which is the latest, is generally recommended for high-quality
32       queries as it is faster and more accurate.   BWA-MEM  also  has  better
33       performance than BWA-backtrack for 70-100bp Illumina reads.
34
35       For  all  the algorithms, BWA first needs to construct the FM-index for
36       the reference genome (the  index  command).  Alignment  algorithms  are
37       invoked with different sub-commands: aln/samse/sampe for BWA-backtrack,
38       bwasw for BWA-SW and mem for the BWA-MEM algorithm.
39
40

COMMANDS AND OPTIONS

42       index  bwa index [-p prefix] [-a algoType] db.fa
43
44              Index database sequences in the FASTA format.
45
46              OPTIONS:
47
48              -p STR    Prefix of the output database [same as db filename]
49
50              -a STR    Algorithm for constructing BWT index.  BWA  implements
51                        three  algorithms  for BWT construction: is, bwtsw and
52                        rb2.  The first algorithm is a little faster for small
53                        database  but requires large RAM and does not work for
54                        databases with total length longer than 2GB. The  sec‐
55                        ond  algorithm is adapted from the BWT-SW source code.
56                        It in theory works with  database  with  trillions  of
57                        bases.  When  this option is not specified, the appro‐
58                        priate algorithm will be chosen automatically.
59
60
61       mem    bwa mem [-aCHjMpP] [-t nThreads] [-k minSeedLen] [-w  bandWidth]
62              [-d  zDropoff]  [-r seedSplitRatio] [-c maxOcc] [-D chainShadow]
63              [-m maxMateSW] [-W minSeedMatch] [-A matchScore] [-B  mmPenalty]
64              [-O  gapOpenPen]  [-E gapExtPen] [-L clipPen] [-U unpairPen] [-x
65              readType] [-R RGline] [-H HDlines] [-v  verboseLevel]  db.prefix
66              reads.fq [mates.fq]
67
68              Align  70bp-1Mbp  query  sequences  with  the BWA-MEM algorithm.
69              Briefly, the algorithm works by seeding alignments with  maximal
70              exact  matches  (MEMs) and then extending seeds with the affine-
71              gap Smith-Waterman algorithm (SW).
72
73              If mates.fq file is absent and option -p is not set,  this  com‐
74              mand regards input reads are single-end. If mates.fq is present,
75              this command assumes the i-th read in reads.fq and the i-th read
76              in  mates.fq  constitute a read pair. If -p is used, the command
77              assumes the 2i-th and the (2i+1)-th read in reads.fq  constitute
78              a read pair (such input file is said to be interleaved). In this
79              case, mates.fq is ignored. In the paired-end mode, the mem  com‐
80              mand will infer the read orientation and the insert size distri‐
81              bution from a batch of reads.
82
83              The BWA-MEM algorithm performs local alignment. It  may  produce
84              multiple  primary  alignments  for  different  part  of  a query
85              sequence. This is a crucial feature for long sequences. However,
86              some  tools  such  as Picard's markDuplicates does not work with
87              split alignments. One may consider to  use  option  -M  to  flag
88              shorter split hits as secondary.
89
90
91              ALGORITHM OPTIONS:
92
93              -t INT    Number of threads [1]
94
95              -k INT    Minimum  seed length. Matches shorter than INT will be
96                        missed. The alignment speed is usually insensitive  to
97                        this  value  unless it significantly deviates from 20.
98                        [19]
99
100              -w INT    Band width. Essentially, gaps longer than INT will not
101                        be  found.  Note  that  the maximum gap length is also
102                        affected by the scoring matrix and the hit length, not
103                        solely determined by this option. [100]
104
105              -d INT    Off-diagonal  X-dropoff  (Z-dropoff).  Stop  extension
106                        when the difference between the best and  the  current
107                        extension  score  is  above |i-j|*A+INT, where i and j
108                        are the current positions of the query and  reference,
109                        respectively,  and  A is the matching score. Z-dropoff
110                        is similar to BLAST's X-dropoff except that it doesn't
111                        penalize  gaps  in  one of the sequences in the align‐
112                        ment. Z-dropoff not only avoids unnecessary extension,
113                        but  also  reduces  poor alignments inside a long good
114                        alignment. [100]
115
116              -r FLOAT  Trigger  re-seeding  for  a  MEM  longer   than   min‐
117                        SeedLen*FLOAT.   This is a key heuristic parameter for
118                        tuning the  performance.  Larger  value  yields  fewer
119                        seeds, which leads to faster alignment speed but lower
120                        accuracy. [1.5]
121
122              -c INT    Discard a MEM if it has more than INT occurence in the
123                        genome. This is an insensitive parameter. [500]
124
125              -D FLOAT  Drop chains shorter than FLOAT fraction of the longest
126                        overlapping chain [0.5]
127
128              -m INT    Perform at most INT rounds of mate-SW [50]
129
130              -W INT    Drop a chain if  the  number  of  bases  in  seeds  is
131                        smaller  than  INT.  This option is primarily used for
132                        longer contigs/reads. When positive, it  also  affects
133                        seed filtering. [0]
134
135              -P        In  the  paired-end mode, perform SW to rescue missing
136                        hits only but do not try  to  find  hits  that  fit  a
137                        proper pair.
138
139
140              SCORING OPTIONS:
141
142              -A INT    Matching score. [1]
143
144              -B INT    Mismatch  penalty. The sequence error rate is approxi‐
145                        mately: {.75 * exp[-log(4) * B/A]}. [4]
146
147              -O INT[,INT]
148                        Gap open penalty. If two numbers  are  specified,  the
149                        first  is  the  penalty of openning a deletion and the
150                        second for openning an insertion. [6]
151
152              -E INT[,INT]
153                        Gap extension penalty. If two numbers  are  specified,
154                        the  first  is the penalty of extending a deletion and
155                        second for extending an insertion. A gap of  length  k
156                        costs  O  + k*E (i.e.  -O is for opening a zero-length
157                        gap). [1]
158
159              -L INT[,INT]
160                        Clipping penalty. When performing SW  extension,  BWA-
161                        MEM  keeps track of the best score reaching the end of
162                        query. If this score is larger than the best SW  score
163                        minus  the  clipping  penalty,  clipping  will  not be
164                        applied. Note that  in  this  case,  the  SAM  AS  tag
165                        reports  the  best  SW  score; clipping penalty is not
166                        deduced. If two numbers are provided, the first is for
167                        5'-end clipping and second for 3'-end clipping. [5]
168
169              -U INT    Penalty  for  an unpaired read pair. BWA-MEM scores an
170                        unpaired read pair  as  scoreRead1+scoreRead2-INT  and
171                        scores   a   paired  as  scoreRead1+scoreRead2-insert‐
172                        Penalty. It compares these  two  scores  to  determine
173                        whether  we should force pairing. A larger value leads
174                        to more aggressive read pair. [17]
175
176              -x STR    Read type. Changes multiple parameters unless  overri‐
177                        den [null]
178
179                        pacbio:   -k17  -W40  -r10 -A1 -B1 -O1 -E1 -L0 (PacBio
180                                  reads to ref)
181
182                        ont2d:    -k14 -W20 -r10 -A1 -B1 -O1 -E1  -L0  (Oxford
183                                  Nanopore 2D-reads to ref)
184
185                        intractg: -B9 -O16 -L5 (intra-species contigs to ref)
186
187              INPUT/OUTPUT OPTIONS:
188
189              -p        Smart  pairing.  If  two  adjacent reads have the same
190                        name, they are considered to form a  read  pair.  This
191                        way, paired-end and single-end reads can be mixed in a
192                        single FASTA/Q stream.
193
194              -R STR    Complete read group header line. '\t' can be  used  in
195                        STR  and will be converted to a TAB in the output SAM.
196                        The read group ID will be attached to  every  read  in
197                        the   output.  An  example  is  '@RG\tID:foo\tSM:bar'.
198                        [null]
199
200              -H ARG    If ARG starts with @, it is interpreted  as  a  string
201                        and  gets  inserted into the output SAM header; other‐
202                        wise, ARG is interpreted as  a  file  with  all  lines
203                        starting  with  @  in  the  file inserted into the SAM
204                        header. [null]
205
206              -o FILE   Write the output SAM file to FILE.  For  compatibility
207                        with other BWA commands, this option may also be given
208                        as -f FILE.  [standard ouptut]
209
210              -q
211                         Don't reduce the mapping quality of  split  alignment
212                        of lower alignment score.
213
214              -5        For  split alignment, mark the segment with the small‐
215                        est  coordinate  as  the  primary.  It   automatically
216                        applies  option  -q as well. This option may help some
217                        Hi-C pipelines.  By  default,  BWA-MEM  marks  highest
218                        scoring segment as primary.
219
220              -K  INT   Process  INT  input  bases in each batch regardless of
221                        the number of threads in use [10000000*nThreads].   By
222                        default,  the batch size is proportional to the number
223                        of threads in use.  Because the inferred  insert  size
224                        distribution slightly depends on the batch size, using
225                        different number of threads may produce different out‐
226                        put.  Specifying this option helps reproducibility.
227
228              -T INT    Don't  output  alignment  with  score  lower than INT.
229                        This option affects output and occasionally  SAM  flag
230                        2. [30]
231
232              -j        Treat  ALT  contigs  as  part  of the primary assembly
233                        (i.e. ignore the db.prefix.alt file).
234
235              -h INT[,INT2]
236                        If a query has not  more  than  INT  hits  with  score
237                        higher  than  80%  of the best hit, output them all in
238                        the XA tag.  If INT2 is specified, BWA-MEM outputs  up
239                        to INT2 hits if the list contains a hit to an ALT con‐
240                        tig. [5,200]
241
242              -a        Output all found alignments for single-end or unpaired
243                        paired-end  reads. These alignments will be flagged as
244                        secondary alignments.
245
246              -C        Append FASTA/Q comment to SAM output. This option  can
247                        be  used  to transfer read meta information (e.g. bar‐
248                        code) to the SAM output. Note that the FASTA/Q comment
249                        (the  string  after  a  space in the header line) must
250                        conform the SAM spec  (e.g.  BC:Z:CGTAC).  Malformated
251                        comments lead to incorrect SAM output.
252
253              -Y        Use  soft  clipping  CIGAR operation for supplementary
254                        alignments. By default, BWA-MEM uses soft clipping for
255                        the primary alignment and hard clipping for supplemen‐
256                        tary alignments.
257
258              -M        Mark shorter split hits as secondary (for Picard  com‐
259                        patibility).
260
261              -v INT    Control the verbosity level of the output. This option
262                        has not been fully supported throughout BWA.  Ideally,
263                        a  value  0  for disabling all the output to stderr; 1
264                        for outputting errors only; 2 for warnings and errors;
265                        3  for all normal messages; 4 or higher for debugging.
266                        When this option takes value 4, the output is not SAM.
267                        [3]
268
269              -I FLOAT[,FLOAT[,INT[,INT]]]
270                        Specify  the mean, standard deviation (10% of the mean
271                        if absent), max (4 sigma from the mean if absent)  and
272                        min  (4  sigma if absent) of the insert size distribu‐
273                        tion.  Only  applicable  to  the  FR  orientation.  By
274                        default,  BWA-MEM  infers  these  numbers and the pair
275                        orientations given enough reads. [inferred]
276
277
278
279       aln    bwa aln [-n maxDiff] [-o maxGapO] [-e maxGapE] [-d nDelTail] [-i
280              nIndelEnd]  [-k maxSeedDiff] [-l seedLen] [-t nThrds] [-cRN] [-M
281              misMsc] [-O gapOsc]  [-E  gapEsc]  [-q  trimQual]  <in.db.fasta>
282              <in.query.fq> > <out.sai>
283
284              Find  the SA coordinates of the input reads. Maximum maxSeedDiff
285              differences are allowed in the  first  seedLen  subsequence  and
286              maximum maxDiff differences are allowed in the whole sequence.
287
288              OPTIONS:
289
290              -n NUM    Maximum  edit  distance  if  the  value is INT, or the
291                        fraction of missing alignments given 2%  uniform  base
292                        error  rate  if FLOAT. In the latter case, the maximum
293                        edit distance is automatically  chosen  for  different
294                        read lengths. [0.04]
295
296              -o INT    Maximum number of gap opens [1]
297
298              -e INT    Maximum  number of gap extensions, -1 for k-difference
299                        mode (disallowing long gaps) [-1]
300
301              -d INT    Disallow a long deletion within  INT  bp  towards  the
302                        3'-end [16]
303
304              -i INT    Disallow an indel within INT bp towards the ends [5]
305
306              -l INT    Take  the  first  INT  subsequence  as seed. If INT is
307                        larger than the query sequence, seeding will  be  dis‐
308                        abled. For long reads, this option is typically ranged
309                        from 25 to 35 for `-k 2'. [inf]
310
311              -k INT    Maximum edit distance in the seed [2]
312
313              -t INT    Number of threads (multi-threading mode) [1]
314
315              -M INT    Mismatch penalty. BWA will not search  for  suboptimal
316                        hits with a score lower than (bestScore-misMsc). [3]
317
318              -O INT    Gap open penalty [11]
319
320              -E INT    Gap extension penalty [4]
321
322              -R INT    Proceed  with  suboptimal  alignments  if there are no
323                        more than INT equally  best  hits.  This  option  only
324                        affects  paired-end mapping. Increasing this threshold
325                        helps to improve the pairing accuracy at the  cost  of
326                        speed, especially for short reads (~32bp).
327
328              -c        Reverse query but not complement it, which is required
329                        for alignment in  the  color  space.  (Disabled  since
330                        0.6.x)
331
332              -N        Disable  iterative  search. All hits with no more than
333                        maxDiff differences will be found. This mode  is  much
334                        slower than the default.
335
336              -q INT    Parameter  for read trimming. BWA trims a read down to
337                        argmax_x{\sum_{i=x+1}^l(INT-q_i)} if q_l<INT  where  l
338                        is the original read length. [0]
339
340              -I        The input is in the Illumina 1.3+ read format (quality
341                        equals ASCII-64).
342
343              -B INT    Length of barcode starting from the 5'-end.  When  INT
344                        is  positive, the barcode of each read will be trimmed
345                        before mapping and will be written at the BC SAM  tag.
346                        For  paired-end  reads, the barcode from both ends are
347                        concatenated. [0]
348
349              -b        Specify the input read sequence file is the  BAM  for‐
350                        mat.  For  paired-end data, two ends in a pair must be
351                        grouped together and options  -1  or  -2  are  usually
352                        applied to specify which end should be mapped. Typical
353                        command lines for mapping pair-end  data  in  the  BAM
354                        format are:
355
356                            bwa aln ref.fa -b1 reads.bam > 1.sai
357                            bwa aln ref.fa -b2 reads.bam > 2.sai
358                            bwa sampe ref.fa 1.sai 2.sai reads.bam reads.bam >
359                        aln.sam
360
361              -0        When -b is specified, only  use  single-end  reads  in
362                        mapping.
363
364              -1        When  -b  is  specified,  only use the first read in a
365                        read pair in mapping (skip single-end  reads  and  the
366                        second reads).
367
368              -2        When  -b  is  specified, only use the second read in a
369                        read pair in mapping.
370
371
372       samse  bwa samse [-n maxOcc] <in.db.fasta> <in.sai> <in.fq> > <out.sam>
373
374              Generate alignments in the SAM format  given  single-end  reads.
375              Repetitive hits will be randomly chosen.
376
377              OPTIONS:
378
379              -n INT    Maximum  number  of alignments to output in the XA tag
380                        for reads paired properly. If a read has more than INT
381                        hits, the XA tag will not be written. [3]
382
383              -r STR    Specify    the   read   group   in   a   format   like
384                        `@RG\tID:foo\tSM:bar'. [null]
385
386
387       sampe  bwa sampe [-a maxInsSize] [-o maxOcc] [-n maxHitPaired] [-N max‐
388              HitDis] [-P] <in.db.fasta> <in1.sai> <in2.sai> <in1.fq> <in2.fq>
389              > <out.sam>
390
391              Generate alignments in the SAM format  given  paired-end  reads.
392              Repetitive read pairs will be placed randomly.
393
394              OPTIONS:
395
396              -a INT  Maximum  insert  size  for  a read pair to be considered
397                      being mapped properly. Since 0.4.5, this option is  only
398                      used  when  there are not enough good alignment to infer
399                      the distribution of insert sizes. [500]
400
401              -o INT  Maximum occurrences of a read for pairing. A  read  with
402                      more  occurrneces  will be treated as a single-end read.
403                      Reducing this parameter helps faster pairing. [100000]
404
405              -P      Load the entire FM-index  into  memory  to  reduce  disk
406                      operations (base-space reads only). With this option, at
407                      least 1.25N bytes of memory are required, where N is the
408                      length of the genome.
409
410              -n INT  Maximum number of alignments to output in the XA tag for
411                      reads paired properly. If a read has more than INT hits,
412                      the XA tag will not be written. [3]
413
414              -N INT  Maximum number of alignments to output in the XA tag for
415                      disconcordant read pairs (excluding  singletons).  If  a
416                      read  has  more  than  INT  hits, the XA tag will not be
417                      written. [10]
418
419              -r STR  Specify   the   read   group   in    a    format    like
420                      `@RG\tID:foo\tSM:bar'. [null]
421
422
423       bwasw  bwa  bwasw  [-a  matchScore]  [-b  mmPen]  [-q  gapOpenPen]  [-r
424              gapExtPen] [-t nThreads] [-w bandWidth] [-T thres] [-s  hspIntv]
425              [-z  zBest]  [-N  nHspRev]  [-c thresCoef] <in.db.fasta> <in.fq>
426              [mate.fq]
427
428              Align query  sequences  in  the  in.fq  file.  When  mate.fq  is
429              present,  perform paired-end alignment. The paired-end mode only
430              works for reads Illumina short-insert libraries. In the  paired-
431              end  mode, BWA-SW may still output split alignments but they are
432              all marked as not properly paired; the mate positions  will  not
433              be written if the mate has multiple local hits.
434
435              OPTIONS:
436
437              -a INT    Score of a match [1]
438
439              -b INT    Mismatch penalty [3]
440
441              -q INT    Gap open penalty [5]
442
443              -r INT    Gap  extension  penalty.  The penalty for a contiguous
444                        gap of size k is q+k*r. [2]
445
446              -t INT    Number of threads in the multi-threading mode [1]
447
448              -w INT    Band width in the banded alignment [33]
449
450              -T INT    Minimum score threshold divided by a [37]
451
452              -c FLOAT  Coefficient  for  threshold  adjustment  according  to
453                        query length. Given an l-long query, the threshold for
454                        a hit to be retained is a*max{T,c*log(l)}. [5.5]
455
456              -z INT    Z-best heuristics. Higher -z increases accuracy at the
457                        cost of speed. [1]
458
459              -s INT    Maximum SA interval size for initiating a seed. Higher
460                        -s increases accuracy at the cost of speed. [3]
461
462              -N INT    Minimum  number  of  seeds  supporting  the  resultant
463                        alignment to skip reverse alignment. [5]
464
465

SAM ALIGNMENT FORMAT

467       The  output  of  the  `aln'  command is binary and designed for BWA use
468       only. BWA outputs the final  alignment  in  the  SAM  (Sequence  Align‐
469       ment/Map) format. Each line consists of:
470
471
472       ┌────┬───────┬──────────────────────────────────────────────────────────┐
473Col Field Description                        
474       ├────┼───────┼──────────────────────────────────────────────────────────┤
475       │ 1  │ QNAME │ Query (pair) NAME                                        │
476       │ 2  │ FLAG  │ bitwise FLAG                                             │
477       │ 3  │ RNAME │ Reference sequence NAME                                  │
478       │ 4  │ POS   │ 1-based leftmost POSition/coordinate of clipped sequence │
479       │ 5  │ MAPQ  │ MAPping Quality (Phred-scaled)                           │
480       │ 6  │ CIAGR │ extended CIGAR string                                    │
481       │ 7  │ MRNM  │ Mate Reference sequence NaMe (`=' if same as RNAME)      │
482       │ 8  │ MPOS  │ 1-based Mate POSistion                                   │
483       │ 9  │ ISIZE │ Inferred insert SIZE                                     │
484       │10  │ SEQ   │ query SEQuence on the same strand as the reference       │
485       │11  │ QUAL  │ query QUALity (ASCII-33 gives the Phred base quality)    │
486       │12  │ OPT   │ variable OPTional fields in the format TAG:VTYPE:VALUE   │
487       └────┴───────┴──────────────────────────────────────────────────────────┘
488
489       Each bit in the FLAG field is defined as:
490
491
492               ┌────┬────────┬───────────────────────────────────────┐
493Chr Flag  Description              
494               ├────┼────────┼───────────────────────────────────────┤
495               │ p  │ 0x0001 │ the read is paired in sequencing      │
496               │ P  │ 0x0002 │ the read is mapped in a proper pair   │
497               │ u  │ 0x0004 │ the query sequence itself is unmapped │
498               │ U  │ 0x0008 │ the mate is unmapped                  │
499               │ r  │ 0x0010 │ strand of the query (1 for reverse)   │
500               │ R  │ 0x0020 │ strand of the mate                    │
501               │ 1  │ 0x0040 │ the read is the first read in a pair  │
502               │ 2  │ 0x0080 │ the read is the second read in a pair │
503               │ s  │ 0x0100 │ the alignment is not primary          │
504               │ f  │ 0x0200 │ QC failure                            │
505               │ d  │ 0x0400 │ optical or PCR duplicate              │
506               │ S  │ 0x0800 │ supplementary alignment               │
507               └────┴────────┴───────────────────────────────────────┘
508
509       The Please check <http://samtools.sourceforge.net> for the format spec‐
510       ification and the tools for post-processing the alignment.
511
512       BWA generates the following optional fields. Tags starting with `X' are
513       specific to BWA.
514
515
516              ┌────┬──────────────────────────────────────────────────┐
517Tag Meaning                      
518              ├────┼──────────────────────────────────────────────────┤
519NM  │ Edit distance                                    │
520MD  │ Mismatching positions/bases                      │
521AS  │ Alignment score                                  │
522BC  │ Barcode sequence                                 │
523SA  │ Supplementary alignments                         │
524              ├────┼──────────────────────────────────────────────────┤
525X0  │ Number of best hits                              │
526X1  │ Number of suboptimal hits found by BWA           │
527XN  │ Number of ambiguous bases in the referenece      │
528XM  │ Number of mismatches in the alignment            │
529XO  │ Number of gap opens                              │
530XG  │ Number of gap extentions                         │
531XT  │ Type: Unique/Repeat/N/Mate-sw                    │
532XA  │ Alternative hits; format: /(chr,pos,CIGAR,NM;)*/ │
533              ├────┼──────────────────────────────────────────────────┤
534XS  │ Suboptimal alignment score                       │
535XF  │ Support from forward/reverse alignment           │
536XE  │ Number of supporting seeds                       │
537              └────┴──────────────────────────────────────────────────┘
538
539       Note  that XO and XG are generated by BWT search while the CIGAR string
540       by Smith-Waterman alignment. These two tags may  be  inconsistent  with
541       the CIGAR string. This is not a bug.
542
543

NOTES ON SHORT-READ ALIGNMENT

545   Alignment Accuracy
546       When  seeding is disabled, BWA guarantees to find an alignment contain‐
547       ing maximum maxDiff differences including maxGapO gap  opens  which  do
548       not  occur  within nIndelEnd bp towards either end of the query. Longer
549       gaps may be found if maxGapE is positive, but it is not  guaranteed  to
550       find  all  hits. When seeding is enabled, BWA further requires that the
551       first seedLen subsequence contains no  more  than  maxSeedDiff  differ‐
552       ences.
553
554       When gapped alignment is disabled, BWA is expected to generate the same
555       alignment as Eland version 1, the Illumina alignment program.  However,
556       as  BWA change `N' in the database sequence to random nucleotides, hits
557       to these random sequences will also be counted. As a  consequence,  BWA
558       may mark a unique hit as a repeat, if the random sequences happen to be
559       identical to the sequences which should be unqiue in the database.
560
561       By default, if the best hit is not  highly  repetitive  (controlled  by
562       -R), BWA also finds all hits contains one more mismatch; otherwise, BWA
563       finds all equally best hits only. Base quality  is  NOT  considered  in
564       evaluating  hits.  In the paired-end mode, BWA pairs all hits it found.
565       It further performs Smith-Waterman alignment for unmapped reads to res‐
566       cue  reads  with a high erro rate, and for high-quality anomalous pairs
567       to fix potential alignment errors.
568
569
570   Estimating Insert Size Distribution
571       BWA estimates the insert size distribution per 256*1024 read pairs.  It
572       first  collects  pairs of reads with both ends mapped with a single-end
573       quality 20 or higher and then calculates median (Q2), lower and  higher
574       quartile  (Q1  and  Q3).  It estimates the mean and the variance of the
575       insert size distribution from  pairs  whose  insert  sizes  are  within
576       interval  [Q1-2(Q3-Q1), Q3+2(Q3-Q1)]. The maximum distance x for a pair
577       considered to be properly paired (SAM flag 0x2) is calculated by  solv‐
578       ing  equation  Phi((x-mu)/sigma)=x/L*p0, where mu is the mean, sigma is
579       the standard error of the insert size distribution, L is the length  of
580       the  genome,  p0  is  prior of anomalous pair and Phi() is the standard
581       cumulative distribution function.  For  mapping  Illumina  short-insert
582       reads  to  the  human  genome, x is about 6-7 sigma away from the mean.
583       Quartiles, mean, variance and x will be printed to the  standard  error
584       output.
585
586
587   Memory Requirement
588       With  bwtsw algorithm, 5GB memory is required for indexing the complete
589       human genome sequences. For short reads, the aln  command  uses  ~3.2GB
590       memory and the sampe command uses ~5.4GB.
591
592
593   Speed
594       Indexing the human genome sequences takes 3 hours with bwtsw algorithm.
595       Indexing smaller genomes with IS algorithms  is  faster,  but  requires
596       more memory.
597
598       The  speed  of alignment is largely determined by the error rate of the
599       query sequences (r). Firstly, BWA runs much  faster  for  near  perfect
600       hits  than for hits with many differences, and it stops searching for a
601       hit with l+2 differences if a l-difference hit is found. This means BWA
602       will  be  very  slow if r is high because in this case BWA has to visit
603       hits with many differences and looking for  these  hits  is  expensive.
604       Secondly,  the  alignment algorithm behind makes the speed sensitive to
605       [k log(N)/m], where k is the maximum allowed differences, N the size of
606       database and m the length of a query. In practice, we choose k w.r.t. r
607       and therefore r is the leading factor. I would not recommend to use BWA
608       on data with r>0.02.
609
610       Pairing  is  slower  for  shorter reads. This is mainly because shorter
611       reads have more spurious hits and converting SA coordinates to  chromo‐
612       somal coordinates are very costly.
613
614

CHANGES IN BWA-0.6

616       Since  version  0.6,  BWA has been able to work with a reference genome
617       longer than 4GB.  This feature makes it possible to integrate the  for‐
618       ward  and  reverse complemented genome in one FM-index, which speeds up
619       both BWA-short and BWA-SW. As a tradeoff, BWA uses more memory  because
620       it has to keep all positions and ranks in 64-bit integers, twice larger
621       than 32-bit integers used in the previous versions.
622
623       The latest BWA-SW also works for paired-end reads longer than 100bp. In
624       comparison  to  BWA-short,  BWA-SW tends to be more accurate for highly
625       unique reads and more robust to relative  long  INDELs  and  structural
626       variants.   Nonetheless,  BWA-short usually has higher power to distin‐
627       guish the optimal hit from many suboptimal hits. The choice of the map‐
628       ping algorithm may depend on the application.
629
630

SEE ALSO

632       BWA    website   <http://bio-bwa.sourceforge.net>,   Samtools   website
633       <http://samtools.sourceforge.net>
634
635

AUTHOR

637       Heng Li at the Sanger Institute wrote the key source  codes  and  inte‐
638       grated    the    following    codes   for   BWT   construction:   bwtsw
639       <http://i.cs.hku.hk/~ckwong3/bwtsw/>, implemented by Chi-Kwong Wong  at
640       the        University       of       Hong       Kong       and       IS
641       <http://yuta.256.googlepages.com/sais> originally proposed by  Nong  Ge
642       <http://www.cs.sysu.edu.cn/nong/>  at  the  Sun  Yat-Sen University and
643       implemented by Yuta Mori.
644
645

LICENSE AND CITATION

647       The full BWA package is distributed under GPLv3 as it uses source codes
648       from  BWT-SW  which  is covered by GPL. Sorting, hash table, BWT and IS
649       libraries are distributed under the MIT license.
650
651       If you use the  BWA-backtrack  algorithm,  please  cite  the  following
652       paper:
653
654       Li  H. and Durbin R. (2009) Fast and accurate short read alignment with
655       Burrows-Wheeler  transform.  Bioinformatics,  25,   1754-1760.   [PMID:
656       19451168]
657
658       If you use the BWA-SW algorithm, please cite:
659
660       Li  H.  and Durbin R. (2010) Fast and accurate long-read alignment with
661       Burrows-Wheeler  transform.   Bioinformatics,   26,   589-595.   [PMID:
662       20080505]
663
664       If you use BWA-MEM or the fastmap component of BWA, please cite:
665
666       Li H. (2013) Aligning sequence reads, clone sequences and assembly con‐
667       tigs with BWA-MEM. arXiv:1303.3997v1 [q-bio.GN].
668
669       It is likely that the BWA-MEM manuscript will not  appear  in  a  peer-
670       reviewed journal.
671
672

HISTORY

674       BWA  is  largely influenced by BWT-SW. It uses source codes from BWT-SW
675       and mimics its binary file formats; BWA-SW resembles BWT-SW in  several
676       ways.  The  initial  idea  about BWT-based alignment also came from the
677       group who developed BWT-SW. At the same time, BWA is  different  enough
678       from  BWT-SW. The short-read alignment algorithm bears no similarity to
679       Smith-Waterman algorithm any more. While BWA-SW learns from BWT-SW,  it
680       introduces  heuristics that can hardly be applied to the original algo‐
681       rithm. In all, BWA does not guarantee to find all local  hits  as  what
682       BWT-SW  is  designed  to  do, but it is much faster than BWT-SW on both
683       short and long query sequences.
684
685       I started to write the first piece of codes on 24 May 2008 and got  the
686       initial  stable  version  on  02  June  2008. During this period, I was
687       acquainted that Professor Tak-Wah  Lam,  the  first  author  of  BWT-SW
688       paper,  was collaborating with Beijing Genomics Institute on SOAP2, the
689       successor to SOAP (Short Oligonucleotide Analysis Package).  SOAP2  has
690       come  out in November 2008. According to the SourceForge download page,
691       the third BWT-based short read aligner, bowtie, was first  released  in
692       August  2008.  At  the time of writing this manual, at least three more
693       BWT-based short-read aligners are being implemented.
694
695       The BWA-SW algorithm is a new component of BWA. It was conceived in No‐
696       vember 2008 and implemented ten months later.
697
698       The  BWA-MEM  algorithm  is based on an algorithm finding super-maximal
699       exact matches (SMEMs), which was first published with the fermi  assem‐
700       bler paper in 2012. I first implemented the basic SMEM algorithm in the
701       fastmap command for an experiment and then extended the basic algorithm
702       and  added  the extension part in Feburary 2013 to make BWA-MEM a fully
703       featured mapper.
704
705
706
707
708bwa-0.7.17-r1188                23 October 2017                         bwa(1)
Impressum