module ELynx.MarkovProcess.Nucleotide
( jc,
f81,
hky,
gtr4,
)
where
import qualified Data.Vector.Storable as V
import ELynx.Alphabet.Alphabet
import ELynx.MarkovProcess.RateMatrix
import ELynx.MarkovProcess.SubstitutionModel
import Numeric.LinearAlgebra hiding (normalize)
n :: Int
n :: Int
n = Int
4
jcExch :: ExchangeabilityMatrix
jcExch :: ExchangeabilityMatrix
jcExch =
(Int
n forall a. Storable a => Int -> Int -> [a] -> Matrix a
>< Int
n)
[ R
0.0,
R
1.0,
R
1.0,
R
1.0,
R
1.0,
R
0.0,
R
1.0,
R
1.0,
R
1.0,
R
1.0,
R
0.0,
R
1.0,
R
1.0,
R
1.0,
R
1.0,
R
0.0
]
uniformVec :: Vector Double
uniformVec :: Vector R
uniformVec = forall a. Storable a => Int -> a -> Vector a
V.replicate Int
n (R
1 forall a. Fractional a => a -> a -> a
/ forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n)
jc :: Normalize -> SubstitutionModel
jc :: Normalize -> SubstitutionModel
jc Normalize
nz = Alphabet
-> Name
-> [R]
-> Normalize
-> Vector R
-> ExchangeabilityMatrix
-> SubstitutionModel
substitutionModel Alphabet
DNA Name
"JC" [] Normalize
nz Vector R
uniformVec ExchangeabilityMatrix
jcExch
f81 :: Normalize -> StationaryDistribution -> SubstitutionModel
f81 :: Normalize -> Vector R -> SubstitutionModel
f81 Normalize
nz Vector R
d = Alphabet
-> Name
-> [R]
-> Normalize
-> Vector R
-> ExchangeabilityMatrix
-> SubstitutionModel
substitutionModel Alphabet
DNA Name
"F81" [] Normalize
nz Vector R
d ExchangeabilityMatrix
jcExch
hkyExch :: Double -> ExchangeabilityMatrix
hkyExch :: R -> ExchangeabilityMatrix
hkyExch R
k =
(Int
n forall a. Storable a => Int -> Int -> [a] -> Matrix a
>< Int
n)
[R
0.0, R
1.0, R
k, R
1.0, R
1.0, R
0.0, R
1.0, R
k, R
k, R
1.0, R
0.0, R
1.0, R
1.0, R
k, R
1.0, R
0.0]
hky :: Normalize -> Double -> StationaryDistribution -> SubstitutionModel
hky :: Normalize -> R -> Vector R -> SubstitutionModel
hky Normalize
nz R
k Vector R
d = Alphabet
-> Name
-> [R]
-> Normalize
-> Vector R
-> ExchangeabilityMatrix
-> SubstitutionModel
substitutionModel Alphabet
DNA Name
"HKY" [R
k] Normalize
nz Vector R
d ExchangeabilityMatrix
e where e :: ExchangeabilityMatrix
e = R -> ExchangeabilityMatrix
hkyExch R
k
gtr4 :: Normalize -> [Double] -> StationaryDistribution -> SubstitutionModel
gtr4 :: Normalize -> [R] -> Vector R -> SubstitutionModel
gtr4 Normalize
nz [R]
es Vector R
d = Alphabet
-> Name
-> [R]
-> Normalize
-> Vector R
-> ExchangeabilityMatrix
-> SubstitutionModel
substitutionModel Alphabet
DNA Name
"GTR" [R]
es Normalize
nz Vector R
d ExchangeabilityMatrix
e
where
e :: ExchangeabilityMatrix
e = forall a.
(RealFrac a, Container Vector a) =>
Int -> [a] -> Matrix a
exchFromListUpper Int
n [R]
es