scrnaseq_data.Rmd 23.8 KB
Newer Older
Laurent Modolo's avatar
Laurent Modolo committed
1
2
3
4
5
6
7
8
9
10
---
title: "single-cell RNA-Seq data"
author: "Laurent Modolo [laurent.modolo@ens-lyon.fr](mailto:laurent.modolo@ens-lyon.fr)"
date: "Friday 3 June 2022"
output:
  beamer_presentation:
    df_print: tibble
    fig_caption: no
    highlight: tango
    latex_engine: xelatex
Laurent Modolo's avatar
Laurent Modolo committed
11
    slide_level: 2
Laurent Modolo's avatar
Laurent Modolo committed
12
    theme: metropolis
Laurent Modolo's avatar
Laurent Modolo committed
13
  oslides_presentation:
Laurent Modolo's avatar
Laurent Modolo committed
14
15
16
17
18
19
20
21
    highlight: tango
  slidy_presentation:
    highlight: tango
classoption: aspectratio=169  
---

# Introduction

Laurent Modolo's avatar
Laurent Modolo committed
22
23
24
## Introduction

### Program
Laurent Modolo's avatar
Laurent Modolo committed
25
26
27
28
29
30

1. Single-cell RNASeq data from 10X Sequencing (Friday 3 June 2022 - 14:00)
2. Normalization and spurious effects (Wednesday 8 June 2022 - 14:00)
3. Dimension reduction and data visualization (Monday 13 June 2022 - 15:00)
4. Clustering and annotation (Thursday 23 June 2022 - 14:00)
5. Pseudo-time and velocity inference (Thursday 30 June 2022 - 14:00)
Laurent Modolo's avatar
Laurent Modolo committed
31
6. Differential expression analysis (Friday 8 July 2022 - 14:00)
Laurent Modolo's avatar
Laurent Modolo committed
32

Laurent Modolo's avatar
Laurent Modolo committed
33
## Introduction
Laurent Modolo's avatar
Laurent Modolo committed
34

Laurent Modolo's avatar
Laurent Modolo committed
35
### Program
Laurent Modolo's avatar
Laurent Modolo committed
36
37
38
39
40
41
42
43
44
45
46
47
48

1. Single-cell RNASeq data from 10X Sequencing (Friday 3 June 2022 - 14:00)
  - 10X Sequencing
  - RNA quantification
    - Mapping
    - Pseudo-mapping
  - Fragments quantification
2. Normalization and spurious effects (Wednesday 8 June 2022 - 14:00)
3. Dimension reduction and data visualization (Monday 13 June 2022 - 15:00)
4. Clustering and annotation (Thursday 23 June 2022 - 14:00)
5. Pseudo-time and velocity inference (Thursday 30 June 2022 - 14:00)
6. Differential expression analysis (Friday 8 July 2022 - 14:00)

Laurent Modolo's avatar
Laurent Modolo committed
49
## RNA Sequencing: what do we want to know ?
Laurent Modolo's avatar
Laurent Modolo committed
50

51
52
We want to estimate the number of each mRNA molecule.
\vspace{1em}
Laurent Modolo's avatar
Laurent Modolo committed
53

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
\begin{center}
\begin{columns}
\column{0.5\textwidth}
\begin{center}
\begin{tikzpicture}
  \fill
      (0.5,5.5) node {\bf{Sample}}
      (0.5,4.5) node {mRNA}
   -- (0.5,3.5) node {mRNA}
   -- (0.5,2.5) node {mRNA}
   -- (0.5,1.5) node {$\vdots$}
   -- (0.5,0.5) node {mRNA};
  \draw (0,0) grid (1,1);
  \draw (0,2) grid (1,5);
\end{tikzpicture}
\end{center}

\column{0.5\textwidth}
\begin{center}
\[
  X_{1\times genes} = 
  \begin{bmatrix}
76
77
    x_{1}\\
    x_{2}\\
78
    \vdots\\
79
    x_{n}
80
81
82
83
84
85
86
87
88
  \end{bmatrix}
\]

\vspace{2em}
$gene = transcripts$ ?
\end{center}
\end{columns}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
89
## single-cell RNA Sequencing
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

We want to estimate the number of each mRNA molecule in each cell.
\vspace{1em}

\begin{center}
\begin{columns}
\column{0.4\textwidth}
\begin{center}
\begin{tikzpicture}
  \fill
      (0.5,3.5) node {\bf $\text{gene}_1$}
   -- (0.5,2.5) node {\bf $\text{gene}_2$}
   -- (0.5,1.5) node {\bf $\vdots$}
   -- (0.5,0.5) node {\bf $\text{gene}_n$};
  \fill
      (1.5,4.5) node {\bf{$\text{cell}_1$}}
   -- (1.5,3.5) node {mRNA}
   -- (1.5,2.5) node {mRNA}
   -- (1.5,1.5) node {$\vdots$}
   -- (1.5,0.5) node {mRNA};
  \fill
      (2.5,4.5) node {\bf{$\text{cell}_2$}}
   -- (2.5,3.5) node {mRNA}
   -- (2.5,2.5) node {mRNA}
   -- (2.5,1.5) node {$\vdots$}
   -- (2.5,0.5) node {mRNA};
  \fill
      (3.5,4.5) node {\bf{$\cdots$}}
   -- (3.5,3.5) node {$\cdots$}
   -- (3.5,2.5) node {$\cdots$}
   -- (3.5,1.5) node {$\ddots$}
   -- (3.5,0.5) node {$\cdots$};
  \fill
      (4.5,4.5) node {\bf{$\text{cell}_c$}}
   -- (4.5,3.5) node {mRNA}
   -- (4.5,2.5) node {mRNA}
   -- (4.5,1.5) node {$\vdots$}
   -- (4.5,0.5) node {mRNA};
  \draw (1,0) grid (5,4);
