750 likes | 765 Views
Understand the differences between local and global alignment problems in bioinformatics, their applications, and algorithms. Learn to compute optimal alignments and scoring matrices for gene sequences.
E N D
CSE 5290:Algorithms for Bioinformatics Fall 2009 Suprakash Datta datta@cs.yorku.ca Office: CSEB 3043 Phone: 416-736-2100 ext 77875 Course page: http://www.cs.yorku.ca/course/5290 CSE 5290, Fall 2009
Next Local and global sequencealignment Some of the following slides are based on slides by the authors of our text. CSE 5290, Fall 2009
Local vs. Global Alignment • The Global Alignment Problem tries to find the longest path between vertices (0,0) and (n,m) in the edit graph. • The Local Alignment Problem tries to find the longest path among paths between arbitrary vertices (i,j) and (i’, j’) in the edit graph. CSE 5290, Fall 2009
Local vs. Global Alignment • The Global Alignment Problem tries to find the longest path between vertices (0,0) and (n,m) in the edit graph. • The Local Alignment Problem tries to find the longest path among paths between arbitrary vertices (i,j) and (i’, j’) in the edit graph. • In the edit graph with negatively-scored edges, Local Alignment may score higher than Global Alignment CSE 5290, Fall 2009
Local vs. Global Alignment (cont’d) • Global Alignment • Local Alignment—better alignment to find conserved segment --T—-CC-C-AGT—-TATGT-CAGGGGACACG—A-GCATGCAGA-GAC | || | || | | | ||| || | | | | |||| | AATTGCCGCC-GTCGT-T-TTCAG----CA-GTTATG—T-CAGAT--C tccCAGTTATGTCAGgggacacgagcatgcagagac |||||||||||| aattgccgccgtcgttttcagCAGTTATGTCAGatc CSE 5290, Fall 2009
Compute a “mini” Global Alignment to get Local Local Alignment: Example Local alignment Global alignment CSE 5290, Fall 2009
Local Alignments: Why? • Two genes in different species may be similar over short conserved regions and dissimilar over remaining regions. • Example: • Homeobox genes have a short region called the homeodomain that is highly conserved between species. • A global alignment would not find the homeodomain because it would try to align the ENTIRE sequence CSE 5290, Fall 2009
The Local Alignment Problem • Goal: Find the best local alignment between two strings • Input : Strings v, w and scoring matrix δ • Output : Alignment of substrings of v and w whose alignment score is maximum among all possible alignment of all possible substrings CSE 5290, Fall 2009
The Problem with this Problem • Long run time O(n4): - In the grid of size n x n there are ~n2 vertices (i,j) that may serve as a source. - For each such vertex computing alignments from (i,j) to (i’,j’) takes O(n2) time. • This can be remedied by giving free rides CSE 5290, Fall 2009
Compute a “mini” Global Alignment to get Local Local Alignment: Example Local alignment Global alignment CSE 5290, Fall 2009
Local Alignment: Example CSE 5290, Fall 2009
Local Alignment: Example CSE 5290, Fall 2009
Local Alignment: Example CSE 5290, Fall 2009
Local Alignment: Example CSE 5290, Fall 2009
Local Alignment: Example CSE 5290, Fall 2009
Local Alignment: Running Time • Long run time O(n4): - In the grid of size n x n there are ~n2 vertices (i,j) that may serve as a source. - For each such vertex computing alignments from (i,j) to (i’,j’) takes O(n2) time. • This can be remedied by giving free rides CSE 5290, Fall 2009
Local Alignment: Free Rides Yeah, a free ride! Vertex (0,0) The dashed edges represent the free rides from (0,0) to every other node. CSE 5290, Fall 2009
Notice there is only this change from the original recurrence of a Global Alignment The Local Alignment Recurrence • The largest value of si,j over the whole edit graph is the score of the best local alignment. • The recurrence: 0 si,j = max si-1,j-1 + δ(vi, wj) s i-1,j + δ(vi, -) s i,j-1 + δ(-, wj) { CSE 5290, Fall 2009
Power of ZERO: there is only this change from the original recurrence of a Global Alignment - since there is only one “free ride” edge entering into every vertex The Local Alignment Recurrence • The largest value of si,j over the whole edit graph is the score of the best local alignment. • The recurrence: 0 si,j = max si-1,j-1 + δ(vi, wj) s i-1,j + δ(vi, -) s i,j-1 + δ(-, wj) { CSE 5290, Fall 2009
Scoring Indels: Naive Approach • A fixed penalty σis given to every indel: • -σ for 1 indel, • -2σ for 2 consecutive indels • -3σ for 3 consecutive indels, etc. Can be too severe penalty for a series of 100 consecutive indels CSE 5290, Fall 2009
This is more likely. This is less likely. Affine Gap Penalties • In nature, a series of k indels often come as a single event rather than a series of k single nucleotide events: ATA__GC ATATTGC ATAG_GC AT_GTGC Normal scoring would give the same score for both alignments CSE 5290, Fall 2009
Accounting for Gaps • Gaps- contiguous sequence of spaces in one of the rows • Score for a gap of length x is: -(ρ +σx) where ρ >0 is the penalty for introducing a gap: gap opening penalty ρ will be large relative to σ: gap extension penalty because you do not want to add too much of a penalty for extending the gap. CSE 5290, Fall 2009
Affine Gap Penalties • Gap penalties: • -ρ-σ when there is 1 indel • -ρ-2σ when there are 2 indels • -ρ-3σ when there are 3 indels, etc. • -ρ- x·σ (-gap opening - x gap extensions) • Somehow reduced penalties (as compared to naïve scoring) are given to runs of horizontal and vertical edges CSE 5290, Fall 2009
Affine Gap Penalties and Edit Graph To reflect affine gap penalties we have to add “long” horizontal and vertical edges to the edit graph. Each such edge of length x should have weight - - x * CSE 5290, Fall 2009
Adding “Affine Penalty” Edges to the Edit Graph There are many such edges! Adding them to the graph increases the running time of the alignment algorithm by a factor of n (where n is the number of vertices) So the complexity increases from O(n2) to O(n3) CSE 5290, Fall 2009
Manhattan in 3 Layers ρ δ δ σ δ ρ δ δ σ CSE 5290, Fall 2009
Affine Gap Penalties and 3 Layer Manhattan Grid • The three recurrences for the scoring algorithm creates a 3-layered graph. • The top level creates/extends gaps in the sequence w. • The bottom level creates/extends gaps in sequence v. • The middle level extends matches and mismatches. CSE 5290, Fall 2009
Switching between 3 Layers • Levels: • The main level is for diagonal edges • The lower level is for horizontal edges • The upper level is for vertical edges • A jumping penalty is assigned to moving from the main level to either the upper level or the lower level (-r- s) • There is a gap extension penalty for each continuation on a level other than the main level (-s) CSE 5290, Fall 2009
The 3-leveled Manhattan Grid Gaps in w Matches/Mismatches Gaps in v CSE 5290, Fall 2009
Affine Gap Penalty Recurrences Continue Gap in w (deletion) si,j = s i-1,j - σ max s i-1,j –(ρ+σ) si,j = s i,j-1 - σ max s i,j-1 –(ρ+σ) si,j = si-1,j-1 + δ(vi, wj) max s i,j s i,j Start Gap in w (deletion): from middle Continue Gap in v (insertion) Start Gap in v (insertion):from middle Match or Mismatch End deletion: from top End insertion: from bottom CSE 5290, Fall 2009
Next • Multiple Alignments CSE 5290, Fall 2009
Multiple Alignment versus Pairwise Alignment • Up until now we have only tried to align two sequences. CSE 5290, Fall 2009
Multiple Alignment versus Pairwise Alignment • Up until now we have only tried to align two sequences. • What about more than two? And what for? CSE 5290, Fall 2009
Multiple Alignment versus Pairwise Alignment • Up until now we have only tried to align two sequences. • What about more than two? And what for? • A faint similarity between two sequences becomes significant if present in many • Multiple alignments can reveal subtle similarities that pairwise alignments do not reveal CSE 5290, Fall 2009
Generalizing the Notion of Pairwise Alignment • Alignment of 2 sequences is represented as a 2-row matrix • In a similar way, we represent alignment of 3 sequences as a 3-row matrix A T _ G C G _ A _ C G T _ A A T C A C _ A • Score: more conserved columns, better alignment CSE 5290, Fall 2009
Alignments = Paths in… • Align 3 sequences: ATGC, AATC,ATGC CSE 5290, Fall 2009
Alignment Paths x coordinate CSE 5290, Fall 2009
Alignment Paths • Align the following 3 sequences: ATGC, AATC,ATGC x coordinate y coordinate CSE 5290, Fall 2009
Alignment Paths x coordinate y coordinate z coordinate • Resulting path in (x,y,z) space: • (0,0,0)(1,1,0)(1,2,1) (2,3,2) (3,3,3) (4,4,4) CSE 5290, Fall 2009
Aligning Three Sequences source • Same strategy as aligning two sequences • Use a 3-D “Manhattan Cube”, with each axis representing a sequence to align • For global alignments, go from source to sink sink CSE 5290, Fall 2009
2-D vs 3-D Alignment Grid V W 2-D edit graph 3-D edit graph CSE 5290, Fall 2009
2-D cell versus 2-D Alignment Cell In 2-D, 3 edges in each unit square In 3-D, 7 edges in each unit cube CSE 5290, Fall 2009
Architecture of 3-D Alignment Cell (i-1,j,k-1) (i-1,j-1,k-1) (i-1,j,k) (i-1,j-1,k) (i,j,k-1) (i,j-1,k-1) (i,j,k) (i,j-1,k) CSE 5290, Fall 2009
si-1,j-1,k-1 + (vi, wj, uk) si-1,j-1,k + (vi, wj, _ ) si-1,j,k-1 + (vi, _, uk) si,j-1,k-1 + (_, wj, uk) si-1,j,k + (vi, _ , _) si,j-1,k + (_, wj, _) si,j,k-1 + (_, _, uk) Multiple Alignment: Dynamic Programming cube diagonal: no indels • si,j,k = max • (x, y, z) is an entry in the 3-D scoring matrix face diagonal: one indel edge diagonal: two indels CSE 5290, Fall 2009
Multiple Alignment: Running Time • For 3 sequences of length n, the run time is 7n3; O(n3) • For ksequences, build a k-dimensional Manhattan, with run time (2k-1)(nk); O(2knk) • Conclusion: dynamic programming approach for alignment between two sequences is easily extended to k sequences but it is impractical due to exponential running time CSE 5290, Fall 2009
Multiple Alignment Induces Pairwise Alignments Every multiple alignment induces pairwise alignments x: AC-GCGG-C y: AC-GC-GAG z: GCCGC-GAG Induces: x: ACGCGG-C; x: AC-GCGG-C; y: AC-GCGAG y: ACGC-GAC; z: GCCGC-GAG; z: GCCGCGAG CSE 5290, Fall 2009
Reverse Problem: Constructing Multiple Alignment from Pairwise Alignments Given 3 arbitrary pairwise alignments: x: ACGCTGG-C; x: AC-GCTGG-C; y: AC-GC-GAG y: ACGC--GAC; z: GCCGCA-GAG; z: GCCGCAGAG Q: can we construct a multiple alignment that induces them? A: NOT ALWAYS Pairwise alignments may be inconsistent CSE 5290, Fall 2009
Inferring Multiple Alignment from Pairwise Alignments • From an optimal multiple alignment, we can infer pairwise alignments between all pairs of sequences, but they are not necessarily optimal • It is difficult to infer a ``good” multiple alignment from optimal pairwise alignments between all sequences CSE 5290, Fall 2009
Combining Optimal Pairwise Alignments into Multiple Alignment Can combine pairwise alignments into multiple alignment Can not combine pairwise alignments into multiple alignment CSE 5290, Fall 2009
Profile Representation of Multiple Alignment In the past we were aligning a sequence against a sequence Can we align a sequence against a profile? Can we align a profile against a profile? - A G G C T A T C A C C T G T A G – C T A C C A - - - G C A G – C T A C C A - - - G C A G – C T A T C A C – G G C A G – C T A T C G C – G G A 1 1 .8 C .6 1 .4 1 .6 .2 G 1 .2 .2 .4 1 T .2 1 .6 .2 - .2 .8 .4 .8 .4 CSE 5290, Fall 2009