Presentation is loading. Please wait.

Presentation is loading. Please wait.

Pairwise alignments Introduction Introduction Why do alignments? Why do alignments? Definitions Definitions Scoring alignments Scoring alignments Alignment.

Similar presentations


Presentation on theme: "Pairwise alignments Introduction Introduction Why do alignments? Why do alignments? Definitions Definitions Scoring alignments Scoring alignments Alignment."— Presentation transcript:

1 Pairwise alignments Introduction Introduction Why do alignments? Why do alignments? Definitions Definitions Scoring alignments Scoring alignments Alignment methods Alignment methods Significance of alignments Significance of alignments

2 Definitions An alignment is a mutual arrangement of sequences, which exhibits where the sequences are similar, and where they differ. An optimal alignment is one that exhibits the most correspondences and the least differences. It is the alignment with the highest score. May or may not be biologically meaningful.

3 Why do alignments? Sequence Alignment is useful for discovering structural, functional and evolutional information in biological sequences.

4 How to measure the similarity Three kinds of changes can occur at any given position within a sequence: Mutation Mutation Insertion Insertion Deletion Deletion Insertion and deletion have been found to occur in nature at a significantly lower frequency than mutations. Insertion and deletion have been found to occur in nature at a significantly lower frequency than mutations. indel

5 v : A T G T T A T w : A T C G T A C m = 7 n = 7 AT--GTAT ATCG A C letters of v letters of w T T 5 matches2 insertions2 deletions Given 2 DNA sequences v and w: Alignment: 2 row representation ??? 4 matches 3 mismatchs

6 Aligning DNA Sequences V = ATCTGATG W = TGCATAC n = 8 m = 7 ATCTGATG TGCATAC V W match insertion deletion mismatch indels 4 1 2 3 matches mismatches insertions deletions

7 Scoring Matrices for Aligning DNA Sequences Transition --- substitutions in which a purine (A/G) is replaced by another purine (A/G) or a pyrimadine (C/T) is replaced by another pyrimadine (C/T). Transversions --- (A/G)  (C/T)

8 Scoring a Sequence Alignment Match score:+1 Match score:+1 Mismatch score:+0 Mismatch score:+0 Gap penalty:–1 Gap penalty:–1 ACGTCTGATACGCCGTATAGTCTATCT ||||| ||| || |||||||| ----CTGATTCGC---ATCGTCTATCT ACGTCTGATACGCCGTATAGTCTATCT ||||| ||| || |||||||| ----CTGATTCGC---ATCGTCTATCT Matches: 18 × (+1) Matches: 18 × (+1) Mismatches: 2 × 0 Mismatches: 2 × 0 Gaps: 7 × (– 1) Gaps: 7 × (– 1) Score = +11 ?

9 Aligning protein sequences FFDGGLQMQMLKDKFPMEGGQKDPKQRI

10 Amino Acid Substitution Matrices PAM - point accepted mutation based on global alignment [evolutionary model] BLOSUM - block substitutions based on local alignments [similarity among conserved sequences]

11 Part of PAM 250 Matrix CSTPAG C12 S02 T-213 P-3106 A-21112 G-31015 Log-odds = log ( ) chance to see pair in homologous proteins chance to see pair in unrelated proteins by chance

12 PAM 250 Matrix CSTPAGNDEQHRKMILVFYW C12 S02 T-213 P-3106 A-21112 G-31015 N-410002 D-5000124 E-50000134 Q-5001224 H-30-221136 R-400-2-30126 K-500-21001035 M-5-2-2-3-2-3-2-2006 I-20-2-3-2-2-2-2-2-2-225 L-6-3-2-3-2-4-3-4-3-2-2-3-3426 V-200-2-2-2-2-2-2-22424 F-4-3-3-5-4-5-4-6-5-5-2-4-50129 Y0-3-3-5-3-5-2-4-4-40-4-4-2-2710 W-8-2-5-6-6-7-4-7-7-5-32-3-4-5-2-60017

13 Scoring Matrix: Example ARNK A5-2 R-73 N--70 K---6 Notice that although R and K are different amino acids, they have a positive score. Why? They are both positively charged amino acids  will not greatly change function of protein. AKRANR KAAANK -1+(-1)+(-2) +5+7+3=11

