Skip to content

Commit

Permalink
Merge pull request #15 from kgori/tn93_pmatrices
Browse files Browse the repository at this point in the history
Bugfixes relating to P matrices of TN93 and related models
  • Loading branch information
jangevaare committed Mar 13, 2019
2 parents 83a979a + 5ffa02f commit 7e83139
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/nucleic_acid/f84/absolute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ end
e₃ = exp(-(πY * α₁ + πR * β) * t)

P₁ = πA + (πA * πY / πR) * e₁ + (πG / πR) * e₂
P₂ = πC + (πT * πR / πY) * e₁ + (πT / πY) * e₃
P₂ = πC + (πC * πR / πY) * e₁ + (πT / πY) * e₃
P₃ = πG + (πG * πY / πR) * e₁ + (πA / πR) * e₂
P₄ = πT + (πT * πR / πY) * e₁ + (πC / πY) * e₃
P₅ = πA * (1 - e₁)
P₆ = πA + (πA * πY / πR) * e₁ - (πA / πR) * e₂
P₇ = πC * (1 - e₁)
P₈ = πC + (πT * πR / πY) * e₁ - (πC / πY) * e₃
P₈ = πC + (πC * πR / πY) * e₁ - (πC / πY) * e₃
P₉ = πG + (πG * πY / πR) * e₁ - (πG / πR) * e₂
P₁₀ = πG * (1 - e₁)
P₁₁ = πT * (1 - e₁)
Expand Down
4 changes: 2 additions & 2 deletions src/nucleic_acid/f84/relative.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ end
e₃ = exp(-(πY * α₁ + πR) * t)

P₁ = πA + (πA * πY / πR) * e₁ + (πG / πR) * e₂
P₂ = πC + (πT * πR / πY) * e₁ + (πT / πY) * e₃
P₂ = πC + (πC * πR / πY) * e₁ + (πT / πY) * e₃
P₃ = πG + (πG * πY / πR) * e₁ + (πA / πR) * e₂
P₄ = πT + (πT * πR / πY) * e₁ + (πC / πY) * e₃
P₅ = πA * (1 - e₁)
P₆ = πA + (πA * πY / πR) * e₁ - (πA / πR) * e₂
P₇ = πC * (1 - e₁)
P₈ = πC + (πT * πR / πY) * e₁ - (πC / πY) * e₃
P₈ = πC + (πC * πR / πY) * e₁ - (πC / πY) * e₃
P₉ = πG + (πG * πY / πR) * e₁ - (πG / πR) * e₂
P₁₀ = πG * (1 - e₁)
P₁₁ = πT * (1 - e₁)
Expand Down
4 changes: 2 additions & 2 deletions src/nucleic_acid/hky85/absolute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ end
e₃ = exp(-(πY * α + πR * β) * t)

P₁ = πA + (πA * πY / πR) * e₁ + (πG / πR) * e₂
P₂ = πC + (πT * πR / πY) * e₁ + (πT / πY) * e₃
P₂ = πC + (πC * πR / πY) * e₁ + (πT / πY) * e₃
P₃ = πG + (πG * πY / πR) * e₁ + (πA / πR) * e₂
P₄ = πT + (πT * πR / πY) * e₁ + (πC / πY) * e₃
P₅ = πA * (1 - e₁)
P₆ = πA + (πA * πY / πR) * e₁ - (πA / πR) * e₂
P₇ = πC * (1 - e₁)
P₈ = πC + (πT * πR / πY) * e₁ - (πC / πY) * e₃
P₈ = πC + (πC * πR / πY) * e₁ - (πC / πY) * e₃
P₉ = πG + (πG * πY / πR) * e₁ - (πG / πR) * e₂
P₁₀ = πG * (1 - e₁)
P₁₁ = πT * (1 - e₁)
Expand Down
4 changes: 2 additions & 2 deletions src/nucleic_acid/hky85/relative.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ end
e₃ = exp(-(πY * κ + πR) * t)

P₁ = πA + (πA * πY / πR) * e₁ + (πG / πR) * e₂
P₂ = πC + (πT * πR / πY) * e₁ + (πT / πY) * e₃
P₂ = πC + (πC * πR / πY) * e₁ + (πT / πY) * e₃
P₃ = πG + (πG * πY / πR) * e₁ + (πA / πR) * e₂
P₄ = πT + (πT * πR / πY) * e₁ + (πC / πY) * e₃
P₅ = πA * (1 - e₁)
P₆ = πA + (πA * πY / πR) * e₁ - (πA / πR) * e₂
P₇ = πC * (1 - e₁)
P₈ = πC + (πT * πR / πY) * e₁ - (πC / πY) * e₃
P₈ = πC + (πC * πR / πY) * e₁ - (πC / πY) * e₃
P₉ = πG + (πG * πY / πR) * e₁ - (πG / πR) * e₂
P₁₀ = πG * (1 - e₁)
P₁₁ = πT * (1 - e₁)
Expand Down
6 changes: 3 additions & 3 deletions src/nucleic_acid/tn93/absolute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ end

