Download - Sequence Alignment
![Page 1: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/1.jpg)
.
Sequence Alignment
![Page 2: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/2.jpg)
Sequences
Much of bioinformatics involves sequences DNA sequences RNA sequences Protein sequences
We can think of these sequences as strings of letters DNA & RNA: alphabet of 4 letters Protein: alphabet of 20 letters
![Page 3: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/3.jpg)
20 Amino Acids
Glycine (G, GLY) Alanine (A, ALA) Valine (V, VAL) Leucine (L, LEU) Isoleucine (I, ILE) Phenylalanine (F, PHE) Proline (P, PRO) Serine (S, SER) Threonine (T, THR) Cysteine (C, CYS) Methionine (M, MET) Tryptophan (W, TRP) Tyrosine (T, TYR) Asparagine (N, ASN) Glutamine (Q, GLN) Aspartic acid (D, ASP) Glutamic Acid (E, GLU) Lysine (K, LYS) Arginine (R, ARG) Histidine (H, HIS) START: AUG STOP: UAA, UAG, UGA
![Page 4: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/4.jpg)
Sequence Comparison
Finding similarity between sequences is important for many biological questions
For example: Find genes/proteins with common origin
Allows to predict function & structure Locate common subsequences in genes/proteins
Identify common “motifs” Locate sequences that might overlap
Help in sequence assembly
![Page 5: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/5.jpg)
Sequence Alignment
Input: two sequences over the same alphabet
Output: an alignment of the two sequences
Example: GCGCATGGATTGAGCGA TGCGCCATTGATGACCA
A possible alignment:
-GCGC-ATGGATTGAGCGA
TGCGCCATTGAT-GACC-A
![Page 6: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/6.jpg)
Alignments
-GCGC-ATGGATTGAGCGA
TGCGCCATTGAT-GACC-A
Three elements: Perfect matches Mismatches Insertions & deletions (indel)
![Page 7: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/7.jpg)
Choosing Alignments
There are many possible alignments
For example, compare:
-GCGC-ATGGATTGAGCGA
TGCGCCATTGAT-GACC-A
to
------GCGCATGGATTGAGCGA
TGCGCC----ATTGATGACCA--
Which one is better?
![Page 8: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/8.jpg)
Scoring Alignments
Rough intuition: Similar sequences evolved from a common
ancestor Evolution changed the sequences from this
ancestral sequence by mutations: Replacements: one letter replaced by another Deletion: deletion of a letter Insertion: insertion of a letter
Scoring of sequence similarity should examine how many operations took place
![Page 9: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/9.jpg)
Simple Scoring Rule
Score each position independently: Match: +1 Mismatch : -1 Indel -2
Score of an alignment is sum of positional scores
![Page 10: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/10.jpg)
Example
Example:
-GCGC-ATGGATTGAGCGA
TGCGCCATTGAT-GACC-A
Score: (+1x13) + (-1x2) + (-2x4) = 3
------GCGCATGGATTGAGCGA
TGCGCC----ATTGATGACCA--
Score: (+1x5) + (-1x6) + (-2x11) = -23
![Page 11: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/11.jpg)
More General Scores
The choice of +1,-1, and -2 scores was quite arbitrary
Depending on the context, some changes are more plausible than others Exchange of an amino-acid by one with similar
properties (size, charge, etc.)
vs. Exchange of an amino-acid by one with opposite
properties
![Page 12: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/12.jpg)
Additive Scoring Rules
We define a scoring function by specifying a function
(x,y) is the score of replacing x by y (x,-) is the score of deleting x (-,x) is the score of inserting x
The score of an alignment is the sum of position scores
}){(}){(:
![Page 13: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/13.jpg)
Edit Distance
The edit distance between two sequences is the “cost” of the “cheapest” set of edit operations needed to transform one sequence into the other
Computing edit distance between two sequences almost equivalent to finding the alignment that minimizes the distance
nment)score(aligmax),d( & of alignment 21 ss21 ss
![Page 14: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/14.jpg)
Computing Edit Distance
How can we compute the edit distance?? If |s| = n and |t| = m, there are more than
alignments
The additive form of the score allows to perform dynamic programming to compute edit distance efficiently
m
nm
![Page 15: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/15.jpg)
Recursive Argument
Suppose we have two sequences:s[1..n+1] and t[1..m+1]
The best alignment must be in one of three cases:
1. Last position is (s[n+1],t[m +1] )2. Last position is (s[n +1],-)3. Last position is (-, t[m +1] )
])[],[(
])..[],..,[(])..[],..[(
1mt1ns
m1tn1sd1m1t1n1sd
![Page 16: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/16.jpg)
Recursive Argument
Suppose we have two sequences:s[1..n+1] and t[1..m+1]
The best alignment must be in one of three cases:
1. Last position is (s[n+1],t[m +1] )2. Last position is (s[n +1],-)3. Last position is (-, t[m +1] )
)],[(
])..[],..,[(])..[],..[(
1ns
1m1tn1sd1m1t1n1sd
![Page 17: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/17.jpg)
Recursive Argument
Suppose we have two sequences:s[1..n+1] and t[1..m+1]
The best alignment must be in one of three cases:
1. Last position is (s[n+1],t[m +1] )2. Last position is (s[n +1],-)3. Last position is (-, t[m +1] )
])[,(
])..[],..,[(])..[],..[(
1nt
m1t1n1sd1m1t1n1sd
![Page 18: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/18.jpg)
Recursive Argument
Define the notation:
Using the recursive argument, we get the following recurrence for V:
])[,(],[
)],[(],[
])[],[(],[
max],[
1jtj1iV
1is1jiV
1jt1isjiV
1j1iV
])..[],..[(],[ j1ti1sdjiV
![Page 19: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/19.jpg)
Recursive Argument
Of course, we also need to handle the base cases in the recursion:
])[,(],[],[
)],[(],[],[
],[
1jtj0V1j0V
1is0iV01iV
000V
![Page 20: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/20.jpg)
Dynamic Programming Algorithm
We fill the matrix using the recurrence rule
0A1
G2
C3
0
A 1
A 2
A 3
C 4
![Page 21: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/21.jpg)
Dynamic Programming Algorithm
0A1
G2
C3
0 0 -2 -4 -6
A 1 -2 1 -1 -3
A 2 -4 -1 0 -2
A 3 -6 -3 -2 -1
C 4 -8 -5 -4 -1
Conclusion: d(AAAC,AGC) = -1
![Page 22: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/22.jpg)
Reconstructing the Best Alignment
To reconstruct the best alignment, we record which case in the recursive rule maximized the score
0A1
G2
C3
0 0 -2 -4 -6
A 1 -2 1 -1 -3
A 2 -4 -1 0 -2
A 3 -6 -3 -2 -1
C 4 -8 -5 -4 -1
![Page 23: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/23.jpg)
Reconstructing the Best Alignment
We now trace back the path the corresponds to the best alignment
0A1
G2
C3
0 0 -2 -4 -6
A 1 -2 1 -1 -3
A 2 -4 -1 0 -2
A 3 -6 -3 -2 -1
C 4 -8 -5 -4 -1
AAACAG-C
![Page 24: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/24.jpg)
Reconstructing the Best Alignment
Sometimes, more than one alignment has the best score
0A1
G2
C3
0 0 -2 -4 -6
A 1 -2 1 -1 -3
A 2 -4 -1 0 -2
A 3 -6 -3 -2 -1
C 4 -8 -5 -4 -1
AAACA-GC
![Page 25: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/25.jpg)
Complexity
Space: O(mn)Time: O(mn) Filling the matrix O(mn) Backtrace O(m+n)
![Page 26: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/26.jpg)
Space Complexity
In real-life applications, n and m can be very large The space requirements of O(mn) can be too
demanding If m = n = 1000 we need 1MB space If m = n = 10000, we need 100MB space
We can afford to perform extra computation to save space Looping over million operations takes less than
seconds on modern workstations
Can we trade off space with time?
![Page 27: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/27.jpg)
Why Do We Need So Much Space?
To compute d(s,t), we only need O(n) space Need to compute V[n,m] Can fill in V, column by column, only storing the last
two columns in memory
Note however This “trick” fails when we need to reconstruct the
sequence Trace back information “eats up” all the memory
![Page 28: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/28.jpg)
Why Do We Need So Much Space?
To find d(s,t), need O(n) space Need to compute V[n,m] Can fill in V, column by
column, storing only two columns in memory
0
-2
-4
-6
-8
-2
1
-1
-3
-5
-4
-1
0
-2
-4
-6
-3
-2
-1
-1
0A1
G2
C3
0
A 1
A 2
A 3
C 4
Note however This “trick” fails when we
need to reconstruct the sequence
Trace back information “eats up” all the memory
![Page 29: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/29.jpg)
Local Alignment
Consider now a different question: Can we find similar substring of s and t Formally, given s[1..n] and t[1..m] find i,j,k, and l
such that d(s[i..j],t[k..l]) is maximal
![Page 30: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/30.jpg)
Local Alignment
As before, we use dynamic programming We now want to setV[i,j] to record the best
alignment of a suffix of s[1..i] and a suffix of t[1..j]
How should we change the recurrence rule?
![Page 31: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/31.jpg)
Local Alignment
New option: We can start a new match instead of extend
previous alignment
0
1jtj1iV1is1jiV
1jt1isjiV
1j1iV])[,(],[)],[(],[
])[],[(],[
max],[
Alignment of empty suffixes
]))[,(],[,max(],[
))],[(],[,max(],[
],[
1jtj0V01j0V
1is0iV001iV
000V
![Page 32: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/32.jpg)
Local Alignment Example
0A1
T2
C3
T4
A5
A6
0
T 1
A 2
A 3
T 4
A 5
s = TAATAt = ATCTAA
![Page 33: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/33.jpg)
Local Alignment Example
0T1
A2
C3
T4
A5
A6
0 0 0 0 0 0 0 0
T 1 0 1 0 0 1 0 0
A 2 0 0 2 0 0 2 1
A 3 0 0 1 1 0 1 3
T 4 0 0 0 0 2 0 1
A 5 0 0 1 0 0 3 1
s = TAATAt = TACTAA
![Page 34: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/34.jpg)
Local Alignment Example
0T1
A2
C3
T4
A5
A6
0 0 0 0 0 0 0 0
T 1 0 1 0 0 1 0 0
A 2 0 0 2 0 0 2 1
A 3 0 0 1 1 0 1 3
T 4 0 0 0 0 2 0 1
A 5 0 0 1 0 0 3 1
s = TAATAt = TACTAA
![Page 35: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/35.jpg)
Local Alignment Example
0T1
A2
C3
T4
A5
A6
0 0 0 0 0 0 0 0
T 1 0 1 0 0 1 0 0
A 2 0 0 2 0 0 2 1
A 3 0 0 1 1 0 1 3
T 4 0 0 0 0 2 0 1
A 5 0 0 1 0 0 3 1
s = TAATAt = TACTAA
![Page 36: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/36.jpg)
Sequence Alignment
We seen two variants of sequence alignment: Global alignment Local alignment
Other variants: Finding best overlap (exercise)
All are based on the same basic idea of dynamic programming
![Page 37: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/37.jpg)
Alignment in Real Life
One of the major uses of alignments is to find sequences in a “database”
Such collections contain massive number of sequences (order of 106)
Finding homologies in these databases with dynamic programming can take too long
![Page 38: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/38.jpg)
Heuristic Search
Instead, most searches relay on heuristic procedures
These are not guaranteed to find the best match Sometimes, they will completely miss a high-
scoring match
We now describe the main ideas used by some of these procedures Actual implementations often contain additional tricks
and hacks
![Page 39: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/39.jpg)
Basic Intuition
Almost all heuristic search procedure are based on the observation that real-life matches often contain long strings with gap-less matches
These heuristic try to find significant gap-less matches and then extend them
![Page 40: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/40.jpg)
Banded DP
Suppose that we have two strings s[1..n] and t[1..m] such that nm
If the optimal alignment of s and t has few gaps, then path of the alignment will be close to diagonal
s
t
![Page 41: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/41.jpg)
Banded DP
To find such a path, it suffices to search in a diagonal region of the matrix
If the diagonal band has width k, then the dynamic programming step takes O(kn)
Much faster than O(n2) of standard DPs
t k
![Page 42: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/42.jpg)
Banded DP
Problem: If we know that t[i..j] matches the query s, then we
can use banded DP to evaluate quality of the match However, we do not know this apriori!
How do we select which sequences to align using banded DP?
![Page 43: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/43.jpg)
FASTA Overview
Main idea: Find potential diagonals & evaluate them
Suppose that we have a relatively long gap-less match
AGCGCCATGGATTGAGCGA
TGCGACATTGATCGACCTA Can we find “clues” that will let use find it quickly?
![Page 44: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/44.jpg)
Signature of a Match
Assumption: good matches contain several “patches” of perfect matches
AGCGCCATGGATTGAGCGA
TGCGACATTGATCGACCTA
Since this is a gap-less alignment, all perfect match regionsshould be on one diagonal
s
t
![Page 45: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/45.jpg)
FASTA
Given s and t, and a parameter k Find all pairs (i,j) such that s[i..i+k]=t[j..j+k] Locate sets of pairs that are on the same diagonal
By sorting according to i-j Compute score for the diagonal that contain all of
these pairs s
t
![Page 46: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/46.jpg)
FASTA
Postprocessing steps: Find highest scoring diagonal matches Combine these to potential gapped matches Run banded DP on the region containing these
combinations
Most applications of FASTA use very small k (2 for proteins, and 4-6 for DNA)
![Page 47: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/47.jpg)
BLAST Overview
BLAST uses similar intuition It relies on high scoring matches rather than exact
matches It is designed to find alignments of a target string s
against large databases
![Page 48: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/48.jpg)
High-Scoring Pair
Given parameters: length k, and thresholdT Two strings s and t of length k are a high scoring
pair (HSP) if d(s,t) > T
Given a query s[1..n], BLAST construct all words w, such that w is an HSP with a k-substring of s Note that not all substrings of s are HSPs!
These words serve as seeds for finding longer matches
![Page 49: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/49.jpg)
Finding Potential Matches
We can locate seed words in a large database in a single pass
Construct a FSA that recognizes seed words Using hashing techniques to locate matching words
![Page 50: Sequence Alignment](https://reader034.vdocuments.us/reader034/viewer/2022051019/56814e80550346895dbc1dc0/html5/thumbnails/50.jpg)
Extending Potential Matches
Once a seed is found, BLAST attempts to find a local alignment that extends the seed
Seeds on the same diagonalare combined (as in FASTA) s
t