\end{tikzpicture}
\end{center}

\column{0.6\textwidth}
\begin{center}
\[
  X_{cells \times genes} = 
  \begin{bmatrix}
137
138
    x_{1,1} & x_{1,2} & \cdots & x_{1,c} \\
    x_{2,1} & x_{2,2} & \cdots & x_{2,c} \\
139
    \vdots & \vdots & \ddots & \vdots \\
Laurent Modolo's avatar
Laurent Modolo committed
140
    x_{n,1} & x_{n,2} & \cdots & x_{n,c} \\
141
142
143
144
145
146
147
  \end{bmatrix}
\]
\end{center}

\end{columns}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
148
149
150
# 10X sequencing

## single-cell RNA Sequencing
Laurent Modolo's avatar
Laurent Modolo committed
151
152
153
154
155
156
157
158
159

\begin{center}
\begin{columns}
\column{0.5\textwidth}

\includegraphics[width=\textwidth]{img/gel_bead.png}

\column{0.5\textwidth}

Laurent Modolo's avatar
Laurent Modolo committed
160
{\bf Number of cell barcode for each 10X protocol:}\\[1em]
Laurent Modolo's avatar
Laurent Modolo committed
161
\begin{itemize}
162
  \item {\bf v2} chemistry $\sim 737,000$ cell barcodes
Laurent Modolo's avatar
Laurent Modolo committed
163
164
165
166
167
168
  \begin{itemize}
    \item Partial Illumina Read 1 sequence (22 nucleotides (nt))
    \item 16 nt 10x™ Barcode
    \item 10 nt Unique Molecular Identifier (UMI)
    \item 30 nt Poly(dT) primer sequence
  \end{itemize}
169
  \item {\bf v3} chemistry $\sim 3,500,000$ cell barcodes
Laurent Modolo's avatar
Laurent Modolo committed
170
171
172
173
174
175
176
177
178
179
180
  \begin{itemize}
    \item an Illumina TruSeq Read 1 (read 1 sequencing primer)
    \item 16 nt 10x™ Barcode
    \item 12 nt unique molecular identifier (UMI)
    \item 30 nt poly(dT) sequence
  \end{itemize}
\end{itemize}

\end{columns}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
181
## Unique Molecular Identifier (UMI)
182
183
184
185
186
187
188

\begin{center}
\includegraphics[width=\textwidth]{./img/umi_and_pcr.png}
\end{center}

