-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gyno.hs
75 lines (48 loc) · 1.78 KB
/
Gyno.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
module Gyno where
import PopGen
import PopGen.Selfing
import PopGen.Selfing.Gynodioecy
import Probability
import System.Environment
-- This file is a template. It using Haskell syntax to describe a model.
-- Lines beginning with -- are comments.
-- To use commented priors, remove the -- and add data on the correspond variable.
-- Alternatively, remove the prior and set the variable to a constant using 'let'.
observed_alleles = read_phase_file (getArgs !! 0)
n_loci = length observed_alleles
n_individuals = length (observed_alleles !! 0) `div` 2
main = do
let alpha = 0.10
theta_effective <- random $ dp n_loci alpha (gamma 0.5 0.5)
(a, tau, p_f, sigma) <- random $ gyno_model
let (s, h, r) = gyno_mating_system tau a p_f sigma
let factor = (1.0 - s * 0.5) * r
let theta = map (/ factor) theta_effective
f_other <- random $ beta 0.25 1.0
let f_selfing = s / (2.0 - s)
f_total = 1.0 - (1.0 - f_selfing) * (1.0 - f_other)
(t, afs_dist) <- random $ robust_diploid_afs n_individuals n_loci s f_other theta_effective
observe afs_dist observed_alleles
-- Insert specific numbers of females and total individuals in below:
-- observe (binomial <total> p_f) <females>
return
[ "t" %=% t
, "a" %=% a
, "tau" %=% tau
, "p_f" %=% p_f
, "sigma" %=% sigma
, "s*" %=% s
, "F[selfing]" %=% f_selfing
, "F[other]" %=% f_other
, "F[total]" %=% f_total
, "theta*" %=% theta_effective
, "theta" %=% theta
, "H" %=% h
, "R" %=% r
]
gyno_model = do
-- a <- uniform 0.0 1.0
-- tau <- beta 2.0 8.0
-- p_f <- uniform 0.0 1.0
-- let sigma = 1.0
return (a, tau, p_f, sigma)