function show(io::IO, object::TN93abs)
print(io, "\r\e[0m\e[1mT\e[0mamura and \e[1mN\e[0mei 19\e[1m93\e[0m model (absolute rate form)
α1 = $(object.α1), α2 = $(object.α1), β = $(object.β), π = [$(object.πA), $(object.πC), $(object.πG), $(object.πT)]")
α1 = $(object.α1), α2 = $(object.α2), β = $(object.β), π = [$(object.πA), $(object.πC), $(object.πG), $(object.πT)]")
end


Expand Down Expand Up @@ -71,13 +71,13 @@ end
e₃ = exp(-(πY * α₁ + πR * β) * t)

P₁ = πA + (πA * πY / πR) * e₁ + (πG / πR) * e₂
P₂ = πC + (πT * πR / πY) * e₁ + (πT / πY) * e₃
P₂ = πC + (πC * πR / πY) * e₁ + (πT / πY) * e₃
P₃ = πG + (πG * πY / πR) * e₁ + (πA / πR) * e₂
P₄ = πT + (πT * πR / πY) * e₁ + (πC / πY) * e₃
P₅ = πA * (1 - e₁)
P₆ = πA + (πA * πY / πR) * e₁ - (πA / πR) * e₂
P₇ = πC * (1 - e₁)
P₈ = πC + (πT * πR / πY) * e₁ - (πC / πY) * e₃
P₈ = πC + (πC * πR / πY) * e₁ - (πC / πY) * e₃
P₉ = πG + (πG * πY / πR) * e₁ - (πG / πR) * e₂
P₁₀ = πG * (1 - e₁)
P₁₁ = πT * (1 - e₁)
Expand Down
4 changes: 2 additions & 2 deletions src/nucleic_acid/tn93/relative.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ end
e₃ = exp(-(πY * κ₁ + πR) * t)

P₁ = πA + (πA * πY / πR) * e₁ + (πG / πR) * e₂
P₂ = πC + (πT * πR / πY) * e₁ + (πT / πY) * e₃
P₂ = πC + (πC * πR / πY) * e₁ + (πT / πY) * e₃
P₃ = πG + (πG * πY / πR) * e₁ + (πA / πR) * e₂
P₄ = πT + (πT * πR / πY) * e₁ + (πC / πY) * e₃
P₅ = πA * (1 - e₁)
P₆ = πA + (πA * πY / πR) * e₁ - (πA / πR) * e₂
P₇ = πC * (1 - e₁)
P₈ = πC + (πT * πR / πY) * e₁ - (πC / πY) * e₃
P₈ = πC + (πC * πR / πY) * e₁ - (πC / πY) * e₃
P₉ = πG + (πG * πY / πR) * e₁ - (πG / πR) * e₂
P₁₀ = πG * (1 - e₁)
P₁₁ = πT * (1 - e₁)
Expand Down
14 changes: 14 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ end
@test isapprox(diag(P(testmod2, 1.0e9)), (testmod2), atol = 1.0e-5)
@test sum((testmod1)) == 1.0
@test sum((testmod2)) == 1.0
@test sum(P(testmod1, 2.5), dims=2) [1 1 1 1]'
@test sum(P(testmod2, 2.5), dims=2) [1 1 1 1]'
end


Expand All @@ -51,6 +53,8 @@ end
@test isapprox(diag(P(testmod2, 1.0e9)), (testmod2), atol = 1.0e-5)
@test sum((testmod1)) == 1.0
@test sum((testmod2)) == 1.0
@test sum(P(testmod1, 2.5), dims=2) [1 1 1 1]'
@test sum(P(testmod2, 2.5), dims=2) [1 1 1 1]'
end


Expand All @@ -65,6 +69,8 @@ end
@test isapprox(diag(P(testmod2, 1.0e9)), (testmod2), atol = 1.0e-5)
@test sum((testmod1)) == 1.0
@test sum((testmod2)) == 1.0
@test sum(P(testmod1, 2.5), dims=2) [1 1 1 1]'
@test sum(P(testmod2, 2.5), dims=2) [1 1 1 1]'
end


Expand All @@ -79,6 +85,8 @@ end
@test isapprox(diag(P(testmod2, 1.0e9)), (testmod2), atol = 1.0e-5)
@test sum((testmod1)) == 1.0
@test sum((testmod2)) == 1.0
@test sum(P(testmod1, 2.5), dims=2) [1 1 1 1]'
@test sum(P(testmod2, 2.5), dims=2) [1 1 1 1]'
end


Expand All @@ -93,6 +101,8 @@ end
@test isapprox(diag(P(testmod2, 1.0e9)), (testmod2), atol = 1.0e-5)
@test sum((testmod1)) == 1.0
@test sum((testmod2)) == 1.0
@test sum(P(testmod1, 2.5), dims=2) [1 1 1 1]'
@test sum(P(testmod2, 2.5), dims=2) [1 1 1 1]'
end


Expand All @@ -107,6 +117,8 @@ end
@test isapprox(diag(P(testmod2, 1.0e9)), (testmod2), atol = 1.0e-5)
@test sum((testmod1)) == 1.0
@test sum((testmod2)) == 1.0
@test sum(P(testmod1, 2.5), dims=2) [1 1 1 1]'
@test sum(P(testmod2, 2.5), dims=2) [1 1 1 1]'
end


Expand All @@ -125,6 +137,8 @@ end
@test isapprox(diag(P(testmod2, 1.0e9)), (testmod2), atol = 1.0e-5)
@test sum((testmod1)) == 1.0
@test sum((testmod2)) == 1.0
@test sum(P(testmod1, 2.5), dims=2) [1 1 1 1]'
@test sum(P(testmod2, 2.5), dims=2) [1 1 1 1]'
end

@testset "Indexing" begin
Expand Down

0 comments on commit 7e83139

Please sign in to comment.