14 Sequence Alignment Problem T C A T G C A T T G

15 Elements of Dynamic Programming Dynamic Programming method is used to solve optimization problems to which optimal solutions depend on the optimal solutions to the subproblems. It involves Dynamic Programming method is used to solve optimization problems to which optimal solutions depend on the optimal solutions to the subproblems. It involves Characterize the structure of the optimal solutions Characterize the structure of the optimal solutions Recursively define the score of an optimal solution in terms of the scores of optimal solutions of sub-problems Recursively define the score of an optimal solution in terms of the scores of optimal solutions of sub-problems Compute the solution in a bottom-up fashion Compute the solution in a bottom-up fashion Trace back the optimal solution Trace back the optimal solution

16 Dynamic Programming Consider two sequences: AAAT AGC AGC To find the optimal solution, if T is aligned with C, we have to find the best alignment between AAA and AG.  Best solution depends on the best solutions of the subproblems.

17 Dynamic Programming Consider two sequences: AAAT AGC AGC To find the optimal solution, we have to find the best alignment between AAA and AG, AAA and AGC or AAAT and AG.  Best solution depends on the best solutions of the subproblems.

18 Dynamic Programming Optimal solutions for the subproblems have to be solved recursively. Let n be the size of sequence s = AAAT, m be the size of sequence t = AGC. m be the size of sequence t = AGC. Consider subproblems: matching the prefixes of s and t. t has ? possible prefixes, including empty string s has ? possible prefixes, including empty string n+1 m+1

19 Dynamic Programming We would like to match s[1…i] and t[1…j]: Align s[1…i] with t[1…j-1] and match a space with t[j] Align s[1…i] with t[1…j-1] and match a space with t[j] Align s[1…i-1] with t[1…j-1] and match s[i] with t[j] Align s[1…i-1] with t[1…j-1] and match s[i] with t[j] Align s[1…i-1] with t[1…j] and match a space with s[i] Align s[1…i-1] with t[1…j] and match a space with s[i] Similarity between s and t: Score(s[1…i],t[1…j])=max  Score(s[1…i],t[1…j-1])+gap penalty Score(s[1…i-1],t[1…j-1])+score(s[i],s[j]) Score(s[1…i-1],t[1…j])+gap penalty

20 Definitions Global alignment - Needleman-Wunsch (1970) maximizes the number of matches between the sequences along the entire length of the sequences. Local alignment - Smith-Waterman (1981) is a modification of the dynamic programming algorithm gives the highest scoring local match between two sequences.

21 Example Let gap = -2 Let gap = -2 match = 1 mismatch = -1. C A A Aempty C G A empty 1 -1 -1 -3 -3 -5 -5 -1 -1 0 -3 -3 -4 -4 -1 -1 -2 -2 -8 -8 -6 -6 -4 -4 -2 -2 -6 -6 -4 -4 -2 -2 0AAACA-GC Complexity : O(mn) ?

22 Gap Penalty Scoring Indels: Naive Approach A fixed penalty σ is given to every indel: A fixed penalty σ is given to every indel: -σ for 1 indel, -σ for 1 indel, -2σ for 2 consecutive indels -2σ for 2 consecutive indels -3σ for 3 consecutive indels, etc. -3σ for 3 consecutive indels, etc. Can be too severe penalty for a series of 100 consecutive indels

23 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: In nature, a series of k indels often come as a single event rather than a series of k single nucleotide events: Normal scoring would give the same score for both alignments This is more likely. This is less likely.

24 Gap Penalty Gap opening penalty defines the cost for opening a gap in one of the sequences. The penalty must be tuned based on the default matrix. Gap extension penalty is an extra penalty proportional to the length of the gap. The gap extension penalty is always lower than gap opening penalty. Optimal penalties vary from sequence to sequence, and finding the most adequate value is a matter of empirical trial and error.