[*](https://www.genomescan.nl/wp-content/uploads/2019/10/graphic_UMIs_1.png.webp)

Laurent Modolo's avatar
Laurent Modolo committed
189
190
191
192
193
194
195

## Unique Molecular Identifier (UMI)

\begin{center}
\includegraphics[width=\textwidth]{./img/umi_vs_read.png}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
196
## single-cell RNA Sequencing
197

Laurent Modolo's avatar
Laurent Modolo committed
198
### **3'** mRNA capture
199

Laurent Modolo's avatar
Laurent Modolo committed
200
201
202
\begin{center}
  \includegraphics[width=0.9\textwidth]{img/10x_r1_r2.png}
\end{center}
203

Laurent Modolo's avatar
Laurent Modolo committed
204
## single-cell RNA Sequencing
205
206
207
208
209
210
211
212
213
214
215
216
217
218

\begin{center}
\begin{columns}
\column{0.7\textwidth}

\includegraphics[width=\textwidth]{img/cluster_generation.png}


\column{0.5\textwidth}

\includegraphics[width=\textwidth]{img/sequencing_by_synthesis.png}
\end{columns}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
219
## single-cell RNA Sequencing
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

\begin{center}
\includegraphics[width=0.7\textwidth]{img/r1_r2.png}
\end{center}

\begin{columns}
\column{0.5\textwidth}
\begin{center}
{\large \bf fastq R1}
\end{center}
\column{0.5\textwidth}
\begin{center}
{\large \bf fastq R2}
\end{center}
\end{columns}

```
@HWUSI-EAS100R:6:73:941:1973#/1      @HWUSI-EAS100R:6:73:941:1973#/2
GATTTGGGGTTCAAAGCAGTATCGATCAAATAGT   GATTTGGGGTTCAAAGCAGTAAAAAAAAAAAAAA
+                                    +
I>IIIII-I)8IIIIIIIIIIIIIIIIIIIII6I   IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII6I
...                                  ...
```

1. begins with a '@' character and is followed by a sequence identifier
Laurent Modolo's avatar
Laurent Modolo committed
245
2. raw sequence letter
246
3. begins with a '+' character and is optionally followed by the same sequence identifier
Laurent Modolo's avatar
Laurent Modolo committed
247
4. encodes the quality values for the sequence in line 2
248

Laurent Modolo's avatar
Laurent Modolo committed
249
## single-cell RNA Sequencing
250
251
252
253
254
255

\begin{center}
\includegraphics[width=0.85\textwidth]{img/fastqc_per_base_sequence_quality_plot.png}
\end{center}


Laurent Modolo's avatar
Laurent Modolo committed
256
## Phred quality score
257
258
259
260
261
262
263
264
265

\begin{center}
$Q = -10 \ \log_{10} P$ or $P = 10^{\frac{-Q}{10}}$

\begin{tabular}{ l l l }
Phred & Probability of incorrect base call & Base call accuracy \\
10 & 1 in 10 & $90\%$ \\
20 & 1 in 100 & $99\%$\\
40 & 1 in 10,000 & $99.99\%$ \\
Laurent Modolo's avatar
Laurent Modolo committed
266
30 & 1 in 1000 & $99.9\%$ \\
267
268
269
270
271
50 & 1 in 100,000 & $99.999\%$ \\
\end{tabular}

\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
272
273
274
# 10X output processing

## single-cell RNA Sequencing
275
276
277
278
279
280
281
282
283

\begin{center}
\begin{columns}
\column{0.5\textwidth}

\includegraphics[width=\textwidth]{img/10x_r1_r2.png}

\column{0.5\textwidth}

284
{\bf We want to:}\\[1em]
285
\begin{itemize}
286
287
288
  \item identify the cell : {\color{red} \bf 10x barcode} 
  \item identify the gene : {\bf cDNA sequence} 
  \item count the mRNA : {\bf UMI $\times$ cDNA sequence} 
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
\end{itemize}
\vspace{1em}

\begin{center}
\begin{tikzpicture}
  \fill
      (0.5,3.5) node {\bf $\text{gene}_1$}
   -- (0.5,2.5) node {\bf $\text{gene}_2$}
   -- (0.5,1.5) node {\bf $\vdots$}
   -- (0.5,0.5) node {\bf $\text{gene}_n$};
  \fill
      (1.5,4.5) node {\color{red}\bf{$\text{cell}_1$}}
   -- (1.5,3.5) node {mRNA}
   -- (1.5,2.5) node {mRNA}
   -- (1.5,1.5) node {$\vdots$}
   -- (1.5,0.5) node {mRNA};
  \fill
      (2.5,4.5) node {\color{red}\bf{$\text{cell}_2$}}
   -- (2.5,3.5) node {mRNA}
   -- (2.5,2.5) node {mRNA}
   -- (2.5,1.5) node {$\vdots$}
   -- (2.5,0.5) node {mRNA};
  \fill
      (3.5,4.5) node {\bf{$\cdots$}}
   -- (3.5,3.5) node {$\cdots$}
   -- (3.5,2.5) node {$\cdots$}
   -- (3.5,1.5) node {$\ddots$}
   -- (3.5,0.5) node {$\cdots$};
  \fill
      (4.5,4.5) node {\color{red}\bf{$\text{cell}_c$}}
   -- (4.5,3.5) node {mRNA}
   -- (4.5,2.5) node {mRNA}
   -- (4.5,1.5) node {$\vdots$}
   -- (4.5,0.5) node {mRNA};
  \draw (1,0) grid (5,4);
\end{tikzpicture}
\end{center}

\end{columns}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
330
## single-cell RNA Sequencing
331
332
333
334
335
336
337
338
339

\begin{center}
\begin{columns}
\column{0.5\textwidth}

\includegraphics[width=\textwidth]{img/10x_r1_r2.png}

\column{0.5\textwidth}

340
{\bf We want to :}\\[1em]
341
\begin{itemize}
342
343
344
  \item identify the cell : {\bf 10x barcode} 
  \item identify the gene : {\color{red}\bf cDNA sequence} 
  \item count the mRNA : {\bf UMI $\times$ cDNA sequence} 
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
\end{itemize}
\vspace{1em}

\begin{center}
\begin{tikzpicture}
  \fill
      (0.5,3.5) node {\color{red} \bf $\text{gene}_1$}
   -- (0.5,2.5) node {\color{red} \bf $\text{gene}_2$}
   -- (0.5,1.5) node {\bf $\vdots$}
   -- (0.5,0.5) node {\color{red} \bf $\text{gene}_n$};
  \fill
      (1.5,4.5) node {\bf{$\text{cell}_1$}}
   -- (1.5,3.5) node {mRNA}
   -- (1.5,2.5) node {mRNA}
   -- (1.5,1.5) node {$\vdots$}
   -- (1.5,0.5) node {mRNA};
  \fill
      (2.5,4.5) node {\bf{$\text{cell}_2$}}
   -- (2.5,3.5) node {mRNA}
   -- (2.5,2.5) node {mRNA}
   -- (2.5,1.5) node {$\vdots$}
   -- (2.5,0.5) node {mRNA};
  \fill
      (3.5,4.5) node {\bf{$\cdots$}}
   -- (3.5,3.5) node {$\cdots$}
   -- (3.5,2.5) node {$\cdots$}
   -- (3.5,1.5) node {$\ddots$}
   -- (3.5,0.5) node {$\cdots$};
  \fill
      (4.5,4.5) node {\bf{$\text{cell}_c$}}
   -- (4.5,3.5) node {mRNA}
   -- (4.5,2.5) node {mRNA}
   -- (4.5,1.5) node {$\vdots$}
   -- (4.5,0.5) node {mRNA};
  \draw (1,0) grid (5,4);
\end{tikzpicture}
\end{center}

\end{columns}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
386
## single-cell RNA Sequencing
387
388
389
390
391
392
393
394
395
396
397

\begin{center}
\begin{columns}
\column{0.5\textwidth}

\includegraphics[width=\textwidth]{img/10x_r1_r2.png}

\column{0.5\textwidth}

{\bf We want:}\\[1em]
\begin{itemize}
398
399
400
  \item identify the cell : {\bf 10x barcode} 
  \item identify the gene : {\bf cDNA sequence} 
  \item count the mRNA : {\color{red}\bf UMI $\times$ cDNA sequence} 
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
\end{itemize}
\vspace{1em}

\begin{center}
\begin{tikzpicture}
  \fill
      (0.5,3.5) node {\bf $\text{gene}_1$}
   -- (0.5,2.5) node {\bf $\text{gene}_2$}
   -- (0.5,1.5) node {\bf $\vdots$}
   -- (0.5,0.5) node {\bf $\text{gene}_n$};
  \fill
      (1.5,4.5) node {\bf{$\text{cell}_1$}}
   -- (1.5,3.5) node {\color{red} mRNA}
   -- (1.5,2.5) node {\color{red} mRNA}
   -- (1.5,1.5) node {$\vdots$}
   -- (1.5,0.5) node {\color{red} mRNA};
  \fill
      (2.5,4.5) node {\bf{$\text{cell}_2$}}
   -- (2.5,3.5) node {\color{red} mRNA}
   -- (2.5,2.5) node {\color{red} mRNA}
   -- (2.5,1.5) node {$\vdots$}
   -- (2.5,0.5) node {\color{red} mRNA};
  \fill
      (3.5,4.5) node {\bf{$\cdots$}}
   -- (3.5,3.5) node {$\cdots$}
   -- (3.5,2.5) node {$\cdots$}
   -- (3.5,1.5) node {$\ddots$}
   -- (3.5,0.5) node {$\cdots$};
  \fill
      (4.5,4.5) node {\bf{$\text{cell}_c$}}
   -- (4.5,3.5) node {\color{red} mRNA}
   -- (4.5,2.5) node {\color{red} mRNA}
   -- (4.5,1.5) node {$\vdots$}
   -- (4.5,0.5) node {\color{red} mRNA};
  \draw (1,0) grid (5,4);
\end{tikzpicture}
\end{center}

\end{columns}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
442
# Fastq processing
443

Laurent Modolo's avatar
Laurent Modolo committed
444
## Fastq preparation
445
446
447
448
449

\begin{center}
\includegraphics[width=0.8\textwidth]{./img/barcode_umi_sequence_split_fastq.png}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
450
## Cell barcode correction
Laurent Modolo's avatar
Laurent Modolo committed
451

452
453
454
\begin{center}
\begin{columns}
\column{0.5\textwidth}
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
\begin{block}{hash function}
  any function that can be used to map data of arbitrary size to fixed-size values. 
\end{block}
\column{0.5\textwidth}
\vspace{2em}
\includegraphics[width=0.7\textwidth]{./img/hash_function.png}
\end{columns}
\end{center}

\vspace{-2em}

\begin{center}
\begin{columns}
\column{0.5\textwidth}
\includegraphics[width=0.9\textwidth]{./img/whitelist_hamming_dist.png}
470
471
472
473
474
475
476
477
\column{0.5\textwidth}

The list of cell barcode is known:
\begin{itemize}
\item Hamming distance $1$: $0.8$\% more reads
\item Hamming distance $2$: $0.0038$\% more reads
\end{itemize}

478
We can take into account the sequence quality
479
480
481
\end{columns}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
482
# sequence alignment
483

Laurent Modolo's avatar
Laurent Modolo committed
484
## mRNA identification
485
486
487
488

We need to **align** the cDNA sequence part of the read to a reference genome. \includegraphics[width=0.2\textwidth]{./img/mapping_read.png}

\begin{block}{Smith–Waterman algorithm}
Laurent Modolo's avatar
Laurent Modolo committed
489
Local sequence alignment, which aims at determining similar regions between two sequences.
490
491
492
493
494
\end{block}

**Substitution matrix**

\vspace{1em}
495
496

\begin{center}
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
\begin{columns}
\column{0.5\textwidth}
\begin{table}[!ht]
    \centering
    \begin{tabular}{|r|r|r|r|r|}
    \hline
        - & A & G & C & T \\ \hline
        A & 3 & -3 & -3 & -3 \\ \hline
        G & -3 & 3 & -3 & -3 \\ \hline
        C & -3 & -3 & 3 & -3 \\ \hline
        T & -3 & -3 & -3 & 3 \\ \hline
    \end{tabular}
\end{table}
\column{0.5\textwidth}
$s(a_i,b_j) = \begin{cases}+3, \quad a_i=b_j \\ -3, \quad a_i\ne b_j\end{cases}$
\end{columns}
513
\end{center}
Laurent Modolo's avatar
Laurent Modolo committed
514

Laurent Modolo's avatar
Laurent Modolo committed
515
## mRNA identification
516

517
518
519
We need to **align** the cDNA sequence part of the read to a reference genome. \includegraphics[width=0.2\textwidth]{./img/mapping_read.png}

\begin{block}{Smith–Waterman algorithm}
Laurent Modolo's avatar
Laurent Modolo committed
520
Local sequence alignment, which aims at determining similar regions between two sequences.
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
\end{block}

**Gap penalty**

\vspace{1em}

\begin{center}
\begin{columns}
\column{0.3\textwidth}
linear:

$W_k=kW_1$

\column{0.5\textwidth}
We can add constrains to the penalty, in EMBOSS we have:
  \begin{itemize}
    \item gap opening $W = 10$
    \item gap extension $W= 0.5$. 
  \end{itemize}
\end{columns}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
543
## mRNA identification
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566

**Scoring matrix**

Fill the scoring matrix using the equation below.
\[
H_{ij} = \max\begin{cases} 
H_{i-1,j-1} + s(a_i,b_j), \\
\max_{k \ge 1} \{ H_{i-k,j} - W_k \}, \\
\max_{l \ge 1} \{ H_{i,j-l} - W_l \}, \\
0
\end{cases} \qquad (1\le i\le n, 1\le j\le m)
\]

\vspace{-1.5em}

where
\begin{itemize}
\item $H_{i-1,j-1} + s(a_i,b_j)$ is the score of aligning $a_i$ and $b_j$,
\item $H_{i-k,j} - W_k$ is the score if $a_i$ is at the end of a gap of length $k$,
\item $H_{i,j-l} - W_l$ is the score if $b_j$ is at the end of a gap of length $l$,
\item $0$ means there is no similarity up to $a_i$ and $b_j$.
\end{itemize}

Laurent Modolo's avatar
Laurent Modolo committed
567
## mRNA identification
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584

**Scoring matrix** with $W_k=k2$

Fill the scoring matrix using the equation below.
\[
H_{ij} = \max\begin{cases} 
H_{i-1,j-1} + s(a_i,b_j), \\
\max_{k \ge 1} \{ H_{i-k,j} - W_k \}, \\
\max_{l \ge 1} \{ H_{i,j-l} - W_l \}, \\
0
\end{cases} \qquad (1\le i\le n, 1\le j\le m)
\]

\begin{center}
\includegraphics[width=\textwidth]{./img/Smith-Waterman-Algorithm-Example-Step1.png}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
585
## mRNA identification
586
587
588
589
590
591
592
593
594
595
596

**Scoring matrix**

\vspace{-3.5em}

\begin{center}
\includegraphics[width=0.4\textwidth]{./img/Smith-Waterman-Algorithm-Example-Step2.png}
\end{center}

We fill all the elements

Laurent Modolo's avatar
Laurent Modolo committed
597
## mRNA identification
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615

**Scoring matrix**

Traceback: starting at the

highest score ending at 

a matrix cell that has a

score of 0

\vspace{-12.5em}

\begin{center}
\includegraphics[width=0.4\textwidth]{./img/Smith-Waterman-Algorithm-Example-Step3.png}
\end{center}


Laurent Modolo's avatar
Laurent Modolo committed
616
## mRNA identification
617
618
619
620
621
622
623
624
625

\begin{block}{Smith–Waterman algorithm}
The complexity of the algorithm is of {\color{red} $O(nm)$} with {\color{red} $n$} the size of the sequence and {\color{red} $m$} the size of the genome (reference)
\end{block}

**Impractical for NGS data**

\begin{itemize}
  \item reads : $m = 100-200$ bases ($\times 2$)
Laurent Modolo's avatar
Laurent Modolo committed
626
  \item human genome : $n \simeq 3^{9}$ bases
627
628
629
  \item number of reads $10^{7-9}$
\end{itemize}

Laurent Modolo's avatar
Laurent Modolo committed
630
631
632
# Sequence mapping

## Mapping algorithm
633
634
635

Mapping algorithms specialized alignment algorithm for NGS data

Laurent Modolo's avatar
Laurent Modolo committed
636
They all work using $k$-mers or *seeds*
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655

\begin{block}{$k$-mers}
A $k$-mers is a sequence of size $k$, with $k$ often small ($\sim 30$ bases)
\begin{table}[!ht]
    \centering
    \begin{tabular}{|l|l|}
    \hline
        $k$ & $k$-mers \\ \hline
        1 & A, C, G, T \\ \hline
        2 & AA, AC, AG, AT, CC, CA, CG, CT, ... \\ \hline
        3 & AAA, AAC, AAT, AAG, ACA, ACC, ACT, ... \\ \hline
        4 & AAAA, AAAC, AAAG, AAAT, AACA, AACG, ... \\ \hline
        ... &  \\ \hline
    \end{tabular}
\end{table}
\end{block}

We have $4^k$ possible $k$-mers of size $k$

Laurent Modolo's avatar
Laurent Modolo committed
656
## Mapping algorithm
657
658
659
660
661
662
663
664
665

We can use $k$-mers to describe a sequence

\begin{center}
\includegraphics[width=\textwidth]{img/indexing_1.png}
\end{center}
\vspace{-2em}
and store the $k$-mers in a hash table

Laurent Modolo's avatar
Laurent Modolo committed
666
## Mapping algorithm
667
668
669
670
671
672
673
674
675

They are efficient way to store $k$-mers

\begin{center}
\includegraphics[width=\textwidth]{img/indexing_2.png}
\end{center}
\vspace{-2em}
like a suffix tree or the Burrows-Wheeler transform

Laurent Modolo's avatar
Laurent Modolo committed
676
## Mapping algorithm
677

Laurent Modolo's avatar
Laurent Modolo committed
678
Instead of comparing the full sequences, we search only some $k$-mers of each read and find their possible positions.
679
680
681
682
683

\begin{center}
\includegraphics[width=\textwidth]{img/mapping_1.png}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
684
## Mapping algorithm
685
686
687
688
689
690
691

The compatible reads $k$-mers are chained together to get a pre-alignment

\begin{center}
\includegraphics[width=0.6\textwidth]{img/mapping_2.png}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
692
Finally, the pre-alignments are corrected using a classical alignment algorithm like Smith–Waterman
693

Laurent Modolo's avatar
Laurent Modolo committed
694
## Mapping algorithm
695
696
697
698
699

After the different step:
\vspace{-1em}

1. indexing (only once of a reference genome)
Laurent Modolo's avatar
Laurent Modolo committed
700
701
2. pre-alignment
3. final alignment
702
703
704
705
706
707
708
709
710
711
712

We get a **SAM**/**BAM**/**CRAM** (text / binary / compressed) which describe for each read:
\vspace{-1em}

- read name
- read sequence
- read quality
- alignment information
- custom tags
- chromosome start coordinate
- alignment quality
Laurent Modolo's avatar
Laurent Modolo committed
713
- match descriptors string
714

Laurent Modolo's avatar
Laurent Modolo committed
715
# Sequence target
716

Laurent Modolo's avatar
Laurent Modolo committed
717
718
719
## mRNA identification

We want to map the reads on the genes sequence, but which one ?
720
721

\begin{center}
Laurent Modolo's avatar
Laurent Modolo committed
722
\includegraphics[width=\textwidth]{img/splicing_one_gene_multiple_functions.png}
723
724
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
725
## mRNA identification
726

Laurent Modolo's avatar
Laurent Modolo committed
727
RNA-Seq mapper like: **STAR** or **HISAT2** will split reads to span splicing sites.
728
729

\begin{center}
Laurent Modolo's avatar
Laurent Modolo committed
730
\includegraphics[width=0.6\textwidth]{img/quantif_all_reads.png}
731
732
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
733
## mRNA identification
734

Laurent Modolo's avatar
Laurent Modolo committed
735
736
737
738
739
740
\begin{center}
\includegraphics[width=0.7\textwidth]{img/quantif_all_reads_density_1.png}
\end{center}

Exons sequences can be shared between mRNA sequences.

Laurent Modolo's avatar
Laurent Modolo committed
741
## mRNA identification
742
743

\begin{center}
Laurent Modolo's avatar
Laurent Modolo committed
744
\includegraphics[width=0.7\textwidth]{img/quantif_all_reads_density_2.png}
745
746
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
747
748
Exons sequences can be shared between mRNA sequences.

Laurent Modolo's avatar
Laurent Modolo committed
749
Under the hypothesis of **coverage uniformity**, we can estimate the average read number per mRNA sequences. 
750

Laurent Modolo's avatar
Laurent Modolo committed
751
## mRNA identification
752

753
\vspace{-2em}
Laurent Modolo's avatar
Laurent Modolo committed
754
755
756
757
\begin{center}
\end{center}
\includegraphics[width=0.9\textwidth]{img/detected_gene_good_exonic_mapping.png}

Laurent Modolo's avatar
Laurent Modolo committed
758
## mRNA identification
Laurent Modolo's avatar
Laurent Modolo committed
759
760
761
762
763
764
765

Do we keep reads mapping to introns ?

\begin{center}
\includegraphics[width=0.8\textwidth]{img/undetect_read_intronic_mapping.png}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
766
## mRNA identification
Laurent Modolo's avatar
Laurent Modolo committed
767
768
769
770
771
772
773

Do we keep reads mapping to introns ?

\begin{center}
\includegraphics[width=0.7\textwidth]{img/premrna_prop.png}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
774
## mRNA identification
Laurent Modolo's avatar
Laurent Modolo committed
775

Laurent Modolo's avatar
Laurent Modolo committed
776
Do we keep reads mapping after the annotated 3' UTR ?
Laurent Modolo's avatar
Laurent Modolo committed
777
778
779
780
781

\begin{center}
\includegraphics[width=0.65\textwidth]{img/undetected_read_intergenic_mapping.png}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
782
## mRNA identification
Laurent Modolo's avatar
Laurent Modolo committed
783

Laurent Modolo's avatar
Laurent Modolo committed
784
Do we keep reads mapping after the annotated 3' UTR ?
Laurent Modolo's avatar
Laurent Modolo committed
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799

\vspace{2em}

\begin{center}
\begin{columns}
\column{0.65\textwidth}
\begin{center}
\includegraphics[width=\textwidth]{img/discared_reads.png
}
\end{center}
\column{0.35\textwidth}
{\bf Your best marker genes could be in the small percent of genes lost}
\end{columns}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
800
## mRNA identification
Laurent Modolo's avatar
Laurent Modolo committed
801
802
803
804
805
806
807
808

Why bother ?
\vspace{-1.5em}

\begin{center}
\includegraphics[width=.8\textwidth]{img/full_length_vs_3prim.png
}
\end{center}
809
810

# Quantification
Laurent Modolo's avatar
Laurent Modolo committed
811

Laurent Modolo's avatar
Laurent Modolo committed
812
813
## Quantification

Laurent Modolo's avatar
Laurent Modolo committed
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
\begin{center}
\begin{columns}
\column{0.5\textwidth}
{\bf We want to:}\\[1em]
\begin{itemize}
  \item identify the cell : {\bf 10x barcode} 
  \item identify the gene : {\bf cDNA sequence} 
  \item count the mRNA : {\color{red} \bf UMI $\times$ cDNA sequence} 
\end{itemize}
\vspace{1em}

\column{0.5\textwidth}
\begin{center}
\begin{tikzpicture}
  \fill
      (0.5,3.5) node {\bf $\text{gene}_1$}
   -- (0.5,2.5) node {\bf $\text{gene}_2$}
   -- (0.5,1.5) node {\bf $\vdots$}
   -- (0.5,0.5) node {\bf $\text{gene}_n$};
  \fill
      (1.5,4.5) node {\bf{$\text{cell}_1$}}
   -- (1.5,3.5) node {\color{red}mRNA}
   -- (1.5,2.5) node {\color{red}mRNA}
   -- (1.5,1.5) node {\color{red}$\vdots$}
   -- (1.5,0.5) node {\color{red}mRNA};
  \fill
      (2.5,4.5) node {\bf{$\text{cell}_2$}}
   -- (2.5,3.5) node {\color{red}mRNA}
   -- (2.5,2.5) node {\color{red}mRNA}
   -- (2.5,1.5) node {\color{red}$\vdots$}
   -- (2.5,0.5) node {\color{red}mRNA};
  \fill
      (3.5,4.5) node {\bf{$\cdots$}}
   -- (3.5,3.5) node {\color{red}$\cdots$}
   -- (3.5,2.5) node {\color{red}$\cdots$}
   -- (3.5,1.5) node {\color{red}$\ddots$}
   -- (3.5,0.5) node {\color{red}$\cdots$};
  \fill
      (4.5,4.5) node {\bf{$\text{cell}_c$}}
   -- (4.5,3.5) node {\color{red}mRNA}
   -- (4.5,2.5) node {\color{red}mRNA}
   -- (4.5,1.5) node {\color{red}$\vdots$}
   -- (4.5,0.5) node {\color{red}mRNA};
  \draw (1,0) grid (5,4);
\end{tikzpicture}
\end{center}
\end{columns}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
863
We could count the reads falling into the *gene annotation* but we would overestimate the mRNA count (PCR amplification bias)
Laurent Modolo's avatar
Laurent Modolo committed
864
865


Laurent Modolo's avatar
Laurent Modolo committed
866
## Unique molecular identifiers (UMI)
Laurent Modolo's avatar
Laurent Modolo committed
867

868
869
870
871
\begin{center}
\includegraphics[width=0.8\textwidth]{img/umi_collision.png}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
872
Estimated number of intra-gene collision:
873
874
875

- v2: highly expressed $0.4$\%, $0.003$ on average
- v3: highly expressed $0.17$\%, $0.0000048$ on average
Laurent Modolo's avatar
Laurent Modolo committed
876

Laurent Modolo's avatar
Laurent Modolo committed
877
878
879
880

# Pipelines

## Analysis pipeline: Cell-Ranger
Laurent Modolo's avatar
Laurent Modolo committed
881

882
883
884
885
\begin{center}
\includegraphics[width=0.49\textwidth]{img/cellranger_workflow.png}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
886
## Analysis pipeline: Kallisto-Bustools
887
888
889
890

\begin{center}
\includegraphics[width=0.65\textwidth]{img/kb_workflow.png}
\end{center}
Laurent Modolo's avatar
Laurent Modolo committed
891

Laurent Modolo's avatar
Laurent Modolo committed
892
## Analysis pipeline: Kallisto-Bustools
Laurent Modolo's avatar
Laurent Modolo committed
893
894
895
896
897
898
899

Why pseudo-map when we can use a mapper to map ?

\begin{center}
\includegraphics[width=0.65\textwidth]{img/maping_vs_pseudo_mapping.png}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
900
## pseudo-mapping
Laurent Modolo's avatar
Laurent Modolo committed
901
902
903
904

\begin{center}
\begin{columns}
\column{0.5\textwidth}
Laurent Modolo's avatar
Laurent Modolo committed
905
{\bf Pseudo-alignment:}
Laurent Modolo's avatar
Laurent Modolo committed
906
907
908
909
910
911
912
913
914
915
916
917
918
919
\begin{enumerate}[a)]
  \item reads in black and sequences of the transcript
  \item de Bruijn Graph where nodes ($v_1$, $v_2$, $v_3$, ... ) are $k$-mers \\
  \item find the $k$-compatibility class of a read
  \item skip redundant $k$-mers (same $k$-compatibility class)
  \item $k$-compatibility class of the read is determined by taking the intersection of the $k$-compatibility classes of its constituent $k$-mers.
