-
Notifications
You must be signed in to change notification settings - Fork 0
/
Andro.hs
63 lines (41 loc) · 1.67 KB
/
Andro.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
module Andro where
import PopGen
import PopGen.Selfing
import PopGen.Selfing.Androdioecy
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.25 2.0)
(male_fraction, s) <- random $ andro_model ()
let r = andro_mating_system' s male_fraction
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 males and total individuals in below:
-- observe (binomial <total_individual> male_fraction) <male_individuals>
return
[ "male_fraction" %=% male_fraction
, "t" %=% t
, "s*" %=% s
, "F[selfing]" %=% f_selfing
, "F[other]" %=% f_other
, "F[total]" %=% f_total
, "theta*" %=% theta_effective
, "R" %=% r
]
andro_model _ = do
s <- beta 0.25 1.0
male_fraction <- beta 2.0 2.0
return (male_fraction, s)