25 Accounting for Gaps Gaps- contiguous sequence of spaces in one of the rows Gaps- contiguous sequence of spaces in one of the rows Score for a gap of length x is: Score for a gap of length x is: -(ρ + σx) -(ρ + σx) where x length of the gap, ρ >0 is the penalty for introducing a gap: where x length of the gap, ρ >0 is the penalty for introducing a gap: gap opening penalty gap opening penalty ρ will be large relative to σ: ρ will be large relative to σ: gap extension penalty gap extension penalty because you do not want to add too much of a penalty for extending the gap. because you do not want to add too much of a penalty for extending the gap.

26 Affine Gap Penalties Gap penalties: Gap penalties: -ρ-σ when there is 1 indel -ρ-σ when there is 1 indel -ρ-2σ when there are 2 indels -ρ-2σ when there are 2 indels -ρ-3σ when there are 3 indels, etc. -ρ-3σ when there are 3 indels, etc. -ρ- x · σ (-gap opening - x gap extensions) -ρ- x · σ (-gap opening - x gap extensions) Somehow reduced penalties (as compared to na ï ve scoring) are given to runs of horizontal and vertical edges Somehow reduced penalties (as compared to na ï ve scoring) are given to runs of horizontal and vertical edges

27 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 * 

28 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 length of the sequence) So the complexity increases from O(n 2 ) to O(n 3 ) from O(n 2 ) to O(n 3 ) Adding “Affine Penalty” Edges to the Edit Graph

29 Optimal alignment Optimal alignment - one that exhibits the most correspondences. It is the alignment with the highest score. May or may not be biologically meaningful. Global alignment - Needleman-Wunsch (1970) maximizes the number of matches between the sequences along the entire length of the sequences. Local alignment - Smith-Waterman (1981) gives the highest scoring local match between two sequences.

30 Local Alignment Problem first formulated: Problem first formulated: Smith and Waterman (1981) Smith and Waterman (1981) Problem: Problem: Find an optimal alignment between a substring of s and a substring of t Find an optimal alignment between a substring of s and a substring of t Algorithm: Algorithm: is a variant of the basic algorithm for global alignment is a variant of the basic algorithm for global alignment

31 Motivation Searching for unknown domains or motifs within proteins from different families Searching for unknown domains or motifs within proteins from different families Proteins encoded from Homeobox genes (only conserved in 1 region called Homeo domain – 60 amino acids long) Proteins encoded from Homeobox genes (only conserved in 1 region called Homeo domain – 60 amino acids long) Identifying active sites of enzymes Identifying active sites of enzymes Comparing long stretches of anonymous DNA Comparing long stretches of anonymous DNA Querying databases where query word much smaller than sequences in database Querying databases where query word much smaller than sequences in database Analyzing repeated elements within a single sequence Analyzing repeated elements within a single sequence

32 Local Alignment Let n be the size of sequence s = GATCACCT m be the size of sequence t = GATACCC. m be the size of sequence t = GATACCC. Consider subproblems: matching the suffixes of s and t. t has ? possible suffixes, including empty string s has ? possible suffixes, including empty string n+1 m+1

33 DP for Local Alignment Match the suffixes of s[1…i] and t[1…j]: Match the suffixes of s[1…i] and t[1…j]: Align suffixes of s[1…i] with t[1…j-1] & match a space with t[j] Align suffixes of s[1…i] with t[1…j-1] & match a space with t[j] Align suffixes of s[1…i-1] with t[1…j-1] & match s[i] with t[j] Align suffixes of s[1…i-1] with t[1…j-1] & match s[i] with t[j] Align suffixes of s[1…i-1] with t[1…j] & match a space with s[i] Align suffixes of s[1…i-1] with t[1…j] & match a space with s[i] Score(s[1…i],t[1…j])=max Score(s[1…i],t[1…j-1])+gap penalty Score(s[1…i-1],t[1…j-1])+score(s[i],s[j]) Score(s[1…i-1],t[1…j])+gap penalty 0 S ij – highest score for alignment between 2 prefixes ending at i and j

