S 1

MAT 4830
Mathematical Modeling
4.4
Matrix Models of Base
Substitutions I
http://myhome.spu.edu/lauw
Preview


Markov Model
Maple
• Matrices
Example from 4.3
Suppose a 40-base ancestral and
descendent DNA sequences are
S0 : ACTTGTCGGATGATCAGCGGTCCATGCACCTGACAACGGT
S1 : ACATGTTGCTTGACGACAGGTCCATGCGCCTGAGAACGGC
S1 \ S0
A G C T
S1 \ S0
A
A
G
C
T
7
9
1
9
1
11
9 2
11 11
2 7
11 11
1
0
11
1
9
A
7
0
1
1
G
1
9
2
0
G
C
0
2
7
2
C
0
T
1
0
1
6
T
1
9
0
0
2
9
6
9
P(S1  i | S0  j )
Notations
Pi  P (a base is of type i), i     A, G , C , T 
Pi| j  P ( S1  i | S0  j )
i, j  
For each sequence S k , we define base distribution vector as
pk   PA
PG
PC
PT 
T
Notations
Pi  PAbuse
(a baseofis of type i), i     A, G , C , T 
notations
Pi| j  P ( S1  i | S0  j )
i, j  
For each sequence S k , we define base distribution vector as
pk   PA
PG
PC
PT 
T
Example from 4.3
p0   PA
PG
T
9
PT   
 40
PC
11
40
9
40 
11
40
T
S0 : ACTTGTCGGATGATCAGCGGTCCATGCACCTGACAACGGT
S1 : ACATGTTGCTTGACGACAGGTCCATGCGCCTGAGAACGGC
S1 \ S0
A
A G C T
7
0
1
S1 \ S0
A
1
A
G
C
T
7
9
1
9
1
11
9 2
11 11
2 7
11 11
1
0
11
1
9
G
1
9
2
0
G
C
0
2
7
2
C
0
T
1
0
1
6
T
1
9
0
0
2
9
6
9
Pi| j  P( S1  i | S0  j )
Example from 4.3
p1   PA
PG
T
9
PT   
 40
PC
12
40
8
40 
11
40
T
S0 : ACTTGTCGGATGATCAGCGGTCCATGCACCTGACAACGGT
S1 : ACATGTTGCTTGACGACAGGTCCATGCGCCTGAGAACGGC
S1 \ S0
A
A G C T
7
0
1
S1 \ S0
A
1
A
G
C
T
7
9
1
9
1
11
9 2
11 11
2 7
11 11
1
0
11
1
9
G
1
9
2
0
G
C
0
2
7
2
C
0
T
1
0
1
6
T
1
9
0
0
2
9
6
9
Pi| j  P( S1  i | S0  j )
Example from 4.3
What is the realtionship between p0 , p1 , and Pi| j ?
9
p0  
 40
9
p1  
 40
11
40
12
40
11
40
11
40
9
40 
8
40 
T
T
S1 \ S0
A
G
A
G
C
T
7
9
1
9
1
11
9 2
11 11
2 7
11 11
1
0
11
1
9
C
0
T
1
9
0
0
2
9
6
9
Pi| j  P( S1  i | S0  j )
Transition Matrix

Encode the conditional prob. into a
matrix
 PA| A
P
G| A



M   Pi| j  
 PC | A

 PT | A
PA|G
PA|C
PG|G
PG|C
PC |G
PC |C
PT |G
PT |C
PA|T 
PG|T 
PC |T 

PT |T 
Example from 4.3
Pi| j  P( S1  i | S0  j )
 PA| A
P
G| A
M 
 PC | A

 PT | A
PA|G
PA|C
PG|G
PG|C
PC |G
PC |C
PT |G
PT |C
7
9
PA|T   1

PG|T   9

PC |T  
 0
PT |T  
1

9
1
0
11
9 2
11 11
2 7
11 11
1
0
11
1
9

0


2
9
6

9
S1 \ S0
A
G
A
G
C
T
7
9
1
9
1
11
9 2
11 11
2 7
11 11
1
0
11
1
9
C
0
T
1
9
0
0
2
9
6
9
Example from 4.3
p1  Mp0
1
 9  7
 40   9 0 11
  
 12   1 9 2
 40   9 11 11
 
 11   0 2 7
 40  
11 11
 8  1
1
  
0
11
 40   9
1  9 
9   40 
 
11 


0
  40 
 
2   11 
9   40 
6  9 
 
9   40 
Example from 4.3
p1  Mp0
1
 9  7
 40   9 0 11
  
 12   1 9 2
 40   9 11 11
 
 11   0 2 7
 40  
11 11
 8  1
1
  
0
11
 40   9
1  9 
9   40 
 
11 


0
  40 
 
2   11 
9   40 
6  9 
 
9   40 
Example from 4.3
p1  Mp0
1
 9  7
 40   9 0 11
  
 12   1 9 2
 40   9 11 11
 
 11   0 2 7
 40  
11 11
 8  1
1
  
0
11
 40   9
1  9 
9   40 
 
11 


0
  40 
 
2   11 
9   40 
6  9 
 
9   40 
Example from 4.3
 ?   PA| A
  P
    G| A
   PC | A
  
   PT | A
A
G
C
PA|G
PA|C
PG|G
PG|C
PC |G
PC |C
PT |G
PT |C
T
A
Key words:
• Mutually Exclusive Events
• Exhaustive Events
PA|T   P ( S0  A) 
PG|T   P ( S0  G ) 


PC |T   P ( S0  C ) 


PT |T   P ( S0  T ) 
Estimation

Use the transition matrix, we can
estimate the base distribution vectors pk
of descendent sequences Sk , k  1, 2,3,...
by
pk  Mpk 1
Estimation

Use the transition matrix, we can
estimate the base distribution vectors pk
of descendent sequences Sk , k  2,3,...
by
pk  Mpk 1
M   Pi| j    P( Sk  i | S k 1  j ) 
Assumptions


The prob. of base substitution is the
same for consecutive pair of generation.
The mutation from Sk-1 to Sk only
depends on Sk-1.
Homework (Maple)

Given S0 to S1 , produce the frequency array
as an matrix
S1 \ S0
A G C T
A
7
0
1
G
1
9
2
C
0
2
7
T
1
0
1
7
1
1
0  
0
2

1
6
0 1 1
9 2 0 
2 7 2

0 1 6
Homework (Maple)

Given S0 to S1 , produce the frequency array
as an matrix (return as a function value)
Homework (Maple)

Given S0 to S1 , produce the transition matrix
 PA| A
P
G| A
M 
 PC | A

 PT | A
PA|G
PA|C
PG|G
PG|C
PC |G
PC |C
PT |G
PT |C
7
9
PA|T   1


PG|T   9

PC |T  
 0
PT |T  
1

9
1
11
9 2
11 11
2 7
11 11
1
0
11
0
1
9

0


2
9
6

9
Homework (Maple)

Given S0 to S1 , produce the transition matrix
Warnings

Do NOT use other package/commands.
Maple: Matrices

Load the Linear Algebra Package
Maple: Matrices

Define a matrix

All entries are initialized to zeros
Maple: Matrices

Define a matrix with specified entries
Maple: Matrices

Indexing
Classwork

Given S0 to S1 , produce the frequency array
as an matrix

Your first version may be ‘bulky”.
See if you can produce a better version

Maple: Strings Handling


You will need this from two lectures ago.
For your reference, I attached the slides
below.
Maple: Strings Handling

Assignments
Maple: Strings Handling

Subscripting
Maple: Strings Handling

Subscripting
Maple: Strings Handling

Subscripting
Maple: Strings Handling

Counting