动态规划法-双序列比对.ppt
1/55,回顾,Dynamic ProgrammingEdit Distance(编辑距离)Alignment(比对)Directed Acyclic GraphEdit GraphBacktracking,-T G C A T-A-C,A T-C-T G A T C,2/55,习题,4,求两条序列的最长共同子序列。【作业】,v=TACGGGTAT,w=GGACGTACG,3/55,G,G,A,C,G,T,A,C,G,T,A,C,G,G,G,T,A,T,4,Sequence Alignment,5/55,Outline,Global Alignment Scoring MatricesLocal AlignmentAlignment with Affine Gap Penalties,6/55,From LCS to Alignment:Change up the Scoring,The Longest Common Subsequence(LCS)problemthe simplest form of sequence alignment allows only insertions and deletions(no mismatches).In the LCS Problem,we scored 1 for matches and 0 for indelsConsider penalizing indels and mismatches with negative scoresSimplest scoring schema:+1:match premium-:mismatch penalty-:indel penalty,-T G C A T-A-C,A T-C-T G A T C,7/55,Simple Scoring,When mismatches are penalized by,indels are penalized by,and matches are rewarded with+1,the resulting score is:#matches(#mismatches)(#indels),8/55,The Global Alignment Problem,Find the best alignment between two strings under a given scoring schemaInput:Strings v and w and a scoring schemaOutput:Alignment of maximum score,m:mismatch penalty:indel penalty,9/55,Scoring Matrices,To generalize scoring,consider a(4+1)x(4+1)scoring matrix.In the case of an amino acid sequence alignment,the scoring matrix would be a(20+1)x(20+1)size.The addition of 1 is to include the score for comparison of a gap character“-”.This will simplify the algorithm as follows:,10/55,The Blosum62 Scoring Matrix,11/55,Measuring Similarity,Measuring the extent of similarity between two sequencesBased on percent sequence identityBased on conservation,12/55,Percent Sequence Identity,The extent to which two nucleotide or amino acid sequences are invariant,A C C T G A G A G A C G T G G C A G,70%identical,mismatch,indel,13/55,Making a Scoring Matrix,Scoring matrices are created based on biological evidence.Alignments can be thought of as two sequences that differ due to mutations.Some of these mutations have little effect on the proteins function,therefore some penalties,(vi,wj),will be less harsh than others.,14/55,Scoring Matrix:Example,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.,15/55,Conservation,Amino acid changes that tend to preserve the physico-chemical properties of the original residuePolar to polaraspartate glutamateNonpolar to nonpolaralanine valineSimilarly behaving residuesleucine to isoleucine,16/55,Scoring matrices,Amino acid substitution matricesPAMBLOSUMDNA substitution matricesDNA is less conserved than protein sequencesLess effective to compare coding regions at nucleotide level,17/55,PAM,Point Accepted Mutation(Dayhoff et al.)1 PAM=PAM1=1%average change of all amino acid positionsAfter 100 PAMs of evolution,not every residue will have changedsome residues may have mutated several timessome residues may have returned to their original statesome residues may not changed at all,18/55,PAMX,PAMx=PAM1xPAM250=PAM1250PAM250 is a widely used scoring matrix:,Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys.A R N D C Q E G H I L K.Ala A 13 6 9 9 5 8 9 12 6 8 6 7.Arg R 3 17 4 3 2 5 3 2 6 3 2 9Asn N 4 4 6 7 2 5 6 4 6 3 2 5Asp D 5 4 8 11 1 7 10 5 6 3 2 5Cys C 2 1 1 1 52 1 1 2 2 2 1 1Gln Q 3 5 5 6 1 10 7 3 7 2 3 5.Trp W 0 2 0 0 0 0 0 0 1 0 1 0Tyr Y 1 1 2 1 3 1 1 1 3 2 2 1Val V 7 4 4 4 4 4 4 4 5 4 15 10,19/55,BLOSUM,Blocks Substitution Matrix Scores derived from observations of the frequencies of substitutions in blocks of local alignments in related proteinsMatrix name indicates evolutionary distanceBLOSUM62 was created using sequences sharing no more than 62%identity,20/55,The Blosum62 Scoring Matrix,BLOSUM 62,21/55,相似度越低的序列,在比对的时候,采用PAM矩阵时,后面的数字越大,采用BLOSUM矩阵时,后面的数字越小。,22/55,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.,23/55,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 Alignmet may score higher than Global Alignment,24/55,Local vs.Global Alignment(contd),Global AlignmentLocal Alignmentbetter alignment to find conserved segment,-T-CC-C-AGT-TATGT-CAGGGGACACGA-GCATGCAGA-GAC,|,AATTGCCGCC-GTCGT-T-TTCAG-CA-GTTATGT-CAGAT-C,tccCAGTTATGTCAGgggacacgagcatgcagagac,|,aattgccgccgtcgttttcagCAGTTATGTCAGatc,25/55,Local Alignment:Example,Global alignment,Local alignment,26/55,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,27/55,The Local Alignment Problem,Goal:Find the best local alignment between two stringsInput: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,28/55,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,29/55,Local Alignment:Example,Global alignment,Local alignment,30/55,Local Alignment:Example,31/55,Local Alignment:Example,32/55,Local Alignment:Example,33/55,Local Alignment:Example,34/55,Local Alignment:Example,35/55,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,36/55,Local Alignment:Free Rides,Vertex(0,0),The dashed edges represent the free rides from(0,0)to every other node.,Yeah,a free ride!,37/55,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),38/55,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),39/55,NP_006735NP_000945,40/55,41/55,习题,考虑序列v=TACGGGTAT和w=GGACGTACG。假设匹配奖励+1,错配和插缺罚分均为-1.【作业】填写序列v和w之间的全局联配的动态规划表(编辑图或相似度矩阵)。在各单元画出箭头以存储返回信息。全局最优联配的得分是多少?这个得分对应的联配又是什么?填写序列v和w之间的局部联配的动态规划表。在各单元画出箭头以存储返回信息。在这种情形下,局部最优联配的得分是多少?这个得分对应的联配又是什么?,42/55,G,G,A,C,G,T,A,C,G,T,A,C,G,G,G,T,A,T,全局比对,43/55,局部比对,G,G,A,C,G,T,A,C,G,T,A,C,G,G,G,T,A,T,44/55,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,45/55,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_GCATATTGC,ATAG_GCAT_GTGC,Normal scoring would give the same score for both alignments,46/55,Accounting for Gaps,Gaps-contiguous sequence of spaces in one of the rowsScore 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.,47/55,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 nave scoring)are given to runs of horizontal and vertical edges,48/55,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*,49/55,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),50/55,Manhattan in 3 Layers,51/55,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.,52/55,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 edgesA 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),53/55,The 3-leveled Manhattan Grid,Gaps in w,Matches/Mismatches,Gaps in v,54/55,Affine Gap Penalty Recurrences,Continue Gap in w(deletion),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,55/55,习题,考虑序列v=TACGGGTAT和w=GGACGTACG。假设匹配奖励+1,错配和插缺罚分均为-1.填写序列v和w之间的全局联配的动态规划表(编辑图或相似度矩阵)。在各单元画出箭头以存储返回信息。全局最优联配的得分是多少?这个得分对应的联配又是什么?填写序列v和w之间的局部联配的动态规划表。在各单元画出箭头以存储返回信息。在这种情形下,局部最优联配的得分是多少?这个得分对应的联配又是什么?假设使用仿射缺口惩罚,其中引入缺口开放的罚分为-10,缺口扩展的罚分为-1。匹配和错配的得分不改变。在这种情形下,全局最优联配是什么?他的得分是多少?,