34 Local Alignment Let gap = -2 Let gap = -2 match = 1 mismatch = -1. GATCACCTGATACCC 000000000 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0000 1 0 2 1 1 0 0 0 0 0 3 2 2 0 0 0 0 1 4 3 0 0 1 0 0 2 3 2 0 1 0 0 0 0 3 1 0 0 0 0 1 2 2 1 1 GATCACCTGAT_ACCC

35 Local Alignment Let gap = -2 Let gap = -2 match = 1 mismatch = -1. GATCACCTGATACCC 000000000 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0000 1 0 2 1 1 0 0 0 0 0 3 2 2 0 0 0 0 1 4 3 0 0 1 0 0 2 3 2 0 1 0 0 0 0 3 1 0 0 0 0 1 2 2 1 1 GATCACCTGAT_ACCC

36 Local Alignment Let gap = -2 Let gap = -2 match = 1 mismatch = -1. ACACACTA AGCACAC -ACACACTA -000000000 A010101001 G000000000 C001010100 A010202001 C002030310 A010314202 C001042531 A010125344

37 Smith & Waterman Place each sequence along one axis Place score 0 at the up-left corner Fill in 1 st row & column with 0s Fill in the matrix with max value of 4 possible values: 0 Vertical move: Score + gap penalty Horizontal move: Score + gap penalty Diagonal move: Score + match/mismatch score The optimal alignment score is the max in the matrix To reconstruct the optimal alignment, trace back where the MAX at each step came from, stop when a zero is hit

38 Semi-global Alignment Example:CAGCA-CTTGGATTCTCGG–––CAGCGTGG––––––––CAGCACTTGGATTCTCGGCAGC––––G––T––––GG We like the first alignment much better. In semiglobal comparison, we score the alignments ignoring some of the end spaces.

39 Global Alignment Example:AAACCC A - - CCC Prefer to see: AAACCC AAACCC - - ACCC - - ACCC Do not want to penalize the end spaces emptyAAACCC empty0-2-4-6-8-10-12 A-21-3-5-7-9 C-40-2-2-4-6 C-6-3-2-3 C-8-5-4-3000

40 SemiGlobal Alignment Example: s = AAACCC t = - - ACCC t = - - ACCC emptyAAACCC empty0000000 A-2111 C-400200 C-6-3-2131 C-8-5-4-3024

41 SemiGlobal Alignment Example: s = AAACCCG t = - - ACCC - t = - - ACCC - emptyAAACCC empty0000000 A-2111 C-400200 C-6-3-2131 C-8-5-4-3024 2 -2 0 G

42 SemiGlobal Alignment Summary of end space charging procedures: Summary of end space charging procedures: Place where spaces are not penalized for Action Beginning of 2 nd sequence End of 1 st sequence Beginning of 1 st sequence End of 2 nd sequence Initialize 1 st row with zeros Look for max in last row Initialize 1 st column with zeros Look for max in last column

43 Global vs Local Demo

44 R R: http://www.r-project.org/ R: http://www.r-project.org/http://www.r-project.org/ R IDE: http://rstudio.org/ R IDE: http://rstudio.org/http://rstudio.org/ R manual: http://cran.r-project.org/doc/manuals/R-intro.pdf R manual: http://cran.r-project.org/doc/manuals/R-intro.pdf http://cran.r-project.org/doc/manuals/R-intro.pdf R & IDE downloads: R & IDE downloads: http://cran.case.edu/ http://cran.case.edu/ http://cran.case.edu/ http://rstudio.org/download/ http://rstudio.org/download/ http://rstudio.org/download/ Quick R: http://www.statmethods.net/ Quick R: http://www.statmethods.net/http://www.statmethods.net/

45 R Demo Bioconductor Bioconductor http://www.bioconductor.org/install/ http://www.bioconductor.org/install/ http://www.bioconductor.org/install/ source("http://bioconductor.org/biocLite.R") source("http://bioconductor.org/biocLite.R") biocLite() biocLite() library(Biostrings) #load library pairwiseAlignment(pattern = c("succeed", "precede"), subject = "supersede") ?pairwiseAlignment


Download ppt "Pairwise alignments Introduction Introduction Why do alignments? Why do alignments? Definitions Definitions Scoring alignments Scoring alignments Alignment."

Similar presentations


Ads by Google