CENTER FOR BIOLOGICAL SEQUENCE ANALYSIS Distance Matrix Methods Anders Gorm Pedersen Molecular...
-
date post
22-Dec-2015 -
Category
Documents
-
view
222 -
download
2
Transcript of CENTER FOR BIOLOGICAL SEQUENCE ANALYSIS Distance Matrix Methods Anders Gorm Pedersen Molecular...
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Distance Matrix Methods
Anders Gorm PedersenAnders Gorm Pedersen
Molecular Evolution GroupMolecular Evolution Group
Center for Biological Sequence AnalysisCenter for Biological Sequence Analysis
Technical University of DenmarkTechnical University of Denmark
[email protected]@cbs.dtu.dk
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Distance Matrix Methods
1.1. Construct multiple alignment of Construct multiple alignment of sequencessequences
2.2. Construct table listing all pairwise Construct table listing all pairwise differences (distance matrix)differences (distance matrix)
3.3. Construct tree from pairwise distancesConstruct tree from pairwise distances
Gorilla : ACGTCGTAHuman : ACGTTCCTChimpanzee: ACGTTTCG
Go Hu Ch
Go - 4 4
Hu - 2
Ch -
Go
Hu
Ch
2
11
1
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Finding optimal branch lengths
S1 S2 S3 S4
S1 - D12 D13 D14
S2 - D23 D24
S3 - D34
S4 -Observed distance
S1
S3
S2
S4
a
b
c
d e
Distance along tree(patristic distance)
D12 ≈ d12 = a + b + cD13 ≈ d13 = a + dD14 ≈ d14 = a + b + eD23 ≈ d23 = d + b + cD24 ≈ d24 = c + eD34 ≈ d34 = d + b + e
Goal:
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Exercise (handout)
• Construct distance matrix (count different positions)Construct distance matrix (count different positions)
• Reconstruct tree and find best set of branch lengthsReconstruct tree and find best set of branch lengths
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Optimal Branch Lengths for a Given Tree: Least Squares
• Fit between given tree and Fit between given tree and observed distances can be observed distances can be expressed as “sum of squared expressed as “sum of squared differences”:differences”:
Q = Q = ΣΣ(D(Dijij - d - dijij))22
• Find branch lengths that minimize Find branch lengths that minimize Q - this is the optimal set of branch Q - this is the optimal set of branch lengths for this tree.lengths for this tree.
S1
S3
S2
S4
a
b
c
d e
Distance along tree
D12 ≈ d12 = a + b + cD13 ≈ d13 = a + dD14 ≈ d14 = a + b + eD23 ≈ d23 = d + b + cD24 ≈ d24 = c + eD34 ≈ d34 = d + b + e
Goal:
j>i
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Optimal Branch Lengths: Least Squares
• Longer distances associated with Longer distances associated with larger errorslarger errors
• Squared deviation may be weighted Squared deviation may be weighted so longer branches contribute less so longer branches contribute less to Q:to Q:
Q = Q = ΣΣ(D(Dijij - d - dijij))22
• Power (n) is typically 1 or 2
S1
S3
S2
S4
a
b
c
d e
Distance along tree
D12 ≈ d12 = a + b + cD13 ≈ d13 = a + dD14 ≈ d14 = a + b + eD23 ≈ d23 = d + b + cD24 ≈ d24 = c + eD34 ≈ d34 = d + b + e
Goal:
Dijn
j>i
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Finding Optimal Branch Lengths
A B C
A - DAB DAC
B - DBC
C -Observed distance
A
B
C
v1
v3
v2
Distance along tree
DAB ≈ dAB = v1 + v2
DAC ≈ dAC = v1 + v3
DBC ≈ dBC = v2 + v3
Goal:
€
Q = DAB − dAB( )2+ DAC − dAC( )
2+ DBC − dBC( )
2
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Finding Optimal Branch Lengths€
Q = DAB − dAB( )2+ DAC − dAC( )
2+ DBC − dBC( )
2
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
€
Q = DAB − dAB( )2+ DAC − dAC( )
2+ DBC − dBC( )
2
c
Q = DAB2 + dAB
2 −2DABdAB
+DAC2 + dAC
2 −2DACdAC
+DBC2 + dBC
2 −2DBCdBC
Finding Optimal Branch Lengths
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Finding Optimal Branch Lengths
€
Q = DAB − dAB( )2+ DAC − dAC( )
2+ DBC − dBC( )
2
c
Q = DAB2 + dAB
2 −2DABdAB
+DAC2 + dAC
2 −2DACdAC
+DBC2 + dBC
2 −2DBCdBCc
Q = DAB2 + v1 + v2( )
2−2DAB v1 + v2( )
+DAC2 + v1 + v3( )
2−2DAC v1 + v3( )
+DBC2 + v2 + v3( )
2−2DBC v2 + v3( )
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Finding Optimal Branch Lengths
€
Q = DAB − dAB( )2+ DAC − dAC( )
2+ DBC − dBC( )
2
c
Q = DAB2 + dAB
2 −2DABdAB
+DAC2 + dAC
2 −2DACdAC
+DBC2 + dBC
2 −2DBCdBCc
Q = DAB2 + v1 + v2( )
2−2DAB v1 + v2( )
+DAC2 + v1 + v3( )
2−2DAC v1 + v3( )
+DBC2 + v2 + v3( )
2−2DBC v2 + v3( )
c
Q = DAB2 + v1
2 + v22 + 2v1v2 −2DABv1 −2DABv2
+DAC2 + v1
2 + v32 + 2v1v3 −2DACv1 −2DACv3
+DBC2 + v2
2 + v32 + 2v2v3 −2DBCv21 −2DBCv3
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Finding Optimal Branch Lengths
€
Q = DAB2 + v1
2 + v22 + 2v1v2 −2DABv1 −2DABv2
+DAC2 + v1
2 + v32 + 2v1v3 −2DACv1 −2DACv3
+DBC2 + v2
2 + v32 + 2v2v3 −2DBCv21 −2DBCv3
c
Q = 2v12
+ 2v2 + 2v3 −2DAB −2DAC( )v1
+2v22 + 2v3
2 + 2v2v3 −2DABv2 −2DACv3 −2DBCv2 −2DBCv3 + DAB2 + DAC
2 + DBC2
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Finding Optimal Branch Lengths
€
Q = DAB2 + v1
2 + v22 + 2v1v2 −2DABv1 −2DABv2
+DAC2 + v1
2 + v32 + 2v1v3 −2DACv1 −2DACv3
+DBC2 + v2
2 + v32 + 2v2v3 −2DBCv21 −2DBCv3
c
Q = 2v12
+ 2v2 + 2v3 −2DAB −2DAC( )v1
+2v22 + 2v3
2 + 2v2v3 −2DABv2 −2DACv3 −2DBCv2 −2DBCv3 + DAB2 + DAC
2 + DBC2
c
Q = 2v12 +C1v1 +C2
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Finding Optimal Branch Lengths
€
Q = 2v12 +C1v1 +C2
min :dQ
dv1= 0
dQ
dv1= 4v1 +C1 = 4v1 + 2v2 + 2v3 −2DAB −2DAC
⇓
4v1 + 2v2 + 2v3 −2DAB −2DAC = 0
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Finding Optimal Branch Lengths
• System of n linear equations with n unknowns
• Can be solved using substitution method or matrix-based methods
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Least Squares Optimality Criterion
• Search through all (or many) tree topologiesSearch through all (or many) tree topologies
• For each investigated tree, find best branch lengths using least For each investigated tree, find best branch lengths using least squares criterion (solve N equations with N unknowns)squares criterion (solve N equations with N unknowns)
• Among all investigated trees, the best tree is the one with the smallest Among all investigated trees, the best tree is the one with the smallest sum of squared errors. sum of squared errors.
• Least squares criterion used both for finding branch lengths on Least squares criterion used both for finding branch lengths on individual trees, and for finding best tree.individual trees, and for finding best tree.
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Minimum Evolution Optimality Criterion
• Search through all (or many) tree topologiesSearch through all (or many) tree topologies
• For each investigated tree, find best branch lengths using least For each investigated tree, find best branch lengths using least squares criterion (solve N equations with N unknowns)squares criterion (solve N equations with N unknowns)
• Among all investigated trees, the best tree is the one with the smallest Among all investigated trees, the best tree is the one with the smallest sum of branch lengths (the shortest tree).sum of branch lengths (the shortest tree).
• Least squares criterion used for finding branch lengths on individual Least squares criterion used for finding branch lengths on individual trees, minimum tree length used for finding best tree.trees, minimum tree length used for finding best tree.
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Superimposed Substitutions
• Actual number of Actual number of
evolutionary events:evolutionary events: 55
• Observed number of Observed number of
differences:differences: 22
• Distance is (almost) always Distance is (almost) always underestimatedunderestimated
ACGGTGC
C T
GCGGTGA
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Model-based correction for superimposed substitutions
• Goal: try to infer the real number of evolutionary events (the real Goal: try to infer the real number of evolutionary events (the real distance) based ondistance) based on
1.1. Observed data (sequence alignment)Observed data (sequence alignment)
2.2. A model of how evolution occursA model of how evolution occurs
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Jukes and Cantor Model
• Four nucleotides assumed to be Four nucleotides assumed to be equally frequent (f=0.25)equally frequent (f=0.25)
• All 12 substitution rates assumed to All 12 substitution rates assumed to be equalbe equal
• Under this model the corrected Under this model the corrected distance is:distance is:
DDJCJC = -0.75 x ln(1-1.33 x D = -0.75 x ln(1-1.33 x DOBSOBS))
• For instance:For instance:
DDOBSOBS=0.43 => D=0.43 => DJCJC=0.64=0.64
A C G T
A -3α α α α
C α -3α α α
G α α -3α α
T α α α -3α
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Clustering Algorithms
• Starting point: Distance matrixStarting point: Distance matrix
• Cluster the two nearest nodes:Cluster the two nearest nodes:– Tree: connect pair of nodes to common ancestral node, compute branch lengths from ancestral Tree: connect pair of nodes to common ancestral node, compute branch lengths from ancestral
node to both descendantsnode to both descendants
– Distance matrix: replace the two joined nodes with the new (ancestral) node. Compute new distance Distance matrix: replace the two joined nodes with the new (ancestral) node. Compute new distance matrix, by finding distance from new node to all other nodesmatrix, by finding distance from new node to all other nodes
• Repeat until all nodes are linked in treeRepeat until all nodes are linked in tree
• Results in only one tree, there is no measure of tree-goodness.Results in only one tree, there is no measure of tree-goodness.
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
• For each tip compute For each tip compute uuii = = ΣΣjj DDijij/(n-2)/(n-2)
(essentially the average distance to all other tips, except the denominator is n-2 instead of n-1)(essentially the average distance to all other tips, except the denominator is n-2 instead of n-1)
• Find the pair of tips, i and j, where Find the pair of tips, i and j, where DDijij-u-uii-u-ujj is smallest is smallest
• Connect the tips i and j, forming a new ancestral node. The branch lengths from the ancestral node Connect the tips i and j, forming a new ancestral node. The branch lengths from the ancestral node to i and j are:to i and j are:
vvii = 0.5 D = 0.5 Dijij + 0.5 (u + 0.5 (uii-u-ujj))
vvjj = 0.5 D = 0.5 Dijij + 0.5 (u + 0.5 (ujj-u-uii))
• Update the distance matrix: Compute distance between new node and each remaining tip as Update the distance matrix: Compute distance between new node and each remaining tip as follows:follows:
DDij,kij,k = (D = (Dikik+D+Djkjk-D-Dijij)/2)/2
• Replace tips i and j by the new node which is now treated as a tipReplace tips i and j by the new node which is now treated as a tip
• Repeat until only two nodes remain.Repeat until only two nodes remain.
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B C D
A - 17 21 27
B - 12 18
C - 14
D -
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B C D
A - 17 21 27
B - 12 18
C - 14
D -
i ui
A (17+21+27)/2=32.5
B (17+12+18)/2=23.5
C (21+12+14)/2=23.5
D (27+18+14)/2=29.5
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B C D
A - 17 21 27
B - 12 18
C - 14
D -
i ui
A (17+21+27)/2=32.5
B (17+12+18)/2=23.5
C (21+12+14)/2=23.5
D (27+18+14)/2=29.5
A B C D
A - -39 -35 -35
B - -35 -35
C - -39
D -
Dij-ui-uj
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B C D
A - 17 21 27
B - 12 18
C - 14
D -
i ui
A (17+21+27)/2=32.5
B (17+12+18)/2=23.5
C (21+12+14)/2=23.5
D (27+18+14)/2=29.5
A B C D
A - -39 -35 -35
B - -35 -35
C - -39
D -
Dij-ui-uj
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B C D
A - 17 21 27
B - 12 18
C - 14
D -
i ui
A (17+21+27)/2=32.5
B (17+12+18)/2=23.5
C (21+12+14)/2=23.5
D (27+18+14)/2=29.5
A B C D
A - -39 -35 -35
B - -35 -35
C - -39
D -
Dij-ui-uj
C D
X
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B C D
A - 17 21 27
B - 12 18
C - 14
D -
i ui
A (17+21+27)/2=32.5
B (17+12+18)/2=23.5
C (21+12+14)/2=23.5
D (27+18+14)/2=29.5
A B C D
A - -39 -35 -35
B - -35 -35
C - -39
D -
Dij-ui-uj
C D
vC = 0.5 x 14 + 0.5 x (23.5-29.5) = 4vD = 0.5 x 14 + 0.5 x (29.5-23.5) = 10
4 10X
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B C D X
A - 17 21 27
B - 12 18
C - 14
D -
X -
C D
4 10X
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B C D X
A - 17 21 27
B - 12 18
C - 14
D -
X -
C D
4 10X
DXA = (DCA + DDA - DCD)/2 = (21 + 27 - 14)/2 = 17
DXB = (DCB + DDB - DCD)/2 = (12 + 18 - 14)/2 = 8
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B C D X
A - 17 21 27 17
B - 12 18 8
C - 14
D -
X -
C D
4 10X
DXA = (DCA + DDA - DCD)/2 = (21 + 27 - 14)/2 = 17
DXB = (DCB + DDB - DCD)/2 = (12 + 18 - 14)/2 = 8
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B X
A - 17 17
B - 8
X -
C D
4 10X
DXA = (DCA + DDA - DCD)/2 = (21 + 27 - 14)/2 = 17
DXB = (DCB + DDB - DCD)/2 = (12 + 18 - 14)/2 = 8
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B X
A - 17 17
B - 8
X -
C D
4 10X
i ui
A (17+17)/1 = 34
B (17+8)/1 = 25
X (17+8)/1 = 25
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B X
A - 17 17
B - 8
X -
C D
4 10X
A B X
A - -42 -28
B - -28
X -
Dij-ui-uj
i ui
A (17+17)/1 = 34
B (17+8)/1 = 25
X (17+8)/1 = 25
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B X
A - 17 17
B - 8
X -
C D
4 10X
Dij-ui-uj
A B X
A - -42 -28
B - -28
X -
i ui
A (17+17)/1 = 34
B (17+8)/1 = 25
X (17+8)/1 = 25
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B X
A - 17 17
B - 8
X -
C D
4 10X
Dij-ui-uj
A B X
A - -42 -28
B - -28
X -
i ui
A (17+17)/1 = 34
B (17+8)/1 = 25
X (17+8)/1 = 25
vA = 0.5 x 17 + 0.5 x (34-25) = 13vD = 0.5 x 17 + 0.5 x (25-34) = 4
A B
Y413
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B X Y
A - 17 17
B - 8
X -
Y
C D
4 10X
A B
Y413
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
A B X Y
A - 17 17
B - 8
X - 4
Y
C D
4 10X
A B
Y413
DYX = (DAX + DBX - DAB)/2 = (17 + 8 - 17)/2 = 4
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
X Y
X - 4
Y -
C D
4 10X
A B
Y413
DYX = (DAX + DBX - DAB)/2 = (17 + 8 - 17)/2 = 4
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
X Y
X - 4
Y -
C D
4 10
A B
413
4
DYX = (DAX + DBX - DAB)/2 = (17 + 8 - 17)/2 = 4
CE
NT
ER
FO
R B
IOLO
GIC
AL
SE
QU
EN
CE
AN
ALY
SIS
Neighbor Joining Algorithm
C
D
A
BA B C D
A - 17 21 27
B - 12 18
C - 14
D - 10
4
13
4
4