| 1 | module Test where |
| 2 | { |
| 3 | import PopGen; |
| 4 | import Probability; |
| 5 | get_observed_alleles file = map vectorToList $ vectorToList $ read_phase_file file; |
| 6 | |
| 7 | filename = "/home/bredelings/Reports/Kmar/TwinCays2005a.phase1.infile"; |
| 8 | |
| 9 | n = 5; |
| 10 | |
| 11 | note mean ~ iid(n, gamma(0.5,0.5) ); |
| 12 | note sigmaOverMu ~ iid(n, gamma(1.05,0.1) ); |
| 13 | |
| 14 | alpha = 1.0; |
| 15 | |
| 16 | note p ~ symmetric_dirichlet (n, alpha/(intToDouble n)); |
| 17 | |
| 18 | data1 = get_observed_alleles filename; |
| 19 | |
| 20 | n_loci = length data1; |
| 21 | |
| 22 | n_individuals = (length (data1!!0))/2; |
| 23 | |
| 24 | note category ~ iid(n_loci, categorical p); |
| 25 | |
| 26 | note z ~ iid(n_loci, normal(0.0, 1.0)); |
| 27 | |
| 28 | safe_exp x = if (x < (-20.0)) then |
| 29 | exp (-20.0); |
| 30 | else if (x > 20.0) then |
| 31 | exp 20.0; |
| 32 | else |
| 33 | exp x; |
| 34 | |
| 35 | theta = [ mean!!k * safe_exp (z!!i * sigmaOverMu!!k) | i <- take n_loci [0..], let {k=category!!i}]; |
| 36 | |
| 37 | theta_effective = map (*(2.0-s)) theta; |
| 38 | |
| 39 | note theta_example ~ mixture [ (p!!i, logNormal(log(mean!!i),sigmaOverMu!!i)) | i <- take n [0..] ]; |
| 40 | |
| 41 | note s ~ uniform(0.0, 1.0); |
| 42 | |
| 43 | note i ~ iid(n_individuals, selfing_coalescence (n_loci, s)); |
| 44 | |
| 45 | note data data1 ~ plate (n_loci, \l -> afs2 (theta_effective!!l, map (!!l) i)); |
| 46 | |
| 47 | note MakeLogger p; |
| 48 | note MakeLogger theta; |
| 49 | } |