| 1 |
{-# LANGUAGE RecursiveDo #-} |
| 2 |
module Model where |
| 3 |
|
| 4 |
import Probability |
| 5 |
import Tree |
| 6 |
import Tree.Newick |
| 7 |
import qualified Data.Text as Text |
| 8 |
import Control.Monad.Fix -- should be unneeded |
| 9 |
import qualified Data.IntMap as IntMap |
| 10 |
|
| 11 |
nLeaves = 5 |
| 12 |
|
| 13 |
allTexts = fmap Text.pack allStrings |
| 14 |
|
| 15 |
allStrings = [ c : s | s <- "" : allStrings, c <- ['a'..'j'] ] |
| 16 |
|
| 17 |
model taxa = do |
| 18 |
let lambda = 1 |
| 19 |
tree <- sample $ yule taxa lambda |
| 20 |
|
| 21 |
let rootValue = 0 |
| 22 |
|
| 23 |
rec let meanFor node = case parentNode tree node of |
| 24 |
Nothing -> rootValue |
| 25 |
Just node -> xs IntMap.! node |
| 26 |
xs <- sample $ independentMap (getNodesSet tree) (\node -> sample $ normal (meanFor node) 1) |
| 27 |
|
| 28 |
return ["tree" %=% writeNewick tree, |
| 29 |
"xs" %=% xs] |
| 30 |
|
| 31 |
main logDir = do |
| 32 |
let taxa = take nLeaves allTexts |
| 33 |
|
| 34 |
return $ model taxa |