-
Notifications
You must be signed in to change notification settings - Fork 15
/
Feng-Doolittle.html
496 lines (432 loc) · 21.3 KB
/
Feng-Doolittle.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
<!--
University of Freiburg WS 2017/2018
Chair for Bioinformatics
Supervisor: Martin Raden
Authors: Alexander Mattheis, Martin Raden
-->
<div id="algorithm_description">
<div class="description">
The progressive alignment approach by
<a href="https://doi.org/10.1007/BF02603120">Da-Fei Feng and Russell F. Doolittle (1987)</a>
computes a multi-sequence-alignment (MSA) of a set of sequences based on pairwise alignments.
This approximative approach identifies good MSA solutions in reasonable time.
<br />
<br />
First, all pairwise alignments with maximal similarity of all input sequence pairs are computed.
To this end, we use <a href="https://doi.org/10.1016/0022-2836(82)90398-9">Osamu Gotoh's (1982)</a>
approach available in
<a href="http://rna.informatik.uni-freiburg.de/Teaching/index.jsp?toolName=Gotoh">our Gotoh implementation</a>.
<br />
In order to build a guide tree to generate the MSA,
observed similarity scores $S(a,b)$ of sequence pairs $a,b\in\Sigma^{*}$ are converted into distances using
$D(a,b) = -ln(S^{eff}_{a,b} \cdot f)$, where we set the scaling factor $f=1$ (originally $f = 100$). <br />
The 'effective' similarity score $S^{eff}$ is computed by $S^{eff}_{a,b} = (S(a,b) - S^{rand}_{a,b})/(S^{max}_{a,b} - S^{rand}_{a,b})$
where $S^{max}_{a,b} = (S(a,a)+S(b,b))/2$ provides the best alignment score for both sequences.
$S^{rand}$ provides a kind of 'expected score' that can be obtained via sequence randomization.
Here, we use an alternative approach introduced in
<a href="https://doi.org/10.1016/s0076-6879(96)66023-6">(Feng&Doolittle, 1996)</a>
using the approximate formula for a given optimal alignment of $a$ and $b$:
$$
\quad
S^{rand}_{a,b} =
\frac{1}{L_{a,b}}
\bigg(
\sum_{x \in \Sigma} \sum_{y \in \Sigma}
s(x,y) \cdot N_a(x) \cdot N_b(y)
\bigg)
+ N_{a,b}^{e} \cdot \beta
+ N_{a,b}^{o} \cdot \alpha
$$
where <br />
<div class="row">
<div class="colW150">$L_{a,b}$</div>
<div class="colW400">number of columns in the alignment of $a,b$</div>
</div>
<div class="row">
<div class="colW150">$s(x,y)$</div>
<div class="colW400">similarity-score for aligning the characters $x$ and $y$</div>
</div>
<div class="row">
<div class="colW150">$N_a(x), N_b(y)$</div>
<div class="colW400">number of characters $x$ and $y$ in sequences $a$ and $b$, resp.</div>
</div>
<div class="row">
<div class="colW150">$N_{a,b}^{e}$</div>
<div class="colW400">number of gaps (enlargements)</div>
</div>
<div class="row">
<div class="colW150">$N_{a,b}^{o}$</div>
<div class="colW400">number of gap openings (adaptation for Gotoh)</div>
</div>
<div class="row">
<div class="colW150">$\alpha, \beta$</div>
<div class="colW400">
parameters from
<a href="http://rna.informatik.uni-freiburg.de/Teaching/index.jsp?toolName=Gotoh">Gotoh</a> algorithm
</div>
</div>
The resulting distances are then used
to create a phylogenetic tree that guides the generation of the MSA, i.e. more related (similar) sequences are fused first.
Here, the <a href="http://rna.informatik.uni-freiburg.de/Teaching/index.jsp?toolName=Agglomerative-Clustering">UPGMA</a> algorithm envisioned
by <a href="https://archive.org/details/cbarchive_33927_astatisticalmethodforevaluatin1902">Robert R. Sokal and Charles D. Michener (1958)</a> is applied.
<br />
The tree defines the order in which sequences or groups of sequences
have to be fused to create a multi-sequence-alignment (MSA).
The fusion is done based on the best pairwise alignment between members of the groups to be aligned.
To simplify the fusion, the 'once a gap, always a gap'-strategy is applied,
i.e. once a gap is introduced in a sequence it is preserved within all subsequent fusions.
To this end, gaps in subalignments are replaced with
a neutral symbol $\#$ before aligning them (i.e. $s(\cdot,\#) = s(\#,\cdot) = 0$).
<br />
<br />
For a given input, the stated computation steps generate
<ul>
<li>pairwise alignments</li>
<li>distance matrix</li>
<li>phylogenetic tree</li>
<li>multiple sequence alignment (MSA) with SoP score</li>
</ul>
and are represented in reversed order below. <br />
The sum-of-pairs (SoP) score of the final MSA is simply the score sum of all pairwise
alignments within the MSA, i.e. of pairwise row combinations where overlying gap columns are removed
since we are using an affine gap cost model.
</div>
<div class="picture">
<img src="Feng-Doolittle-120x90.png" />
</div>
</div>
<h1>Input:</h1>
<div id="algorithm_input">
<!-- ko foreach: $root.input.sequences() -->
<div class="row">
<div class="colW100">
<label>
Sequence <span data-bind="text: $root.input.clusterNames()[$index()]"></span>:
</label>
</div>
<div class="colW225">
<input class="sequence_multi" data-bind="value: $data" placeholder="EXAMPLE 'ATC'" title="Allowed are A-Z and '-'." type="text">
<!-- ko if: $index() == $root.input.clusterNames().length-1 -->
<div class="group_hint">
<b>Hints:</b> <br />
The "+" and "-" buttons can be used to add or remove sequences.
Duplicates of sequences are excluded from computations.
<!-- The distance formula
is not defined for two sequences of same type,
because the denominator gets zero.
Also, this allows a bigger code readability and runtime enhancement:
Sequences are stored as keys in hash-tables and
two times the same key is not possible in a hash-table!
-->
</div>
<!-- /ko -->
</div>
<!-- ko if: $index() == $root.input.clusterNames().length-1 -->
<button class="add_remove" data-bind="click: $root.input.addRow" title="Add Sequence" type="button">+</button>
<!-- /ko -->
<!-- ko if: $index() == $root.input.clusterNames().length-1 && $root.input.clusterNames().length > 2 -->
<button class="add_remove" data-bind="click: $root.input.removeRow" title="Remove Sequence" type="button">-</button>
<!-- /ko -->
</div>
<!-- /ko -->
<div class="row">
<div class="colW100"><label>Scoring in $s$:</label></div>
<div class="colW400">
<span class="group"> <!-- Microsoft Browsers will fallback on text-fields using following input type -->
Match <input class="fx_parameter" data-bind="value: input.match" id="match" type="number">
Mismatch <input class="fx_parameter" data-bind="value: input.mismatch" id="mismatch" type="number">
</span>
</div>
</div>
<div class="row">
<div class="colW100"><label>Scoring in $g$:</label></div>
<div class="colW400">
<span class="group"> <!-- Microsoft Browsers will fallback on text-fields using following input type -->
Gap opening $\alpha$ <input class="fx_parameter" data-bind="value: input.baseCosts" id="base_costs" type="number">
Enlargement $\beta$ <input class="fx_parameter" data-bind="value: input.enlargement" id="enlargement" type="number">
</span>
<br />
<br />
<span data-bind="text: $root.input.gapFunction"></span>
<div class="group_hint">
<b>Hint:</b> <br />
For similarity maximization, <br /> match scores should be positive and all other scores lower. <br />
</div>
</div>
</div>
</div>
<h1>Output:</h1>
<div id="algorithm_output">
<div class="final">
<table class="final_result_header">
<thead>
<tr>
<th>
Final result
</th>
</tr>
</thead>
</table>
<div class="final_result_with_scrollbar">
<table class="final_result">
<tbody>
<tr>
<td class="entry entry_start">
<!-- ko foreach: $root.output.progressiveAlignment() -->
<code data-bind="text: $root.output.progressiveAlignment()[$index()]"></code> <br />
<!-- /ko -->
</td>
</tr>
</tbody>
</table>
</div>
<table class="final_result_footer">
<tr>
<th>
<small>
Affine SoP score: <span data-bind="text: $root.output.score()"></span>
</small>
</th>
</tr>
</table>
</div>
<h2>Intermediate Results</h2>
<div class="merge_steps">
<table class="result_header">
<thead>
<tr>
<th>
Fusion steps
</th>
</tr>
</thead>
</table>
<div class="result_with_scrollbar">
<table class="result_categories">
<thead>
<tr>
<th>
<small><b>Group 1</b></small>
</th>
<th>
<small><b>Group 2</b></small>
</th>
<th>
<small><b>Guide Alignment</b></small>
</th>
<th>
<small><b>Result</b></small>
</th>
</tr>
</thead>
<tbody>
<!-- ko foreach: $root.output.guideAlignments() -->
<tr>
<td class="entry entry_start">
<code data-bind="text: $root.output.firstGroupsNames()[$index()]"></code>: <br />
<!-- ko foreach: $root.output.firstGroups()[$index()] -->
<code data-bind="text: $data"></code> <br />
<!-- /ko -->
</td>
<td class="entry entry_start">
<code data-bind="text: $root.output.secondGroupsNames()[$index()]"></code>: <br />
<!-- ko foreach: $root.output.secondGroups()[$index()] -->
<code data-bind="text: $data"></code> <br />
<!-- /ko -->
</td>
<td class="entry entry_start">
<code data-bind="text: $root.output.guideAlignmentsNames()[$index()]"></code>: <br />
<code data-bind="text: $root.output.guideAlignments()[$index()][0]"></code> <br />
<code data-bind="text: $root.output.guideAlignments()[$index()][1]"></code> <br />
<code data-bind="text: $root.output.guideAlignments()[$index()][2]"></code>
</td>
<td class="entry entry_start">
<code data-bind="text: $root.output.joinedGroupNames()[$index()]"></code>: <br />
<!-- ko foreach: $root.output.joinedGroups()[$index()] -->
<code data-bind="text: $data"></code> <br />
<!-- /ko -->
</td>
</tr>
<!-- /ko -->
</tbody>
</table>
</div>
</div>
<h2>Phylogenetic Tree</h2>
<div class="newick_tree">
<table class="result_header">
<thead>
<tr>
<th>
Newick Tree
</th>
</tr>
</thead>
</table>
<div class="result_with_scrollbar">
<table class="result">
<tbody>
<tr>
<td class="entry entry_start">
<code data-bind="text: $root.output.newickString()"></code>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="tree_container"> <!-- allows to delete and reinsert the div -->
<div id="phylogenetic_tree"></div>
</div>
<!-- ko if: $root.output.newickString().length !== 1 && $root.output.newickString().indexOf(SYMBOLS.MINUS) === -1 -->
<div class="group_hint">
<b>Visualization done with</b> <br />
Smits SA, Ouverney CC, 2010. jsPhyloSVG: <br />
A Javascript Library for Visualizing Interactive and Vector-Based Phylogenetic Trees on the Web. <br />
<a href="http://www.plosone.org/article/info:doi/10.1371/journal.pone.0012267">
PLoS ONE 5(8): e12267. doi:10.1371/journal.pone.0012267
</a>
</div>
<!-- /ko -->
<div class="group_hint">
<b>Hint: </b> Visualization is only shown, if there are no negative distances.
</div>
<h2>Distance Table</h2>
<!-- ko if: $root.output.progressiveAlignment()[0].length > 0 -->
<div class="distance_table">
<table class="distances">
<thead>
<tr>
<th></th>
<!-- ko foreach: $root.output.remainingClusters()[0] -->
<th data-bind="drawChar: [$data, undefined]"></th>
<!-- /ko -->
</tr>
</thead>
<tbody>
<!-- ko foreach: $root.output.distanceMatrices()[0][0]--> <!-- to get i-indexes = $parentContext.$index() -->
<tr>
<th data-bind="drawChar: [$root.output.remainingClusters()[0][$index()], undefined]"></th>
<!-- ko foreach: $root.output.distanceMatrices()[0][0] --> <!-- to get j-indexes = $index() -->
<!-- ko if: $index() >= $parentContext.$index() -->
<td class="non_selectable_entry"
data-bind="text: $root.output.distanceMatrices()[0][$parentContext.$index()][$index()]">
</td>
<!-- /ko -->
<!-- ko if: $index() < $parentContext.$index() -->
<td class="non_selectable_entry gray"
data-bind="text: $root.output.distanceMatrices()[0][$parentContext.$index()][$index()]">
</td>
<!-- /ko -->
<!-- /ko -->
</tr>
<!-- /ko -->
<tr>
<th class="hint" colspan=100%> <!-- HINT: move colspan into "hint"-class when browsers are ready! -->
<small>
<b>Minimum:</b> <span data-bind="text: $root.output.minimums()[0]"></span>
</small>
</th>
</tr>
</tbody>
</table>
</div>
<a href="#" data-bind="click: $root.output.toggleVisibility, text: $root.output.toggleLinkText"></a>
<!-- /ko -->
<div class="matrices" data-bind="visible: $root.output.showMatrices">
<!-- ko foreach: $root.output.distanceMatrices() -->
<!-- ko if: $index() > 0 -->
<h3 class="header">Iteration <span data-bind="text: $index()"></span></h3>
<div class="distance_table">
<table class="distances">
<thead>
<tr>
<th></th>
<!-- ko foreach: $root.output.remainingClusters()[$index()] -->
<th data-bind="drawChar: [$data, undefined]"></th>
<!-- /ko -->
</tr>
</thead>
<tbody>
<!-- ko foreach: $root.output.distanceMatrices()[$index()] --> <!-- to get i-indexes = $parentContext.$index() -->
<tr>
<th data-bind="drawChar: [$root.output.remainingClusters()[$parentContext.$index()][$index()], undefined]"></th>
<!-- ko foreach: $root.output.distanceMatrices()[$parentContext.$index()][$index()] --> <!-- to get j-indexes = $index() -->
<!-- ko if: $index() >= $parentContext.$index() -->
<td class="non_selectable_entry"
data-bind="text: $root.output.distanceMatrices()[$parentContext.$parentContext.$index()][$parentContext.$index()][$index()]">
</td>
<!-- /ko -->
<!-- ko if: $index() < $parentContext.$index() -->
<td class="non_selectable_entry gray"
data-bind="text: $root.output.distanceMatrices()[$parentContext.$parentContext.$index()][$parentContext.$index()][$index()]">
</td>
<!-- /ko -->
<!-- /ko -->
</tr>
<!-- /ko -->
<!-- ko if: $index() < $root.output.distanceMatrices().length-1 --> <!-- The last minimum is not computed -->
<tr>
<th class="hint" colspan=100%> <!-- HINT: move colspan into "hint"-class when browsers are ready! -->
<small>
<b>Minimum:</b> <span data-bind="text: $root.output.minimums()[$index()]"></span>
</small>
</th>
</tr>
<!-- /ko -->
</tbody>
</table>
</div>
<!-- /ko -->
<!-- /ko -->
</div>
<h2>Pairwise Data</h2>
<div class="pairwise_data">
<div class="result_with_scrollbar">
<table class="result_categories top_border">
<thead>
<tr>
<th>
<small><b>Sequence Pair</b></small>
</th>
<th>
<small><b>Length $L$</b></small>
</th>
<th>
<small><b>Score $S$</b></small>
</th>
<th>
<small><b>Gaps $N^e$</b></small>
</th>
<th>
<small><b>Gap openings $N^o$</b></small>
</th>
</tr>
</thead>
<tbody>
<!-- ko foreach: $root.output.sequencePairNames() -->
<tr>
<td class="entry entry_start">
<code>(</code><code data-bind="text: $data[0]"></code><code>,</code>
<code data-bind="text: $data[1]"></code><code>)</code>
<br />
</td>
<td class="entry entry_start">
<code data-bind="text: $root.output.alignmentLengths()[$index()]"></code> <br />
</td>
<td class="entry entry_start">
<code data-bind="text: $root.output.similarities()[$index()]"></code> <br />
</td>
<td class="entry entry_start">
<code data-bind="text: $root.output.gapNumbers()[$index()]"></code> <br />
</td>
<td class="entry entry_start">
<code data-bind="text: $root.output.gapStarts()[$index()]"></code> <br />
</td>
</tr>
<!-- /ko -->
</tbody>
</table>
</div>
</div>
</div>