\end{enumerate}
\column{0.5\textwidth}
\vspace{2em}

\includegraphics[width=0.9\textwidth]{img/pseudo_mapping.png}
\end{columns}
\end{center}

Laurent Modolo's avatar
Laurent Modolo committed
920
## pseudo-mapping: transcript-level quantification
Laurent Modolo's avatar
Laurent Modolo committed
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

With $K$ the $k$-compatibility class counts and $\beta$ the transcript quantification.
\begin{center}
\begin{columns}
\column{0.5\textwidth}
\[
  \begin{bmatrix}
    k_{1}\\
    k_{2}\\
    \vdots\\
    k_{K}
  \end{bmatrix} =
  \begin{bmatrix}
    x_{1,1} & x_{1,2} & \cdots & x_{1,T} \\
    x_{2,1} & x_{2,2} & \cdots & x_{2,T} \\
    \vdots & \vdots & \ddots & \vdots \\
    x_{K,1} & x_{K,2} & \cdots & x_{K,T} \\
  \end{bmatrix} \times
  \begin{bmatrix}
    \beta_{1}\\
    \beta_{2}\\
    \vdots\\
    \beta_{T}
  \end{bmatrix}
\]
\column{0.5\textwidth}
\begin{enumerate}
  \item given $K$ and $X$ estimate ${\beta}$ per cell
