-
Notifications
You must be signed in to change notification settings - Fork 867
/
slides.html
1074 lines (778 loc) · 24.5 KB
/
slides.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
layout: tutorial_slides
logo: "GTN"
title: "Mapping"
zenodo_link: "https://doi.org/10.5281/zenodo.61771"
questions:
- What is mapping (alignment)?
- What is the BAM format?
- How can we view aligned sequences?
objectives:
- Understand the basic concept of mapping
- Learn about factors influencing alignment
- See a genome browser used to better understand your aligned data
time_estimation: "1h"
key_points:
- Mapping is not trivial
- There are many mapping tools, best choice depends on your data
- Choice of mapper can affect downstream results
- Know your data!
- Genome browsers can be used to view aligned reads
contributors:
- joachimwolff
- shiltemann
- EngyNasr
- gallardoalba
- gallantries
recordings:
- captioners:
- blankenberg
date: '2021-02-15'
galaxy_version: '21.01'
length: 10M
youtube_id: 7FhHb8EV3EU
speakers:
- pvanheus
---
# Example NGS pipeline
![High level view of a typical NGS workflow](../../images/mapping/variant_calling_workflow.png)
A high level view of a typical NGS bioinformatics workflow
???
- Mapping step occurs if a reference genome is available for the organism of interest
- else: de-novo assembly
- Variant calling step is just an example, after mapping can do many steps
- Structural Variants / Fusion genes
- Differential Gene expression
- Alternative Splicing
- ..
---
# What is mapping?
.pull-left[
![Mapping vs assembly](../../images/mapping/mapping_assembly.png)
]
.pull-right[
- Short reads must be combined into longer fragments
- **Mapping:** use a reference genome as a guide
- **De-novo assembly:** without reference genome
]
???
- Mapping is also referred to as *alignment*
- Short reads produced by sequencer must be combined into larger contigs
- e.g. reconstruct the chromosomes
- mapping uses a reference genome as a guide
- can subsequently find where our sample differs from reference (variants)
- This tutorial only deals with mapping/alignment
- There are other tutorials available for de-novo assembly
---
class: top
# Sequence alignment
- Determine position of short read on the reference genome
```
Reference: . . . A A C G C C T T . . .
Read: A G G G G C C T T
```
???
- Consider situation where we must map this (short) read to this (long) reference
- e.g. human genome ~ 3.2 billion base pairs
- We scan the reference genome until we find an area that's similar to our read
- This area looks pretty similar, but not quite identical..
---
class: top
# Sequence alignment
- Determine position of short read on the reference genome
```
Reference: . . . A A - C G C C T T . . . | = match
. | : - : | | | | | : = mismatch
Read: A G G G G C C T T - = gap
```
???
But if we introduce gaps and allow for some mismatches in bases, this matches
up pretty well..
--
- Read could align to multiple places
.center[.image-50[![Illustration of multi-mapped read](../../images/mapping/multimap.png)]]
- How to handle multi-mapped reads? Depends on tool:
- Map to best region (but what is "best"? And what about ties?)
- Map to all regions
- Map to one region randomly
- Discard read
- How do we determine *best* region?
- Assign ***alignment score*** to every mapping
???
Some reads may map to multiple locations
- repeat regions, short reads, highly variable regions, sequencing errors, ..
We want a way to determine *best* alignment if none are perfect matches..
---
class: top
# Alignment Scoring (basics)
- **Reward** for a match (e.g. +10), **penalty** for a mismatch (e.g. -5)
- **Penalty** for gaps
- *Linear:* every gap same penalty (e.g. -5)
- *Affine:* gap open vs gap extend (e.g. -5 and -1)
- Different tools use different scoring values (and give different results)
.center[
.image-25[![Screenshot of a sequence scoring game where two sequences are being aligned across the top (GGCTGG and GAGG) and the per-base and cumulative scores from left to right.](../../images/mapping/scoring_example.png)]
**Example** (with affine gap penalty)
]
???
- Each locus get scored independently (first row of scores in example)
- Scores from all loci are added up (cumulative score row)
- Final score for entire alignment in this example is 19
- These reward and penalty values are just examples and will vary
---
class: top
# Alignment Scoring (advanced)
- **Base quality**
- Mismatch of low-confidence base: lower penalty
- Mismatch of high-confidence base: higher penalty
- **Transitions vs transversions**
- Transitions about 2x as frequent as transversions
.center[
.image-50[ ![Transitions vs transversions](../../images/mapping/ti_tv.png) ]
.image-25[ ![Example scoring matrix](../../images/mapping/ti_tv_scoring.png) ]
]
- Knowledge about sequencing platform and biases
- Optimize for read length, error rate, homopolymer accuracy, etc..
.footnote[More information about mapping algorithms: [10.1089/cmb.2012.0022](https://doi.org/10.1089/cmb.2012.0022)]
???
Many more complexities may be considered, different tools make different choices
Transitions are more likely to occur in real sequences, so may give lower penalty than transversions
**Transitions** are interchanges of two-ring purines (A G) or of one-ring pyrimidines (C T): they therefore involve bases of similar shape.
**Transversions** are interchanges of purine for pyrimidine bases, which therefore involve exchange of one-ring and two-ring structures.
![Transitions and transversions](../../images/mapping/transition_transversion.gif)
---
# Looks easy but..
---
class: top
# Sequence Alignment
```
Reference: AAA CAGTGA GAA
Observed: AAA TCTCT GAA
```
???
Suppose we want to map this read (bottom) to this reference sequence (top)
---
class: top
# Sequence Alignment
```
Reference: AAA CAGTGA GAA
Observed: AAA TCTCT GAA
```
<table style="width:100%; table-layout: fixed; font-size:0.8em">
<th>Alignment</th><th></th>
<tr><td><pre>
AAA-CAGTGAGAA
|||-|--|::|||
AAATC--TCTGAA
</pre></td>
<td>Maybe like this?</td>
</tr>
</table>
???
This is one possibility, is it the only one?
---
class: top
# Sequence Alignment
```
Reference: AAA CAGTGA GAA
Observed: AAA TCTCT GAA
```
<table style="width:100%; table-layout:fixed; font-size:0.8em;">
<th>Alignment</th><th></th>
<tr><td><pre>
AAA-CAGTGAGAA
|||-|--|::|||
AAATC--TCTGAA
</pre></td>
<td>Maybe like this?</td>
</tr>
<tr><td><pre>
AAACAGTGAGAA
|||-::|::|||
AAA-TCTCTGAA
</pre></td>
<td> Or this? </td>
</tr>
</table>
???
This is also a possible alignment. Not easy to say which is better.
---
class: top
# Sequence Alignment
```
Reference: AAA CAGTGA GAA
Observed: AAA TCTCT GAA
```
<table style="width:100%; table-layout:fixed; font-size:0.8em">
<th>Alignment</th><th></th>
<tr><td><pre>
AAA-CAGTGAGAA
|||-|--|::|||
AAATC--TCTGAA
</pre></td>
<td>Maybe like this?</td>
</tr>
<tr><td><pre>
AAACAGTGAGAA
|||-::|::|||
AAA-TCTCTGAA
</pre></td>
<td> Or this? </td>
</tr>
<tr><td><pre>
AAACAGTGAGAA
|||:-:|::|||
AAAT-CTCTGAA
</pre></td>
<td>Or..? </td>
</tr>
</table>
???
And a third option
---
class: top
# Sequence Alignment
```
Reference: AAA CAGTGA GAA
Observed: AAA TCTCT GAA
```
<table style="width:100%; table-layout:fixed; font-size:0.8em">
<th>Alignment</th><th></th>
<tr><td><pre>
AAA-CAGTGAGAA
|||-|--|::|||
AAATC--TCTGAA
</pre></td>
<td>Maybe like this?</td>
</tr>
<tr><td><pre>
AAACAGTGAGAA
|||-::|::|||
AAA-TCTCTGAA
</pre></td>
<td> Or this? </td>
</tr>
<tr><td><pre>
AAACAGTGAGAA
|||:-:|::|||
AAAT-CTCTGAA
</pre></td>
<td>Or..? </td>
</tr>
<tr><td><pre>
AAACAGTCA-----GAA
|||-----------|||
AAA------TCTCTGAA
</pre></td>
<td> What about this? </td>
</tr>
</table>
???
There is no one right way to do alignment
- Hard to say which of these is "better" or "worse"
- Just different choices, but all valid
Mapping is a non-trivial problem!
---
class: top
# Sequence Alignment
```
Reference: AAA CAGTGA GAA
Observed: AAA TCTCT GAA
```
<table style="width:100%; table-layout:fixed; font-size:0.8em">
<th>Alignment</th><th>Tool</th>
<tr><td><pre>
AAA-CAGTGAGAA
|||-|--|::|||
AAATC--TCTGAA
</pre></td>
<td>Novoalign</td>
</tr>
<tr><td><pre>
AAACAGTGAGAA
|||-::|::|||
AAA-TCTCTGAA
</pre></td>
<td> Ssaha2 </td>
</tr>
<tr><td><pre>
AAACAGTGAGAA
|||:-:|::|||
AAAT-CTCTGAA
</pre></td>
<td> BWA </td>
</tr>
<tr><td><pre>
AAACAGTCA-----GAA
|||-----------|||
AAA------TCTCTGAA
</pre></td>
<td> Complete Genomics </td>
</tr>
</table>
???
We didn't just make these up, these real aligners gave these different results
---
class: top
# Sequence Alignment
```
Reference: AAA CAGTGA GAA
Observed: AAA TCTCT GAA
```
<table style="width:100%; table-layout:fixed; font-size:0.8em">
<th>Alignment</th><th>Variant calls</th>
<tr><td><pre>
AAA-CAGTGAGAA
|||-|--|::|||
AAATC--TCTGAA
</pre></td>
<td><pre>
ins T
del AG
sub GA -> CT
</pre></td>
</tr>
<tr><td><pre>
AAACAGTGAGAA
|||-::|::|||
AAA-TCTCTGAA
</pre></td>
<td><pre>
del C
sub AG -> TC
sub GA -> CT
</pre></td>
</tr>
<tr><td><pre>
AAACAGTGAGAA
|||:-:|::|||
AAAT-CTCTGAA
</pre></td>
<td><pre>
snp C -> T
del A
snp G -> C
sub GA -> CT
</pre></td>
</tr>
<tr><td><pre>
AAACAGTGA-----GAA
|||-----------|||
AAA------TCTCTGAA
</pre></td>
<td><pre>
del CAGTGA
ins TCTCT
</pre></td>
</tr>
</table>
???
**Important:** Mapping can affect downstream analysis!
These different mappings led to different variants, and hard to tell they are equivalent.
---
# Try it yourself!
- Lego time! Who wants to volunteer?
- Or try this [online sequence alignment game](http://web.archive.org/web/20200411075748/https://teacheng.illinois.edu/SequenceAlignment/):
<!-- using webarchive version because game seems broken, once fixed we can update the link back to: http://teacheng.illinois.edu/SequenceAlignment/ -->
.image-75[![Recording of alignment game](../../images/mapping/alignment.gif)]
.footnote[https://tinyurl.com/sequence-alignment]
???
Can have learners play around with this alignment game now
Or use Lego bricks, each nucleotide a different colour
---
## Paired-end sequencing
- **Sequencing:** Cut longer fragments of DNA, sequence only the ends
.center[.image-90[![Paired-end reads](../../images/mapping/pairedend_read.png)]]
- **Mapping:** known distance between reads improves accuracy
.center[.image-75[![Mapping of paired-end reads](../../images/mapping/pairedend_mapping.png)]]
???
- The fragments are too long to sequence entirely, but we can sequence
the ends.
- Then we have the added information of how far apart these two reads must map
- This improves our mapping
- For example for multi-mapped reads, or repeats (next slide)
---
class: top
## Repeats
- Multi-mapped reads (e.g. because of repeats) may now be resolved
- **Single-end:**
![Cartoon with a reference genome and two repeats marked. Two blue boxes representing a single-ended read map equally well to both repeats.](../../images/mapping/repeats_se.png)
???
In the case of repeats, a single-end read alone would not have be enough
for unique mapping..
--
- **Paired-end:**
![Cartoon with a reference genome and two repeats marked. Now the two blue boxes are linked and one of them is red, representing a forward/reverse pair of a paired-end read. The mapping is no longer ambiguous and you can know which repeat the blue box belongs to, as the red box maps upstream.](../../images/mapping/repeats_pe.png)
???
But with the additional information provided by
paired-end protocol (distance to mate), this can now be resolved..
---
class: top
# InDels (Insertions / Deletions)
- Discordant insert size may indicate insertion or deletion between reads
- **Deletions:** Longer mapping distance than expected
.image-75[![Deletion between two paired reads](../../images/mapping/pairedend_deletion.png)]
--
- **Insertions:** Shorter mapping distance than expected
.image-75[![Insertions beteween two paired reads](../../images/mapping/pairedend_insertion.png)]
???
- Unexpected mapping distance between two reads in a pair may indicate a variant.
- Exact location of variant unknown unless more reads covering the area
- Only know it it somewhere between the two reads
**FAQ:** "What about mate-pair sequencing?"
- Same concept as paired-end
- Much longer distance between ends
- Very different library prep
- Useful for detection of larger Structural Variations (SVs) / Fusion Genes
- longer than expected distance between mates: deletion in sample
- shorter than expected distance beetween mates: insertion in sample
- unexpected orientation of one mate: inversion in sample
---
class: top
## Paired-end FASTQ files
- Sequencer produces two FASTQ files:
- **Forward** reads (usually **`_1`** or **`_R1`** in file name)
- **Reverse** reads (usually **`_2`** or **`_R2`** in file name)
![Paired-end reads as two separate FASTQ files](../../images/mapping/pairedend_fastq.png)
???
When you have paired-end data, you will usually get 2 files.
- File names identical except for e.g. `_1`/`_2` or `_R1`/`_R2`
- First file contains all the forward reads ("left" sides of pairs)
- Other file contains all the reverse reads
Pairing also visible in read names
- `/1` `/2` at end or `1:` and `2:` in read ID
--
- Sometimes: One **interleaved** (or **interlaced**) FASTQ file
- Most tools require 2 separate files
- {% icon tool %} De-interlace tools in Galaxy for conversion
???
Sometimes data can be in a single **interleaved file** (aka **interlaced**)
- alternating forward and reverse read
- de-interlace tools in Galaxy to convert this to two separate files
- because many tools require two separate files
---
class: top
## Paired-end FASTQ files
- Order of reads matters!
- **`N`<sup>th</sup>** read in forward file <i class="fa fa-arrows-h" aria-hidden="true"></i>
**`N`<sup>th</sup>** read in reverse file
- Much faster than determining pairing by read names alone
- ***Always trim and filter together!***
???
Most tools blindly assume that first read in forward file is paired with first read in reverse file etc
Otherwise too slow
- for every read, worst case have to scan all reads in other file
- for files with millions of reads, that is millions ^ millions
When trimming and filtering, if a read is removed from one file, its mate must be removed from other one too!
**Always trim together in paired-end mode!**
--
.pull-left[
.red[
```
@PAIR-1 forward
GGGTGATGGCCGCTGCCGATGGCGTCAAAT
+
))%255CCF>>>>>>CCCCCCC65`IIII%
```
]
.orange[
```
@PAIR-2 forward
GATTTGGGGTTCAAAGCAGTATCGATCAA
+
!''3((((^^d+))%%%++)(%%%%).1)
```
]
.blue[
```
@PAIR-3 forward
TCGCACTCAACGCCCTGCATATGACAAGAC
+
A64;##=#B9=AAAAAAAAAA9#:AB95%^
```
]
**`mysample_R1.fastq`**
]
.pull-right[
<i class="fa fa-arrows-h" style="position:absolute;font-size:3em;left:8em;"></i>
.red[
```
@PAIR-1 reverse
AAGTTACCCTTAACAACTTAAGGGTTTTCA
+
fffddf`feedB`IABa)^%YBBBRTT\^d
```
]
<i class="fa fa-arrows-h" style="position:absolute;font-size:3em;left:8em;"></i>
.orange[
```
@PAIR-2 reverse
AGCAGAAGTCGATGATAATACGCGTCGTTT
+
IIIIIII^^IIId`?III%IIIGII>IIII
```
]<i class="fa fa-arrows-h" style="position:absolute;font-size:3em;left:8em;"></i>
.blue[
```
@PAIR-3 reverse
AATCCATTTGTTCAACTCACAGTTTACCGT
+
9C;=;=<9@4868>9:67AA<9>65<=>59
```
]
**`mysample_R2.fastq`**
]
???
- Nth read in forward file belongs in a pair with Nth read in reverse file
- So red reads in this slide form a pair, orange ones, etc
---
class: top
## Paired-end FASTQ files
- Order of reads matters!
- **`N`<sup>th</sup>** read in forward file <i class="fa fa-arrows-h" aria-hidden="true"></i>
**`N`<sup>th</sup>** read in reverse file
- Much faster than determining pairing by read names alone
- ***Always trim and filter together!***
.pull-left[
<i class="fa fa-arrows-h" style="position:absolute;font-size:3em;left:8em;"></i>
.red[
```
@PAIR-1 forward
GGGTGATGGCCGCTGCCGATGGCGTCAAAT
+
))%255CCF>>>>>>CCCCCCC65`IIII%
```
]
.left[<i class="fa fa-cut" style="width:15%;position:absolute;font-size:5em;"></i>]
<i class="fa fa-arrows-h" style="position:absolute;font-size:3em;left:8em;"></i>
.orange[
```
@PAIR-2 forward
GATTTGGGGTTCAAAGCAGTATCGATCAA
+
!''3((((^^d+))%%%++)(%%%%).1)
```
]
<i class="fa fa-arrows-h" style="position:absolute;font-size:3em;left:8em;"></i>
.blue[
```
@PAIR-3 forward
TCGCACTCAACGCCCTGCATATGACAAGAC
+
A64;##=#B9=AAAAAAAAAA9#:AB95%^
```
]
**`mysample_R1.fastq`**
]
.pull-right[
.red[
```
@PAIR-1 reverse
AAGTTACCCTTAACAACTTAAGGGTTTTCA
+
fffddf`feedB`IABa)^%YBBBRTT\^d
```
]
.orange[
```
@PAIR-2 reverse
AGCAGAAGTCGATGATAATACGCGTCGTTT
+
IIIIIII^^IIId`?III%IIIGII>IIII
```
]
.blue[
```
@PAIR-3 reverse
AATCCATTTGTTCAACTCACAGTTTACCGT
+
9C;=;=<9@4868>9:67AA<9>65<=>59
```
]
**`mysample_R2.fastq`**
]
???
- Important to always provide both files to trimming and filtering tools together
- If a read in one file gets removed (e.g. because it is below quality threshold), but it's mate is not, the pairing between the two files is no longer correct.
- If one half of pair is trimmed, the other
- also removed, or
- put into separate "singletons" FASTQ file that some mappers can use
- FAQ:" why not look at read names to determine pairing?"
- analysis would be much slower if for every read must scan (max) entire other file for mate, since often millions or reads (for whole-genome sequencing).
---
class: top
## Paired-end FASTQ files
- Order of reads matters!
- **`N`<sup>th</sup>** read in forward file <i class="fa fa-arrows-h" aria-hidden="true"></i>
**`N`<sup>th</sup>** read in reverse file
- Much faster than determining pairing by read names alone
- ***Always trim and filter together!***
.pull-left[
<i class="fa fa-arrows-h" style="position:absolute;font-size:3em;left:8em;"></i>
.red[
```
@PAIR-1 forward
GGGTGATGGCCGCTGCCGATGGCGTCAAAT
+
))%255CCF>>>>>>CCCCCCC65`IIII%
```
]
<i class="fa fa-frown-o" style="position:absolute;font-size:3em;left:8em;"></i>
.blue[
```
@PAIR-3 forward
TCGCACTCAACGCCCTGCATATGACAAGAC
+
A64;##=#B9=AAAAAAAAAA9#:AB95%^
```
]
<i class="fa fa-frown-o" style="position:absolute;font-size:3em;left:8em;"></i>
.green[
```
@PAIR-4 forward
AAACTTCGTAGGTCCATTTGACAGCGTGCA
+
6664%!!III^(=%3333^^d^d:#32333
```
]
**`mysample_R1.fastq`**
]
.pull-right[
.red[
```
@PAIR-1 reverse
AAGTTACCCTTAACAACTTAAGGGTTTTCA
+
fffddf`feedB`IABa)^%YBBBRTT\^d
```
]
.orange[
```
@PAIR-2 reverse
AGCAGAAGTCGATGATAATACGCGTCGTTT
+
IIIIIII^^IIId`?III%IIIGII>IIII
```
]
.blue[
```
@PAIR-3 reverse
AATCCATTTGTTCAACTCACAGTTTACCGT
+
9C;=;=<9@4868>9:67AA<9>65<=>59
```
]
**`mysample_R2.fastq`**
]
???
By cutting the yellow read only from the forward reads file, but leaving the other side of pair in the other file, an incorrect pairing is now assumed by downstream tools
---
## Choosing an Aligner
- Each tool makes **different choices** during alignment
- Choice of aligner may **affect downstream results**
- Default options may not be best for your data!
- Best tool for your data **depends on many factors**
- Type of experiment (e.g. DNA, RNA, Bisulphite)
- Sequencing platform
- Compute resources vs sensitivity
- Read characteristics (paired/single end, read length)
.center[
.image-40[![Mapping RNA](../../images/mapping/spliced_mapper.png)]
]
.footnote[**Figure:** mapping of RNA-seq reads is different than DNA-seq]
???
Choice of mapper depends on your experiment
- Some mappers are good for DNA but not RNA
- Some mappers do well in highly rearranged genomes (e.g. cancer), others less so
- Some mappers do well on some platforms but worse on others
- e.g. Oxford Nanopore with its long reads but high error rates
Or other factors
- STAR needs a LOT of RAM
- Do you need results fast? or accurate? (e.g. medical setting)
FAQ: "Why not map RNA reads to the transcriptome?"
- you can, and it is done, but then cannot find novel genes or alternative splicing
FAQ: "Why not BLAST or BLAT?"
- optimized for longer sequences
- not base quality aware
- too slow
---
# Know your data!
*“... there is no tool that outperforms all of the others in
all the tests. Therefore, the end user should clearly
specify [their] needs in order to choose the tool that
provides the best results.”* - Hatem et al BMC Bioinformatics 2013, 14:184
.footnote[ [DOI: 10.1186/1471-2105-14-184](https://doi.org/10.1186/1471-2105-14-184) ]
???
Know the data you are working with and pick the right mapper and parameters for the job!
Not an easy task..
---
class: top
## Mapping tools
![Timeline of mapping tools](../../images/mapping/ngs_read_mappers_timeline.jpeg)
.footnote[60+ different mappers, many comparison papers. Figure from [10.1093/bioinformatics/bts605](https://doi.org/10.1093/bioinformatics/bts605) ]
???
Many different tools available
Different strengths and weaknesses, comparison table in link
---
class: top
# Mapping tools
**Mapping tool** | **Uses** | **Characteristics**
--- | --- | ---
HISAT2 | DNA/RNA | Short reads. Based on [GCSA](https://doi.org/10.1109/TCBB.2013.2297101). [Reference](https://www.nature.com/articles/s41587-019-0201-4).
RNASTAR | RNA | Short reads. Extremely fast. High sensitive and accuracy. Based on Maximal Mappable Prefixes (MMPs). [Reference](https://pubmed.ncbi.nlm.nih.gov/23104886/).
BWA-MEM2 | DNA | Short reads. Twice as faster as BWA-MEM. Memory efficient. Based on [Burrows-Wheeler](https://academic.oup.com/bioinformatics/article/25/14/1754/225615). [Reference](https://arxiv.org/abs/1907.12931).
Minimap2 | DNA/RNA | Long reads (PacBio and ONT). Extremely fast. Based on [DALIGN](https://link.springer.com/chapter/10.1007/978-3-662-44753-6_5) and [MHAP](https://www.nature.com/articles/nbt.3238). [Reference](https://doi.org/10.1093/bioinformatics/bty191).
Bismark | DNA/RNA | Short reads. Bisulfite treated sequencing. Based on [GCSA](https://doi.org/10.1109/TCBB.2013.2297101). [Reference](https://pubmed.ncbi.nlm.nih.gov/21493656/).
BBMap | DNA/RNA | Short and long reads (PacBio and ONT). Memory demanding. [Reference](https://bib.irb.hr/datoteka/773708.Josip_Maric_diplomski.pdf).
Whisper 2 | DNA | Short reads. Indel sensitive. Variant-calling oriented. [Reference](https://academic.oup.com/bioinformatics/article/35/12/2043/5165374).
S-conLSH | DNA | Long reads (ONT). High sensitivity and accuracy. [Reference](https://bmcbioinformatics.biomedcentral.com/articles/10.1186/s12859-020-03918-3).
---
# File Formats
---
# SAM/BAM file format
![Example of SAM file format](../../images/bam_file.png "SAM/BAM file")