| 1 |
module Model where |
| 2 |
|
| 3 |
import Probability |
| 4 |
import Bio.Alignment |
| 5 |
import Bio.Alphabet |
| 6 |
import Bio.Sequence |
| 7 |
import Tree |
| 8 |
import Tree.Newick |
| 9 |
import SModel |
| 10 |
import IModel |
| 11 |
import System.Environment -- for getArgs |
| 12 |
|
| 13 |
branch_length_dist topology branch = gamma (1/2) (2/fromIntegral n) where n = numBranches topology |
| 14 |
|
| 15 |
model seq_data = do |
| 16 |
let taxa = getTaxa seq_data |
| 17 |
tip_seq_lengths = getSequenceLengths seq_data |
| 18 |
|
| 19 |
-- Tree |
| 20 |
scale <- prior $ gamma (1/2) 2 |
| 21 |
tree <- prior $ uniformLabelledTree'' taxa branch_length_dist |
| 22 |
|
| 23 |
-- Indel model |
| 24 |
indel_rate <- prior $ logLaplace (-4) 0.707 |
| 25 |
mean_length <- (1 +) <$> sample (exponential 10) |
| 26 |
let imodel = rs07 indel_rate mean_length tree |
| 27 |
|
| 28 |
-- Substitution model |
| 29 |
freqs <- prior $ symmetricDirichletOn ["A", "C", "G", "T"] 1 |
| 30 |
kappa1 <- prior $ logNormal 0 1 |
| 31 |
kappa2 <- prior $ logNormal 0 1 |
| 32 |
let tn93_model = tn93' dna kappa1 kappa2 freqs |
| 33 |
|
| 34 |
-- Alignment |
| 35 |
alignment <- prior $ phyloAlignment tree imodel scale tip_seq_lengths |
| 36 |
|
| 37 |
-- Observation |
| 38 |
observe seq_data $ phyloCTMC tree alignment tn93_model scale |
| 39 |
|
| 40 |
return |
| 41 |
[ "tree" %=% writeNewick tree |
| 42 |
, "log(indel_rate)" %=% log indel_rate |
| 43 |
, "mean_length" %=% mean_length |
| 44 |
, "kappa1" %=% kappa1 |
| 45 |
, "kappa2" %=% kappa2 |
| 46 |
, "frequencies" %=% freqs |
| 47 |
, "scale" %=% scale |
| 48 |
, "|T|" %=% treeLength tree |
| 49 |
, "scale*|T|" %=% treeLength tree * scale |
| 50 |
, "|A|" %=% alignmentLength alignment |
| 51 |
] |
| 52 |
|
| 53 |
main logDir = do |
| 54 |
[filename] <- getArgs |
| 55 |
|
| 56 |
seq_data <- mkUnalignedCharacterData dna <$> loadSequences filename |
| 57 |
|
| 58 |
return $ model seq_data |