Laurent Modolo's avatar
Laurent Modolo committed
949
  \item given $K$ and ${\beta}$ estimate $X$ across cells
Laurent Modolo's avatar
Laurent Modolo committed
950
951
952
953
954
955
956
957
958
\end{enumerate}
\end{columns}
\end{center}

\vspace{2em}

\begin{center}
\includegraphics[width=\textwidth]{img/scasa_vs_other.png}
\end{center}
Laurent Modolo's avatar
Laurent Modolo committed
959

960

Laurent Modolo's avatar
Laurent Modolo committed
961
962
963
964
965
966
## References

* [Zheng, Grace X. Y., Jessica M. Terry, Phillip Belgrader, Paul Ryvkin, Zachary W. Bent, Ryan Wilson, Solongo B. Ziraldo, et al. Massively Parallel Digital Transcriptional Profiling of Single Cells. Nature Communications 8, no. 1 (16 January 2017): 14049.](https://doi.org/10.1038/ncomms14049.)
* [Melsted, Páll, A. Sina Booeshaghi, Lauren Liu, Fan Gao, Lambda Lu, Kyung Hoi (Joseph) Min, Eduardo da Veiga Beltrame, Kristján Eldjárn Hjörleifsson, Jase Gehring, and Lior Pachter. Modular, Efficient and Constant-Memory Single-Cell RNA-Seq Preprocessing. Nature Biotechnology 39, no. 7 (July 2021): 813–18.](https://doi.org/10.1038/s41587-021-00870-2)
* [Bray, Nicolas L., Harold Pimentel, Páll Melsted, and Lior Pachter. Near-Optimal Probabilistic RNA-Seq Quantification. Nature Biotechnology 34, no. 5 (May 2016): 525–27.](https://doi.org/10.1038/nbt.3519)
* [Pan, Lu, Huy Q Dinh, Yudi Pawitan, and Trung Nghia Vu. Isoform-Level Quantification for Single-Cell RNA Sequencing. Bioinformatics 38, no. 5 (1 March 2022): 1287–94.](https://doi.org/10.1093/bioinformatics/btab807)
967