-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathClockModels.xml
171 lines (147 loc) · 9.8 KB
/
ClockModels.xml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<beast version='2.0'
namespace='beastfx.app.beauti:beast.pkgmgmt:beast.base.core:beast.base.inference:beast.base.evolution.branchratemodel:beast.base.evolution.speciation:beast.base.evolution.tree.coalescent:beast.base.util:beast.base.math:beast.evolution.nuc:beast.base.evolution.operator:beast.base.inference.operator:beast.base.evolution.sitemodel:beast.base.evolution.substitutionmodel:beast.base.evolution.likelihood:beast.evolution:beast.base.inference.distribution'>
<!-- Clock models -->
<mergewith point='clockModelTemplates'>
<!-- Strict clock -->
<subtemplate id='StrictClock' class='beast.base.evolution.branchratemodel.StrictClockModel'
mainid='StrictClock.c:$(n)'
hmc='ClockPrior/index/=Priors/ClockPrior/,
StrictClockRateScaler/index/=Operators/BactrianRateScaler/index/,
strictClockUpDownOperator/index/=Operators/BactrianUpDown/index/'>
<![CDATA[
<branchRateModel spec='StrictClockModel' id='StrictClock.c:$(n)'>
<clock.rate id='clockRate.c:$(n)' spec='parameter.RealParameter' value='1.0' lower="0.0" estimate='false'/>
</branchRateModel>
<operator id='StrictClockRateScaler.c:$(n)' spec='kernel.BactrianScaleOperator' scaleFactor="0.1" weight="3" parameter='@clockRate.c:$(n)'/>
<operator id="strictClockUpDownOperator.c:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="1.5">
<parameter idref="clockRate.c:$(n)"/>
<tree idref="Tree.t:$(n)"/>
<operator idref="AVMNOperator.$(n)"/>
<operator id='strictClockUpDownOperatorX.c:$(n)' spec='kernel.BactrianUpDownOperator' scaleFactor="0.75" weight="3">
<up idref="clockRate.c:$(n)"/>
<down idref="Tree.t:$(n)"/>
</operator>
</operator>
<prior id='ClockPrior.c:$(n)' x='@clockRate.c:$(n)'>
<Gamma name="distr">
<alpha spec="parameter.RealParameter" value="0.01" estimate="false"/>
<beta spec="parameter.RealParameter" value="100.0" estimate="false"/>
</Gamma>
</prior>
]]>
<connect srcID='clockRate.c:$(n)' targetID='state' inputName='stateNode'
if='inlikelihood(clockRate.c:$(n)) and clockRate.c:$(n)/estimate=true'/>
<connect srcID='clockRate.c:$(n)' targetID='AVMNLogTransform.$(n)' inputName='f'
if='inlikelihood(clockRate.c:$(n)) and clockRate.c:$(n)/estimate=true'/>
<connect srcID='ClockPrior.c:$(n)' targetID='prior' inputName='distribution'
if='inlikelihood(clockRate.c:$(n)) and clockRate.c:$(n)/estimate=true'>substitution rate of
partition c:$(n)
</connect>
<connect srcID='StrictClockRateScaler.c:$(n)' targetID='mcmc' inputName='operator'
if='inlikelihood(clockRate.c:$(n)) and clockRate.c:$(n)/estimate=true'>Scale substitution rate of
partition c:$(n)
</connect>
<connect srcID='strictClockUpDownOperator.c:$(n)' targetID='mcmc' inputName='operator'
if='inlikelihood(clockRate.c:$(n)) and clockRate.c:$(n)/estimate=true and inlikelihood(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'>
Scale up substitution rate c:$(n) and scale down tree t:$(n)
</connect>
</subtemplate>
<!-- Random local clock -->
<subtemplate id='RandomLocalClock' class='beast.base.evolution.branchratemodel.RandomLocalClockModel'
mainid='RandomLocalClock.c:$(n)'
suppressInputs='beast.base.evolution.branchratemodel.RandomLocalClockModel.rates'
hmc='
RandomLocalClock/clock.rate/=StrictClock/clock.rate/,
RandomLocalClock/scaling/,
RandomLocalClock/includeRoot/,
RandomLocalClock/ratesAreMultipliers/,
RRatesPrior/index/=RandomLocalClock/RatesPrior/,
RRateChangesPrior/index/=RandomLocalClock/RRateChangesPrior/,
MeanRRatePrior/index/=Priors/ClockPrior/,
ClockRateScaler/index/=Operators/BactrianRateScaler/index/,
randomClockScaler/index/=Operators/BactrianRateScaler/index/,
randomClockUpDownOperator/index/=Operators/BactrianUpDown/index/,
BitFlipOperator/index/=Operators/BitFlipper/index/
'>
<![CDATA[
<input spec='RandomLocalClockModel' id="RandomLocalClock.c:$(n)" ratesAreMultipliers="false" tree='@Tree.t:$(n)'>
<clock.rate id='meanClockRate.c:$(n)' spec='parameter.RealParameter' value='1.0' lower="0.0" estimate='false'/>
<parameter spec='parameter.BooleanParameter' name='indicators' id='Indicators.c:$(n)' value="0"/>
<parameter name='rates' id='clockrates.c:$(n)' value="1" lower="1e-9"/>
</input>
<operator id="IndicatorsBitFlip.c:$(n)" spec="BitFlipOperator" weight="15" parameter="@Indicators.c:$(n)"/>
<!-- this should probably be a DeltaExchange instead of scale operator to keep mean rate to 1 -->
<operator id='ClockRateScaler.c:$(n)' spec='kernel.BactrianScaleOperator' scaleAll='false' scaleFactor="0.1" weight="15" parameter="@clockrates.c:$(n)"/>
<operator id='randomClockScaler.c:$(n)' spec='kernel.BactrianScaleOperator' scaleAll='false' scaleFactor="0.1" weight="1" parameter="@meanClockRate.c:$(n)"/>
<operator id='randomClockUpDownOperator.c:$(n)' spec='kernel.BactrianUpDownOperator' scaleFactor="0.1" weight="3">
<up idref="meanClockRate.c:$(n)"/>
<down idref="Tree.t:$(n)"/>
</operator>
<distribution idref="prior">
<if cond='inlikelihood(RandomLocalClock.c:$(n))'>
<!-- prior on rates -->
<prior id='RRatesPrior.c:s$(n)' name="distribution" x='@clockrates.c:$(n)'>
<Gamma id="Gamma.0" name="distr">
<parameter estimate="false" name="alpha">0.5</parameter>
<parameter estimate="false" name="beta">2.0</parameter>
</Gamma>
</prior>
<!-- prior on number of changes -->
<prior id="RRateChangesPrior.c:$(n)" name="distribution">
<x id="RRateChanges.c:$(n)" spec="beast.base.evolution.Sum" arg="@Indicators.c:$(n)"/>
<distr spec='beast.base.inference.distribution.Poisson'>
<lambda spec='parameter.RealParameter' estimate='false' value='0.6931471805599453'/>
</distr>
</prior>
</if>
</distribution>
<logger idref="tracelog">
<if cond='inlikelihood(RandomLocalClock.c:$(n))'>
<log idref="RRateChanges.c:$(n)"/>
</if>
</logger>
<prior id='MeanRRatePrior.c:s$(n)' x='@meanClockRate.c:$(n)'>
<Gamma name="distr">
<alpha spec="parameter.RealParameter" value="0.01" estimate="false"/>
<beta spec="parameter.RealParameter" value="100.0" estimate="false"/>
</Gamma>
</prior>
]]>
<connect srcID='Indicators.c:$(n)' targetID='state' inputName='stateNode'
if='inlikelihood(Indicators.c:$(n))'/>
<connect srcID='meanClockRate.c:$(n)' targetID='state' inputName='stateNode'
if='inlikelihood(meanClockRate.c:$(n)) and meanClockRate.c:$(n)/estimate=true'/>
<connect srcID='meanClockRate.c:$(n)' targetID='AVMNLogTransform.$(n)' inputName='f'
if='inlikelihood(meanClockRate.c:$(n)) and meanClockRate.c:$(n)/estimate=true'/>
<connect srcID='clockrates.c:$(n)' targetID='state' inputName='stateNode'
if='inlikelihood(clockrates.c:$(n))'/>
<connect srcID='randomClockScaler.c:$(n)' targetID='mcmc' inputName='operator'
if='inlikelihood(meanClockRate.c:$(n)) and meanClockRate.c:$(n)/estimate=true'>Scale clock rate of
partition c:$(n)
</connect>
<connect srcID='randomClockUpDownOperator.c:$(n)' targetID='mcmc' inputName='operator'
if='inlikelihood(meanClockRate.c:$(n)) and inlikelihood(Tree.t:$(n)) and Tree.t:$(n)/estimate=true and meanClockRate.c:$(n)/estimate=true'>
Up/down scaler for mean rate and tree of partition c:$(n)
</connect>
<connect srcID='IndicatorsBitFlip.c:$(n)' targetID='mcmc' inputName='operator'
if='inlikelihood(Indicators.c:$(n))'>Flip indicator bits for random clock of partition c:$(n)
</connect>
<connect srcID='ClockRateScaler.c:$(n)' targetID='mcmc' inputName='operator'
if='inlikelihood(clockrates.c:$(n))'>Scale random clock rates of partition c:$(n)
</connect>
<connect srcID='Tree.t:$(n)' targetID='RandomLocalClock.c:$(n)' inputName='tree' if='inlikelihood(RandomLocalClock.c:$(n))'/>
<connect srcID='Indicators.c:$(n)' targetID='tracelog' inputName='log'
if='inlikelihood(Indicators.c:$(n))'/>
<connect srcID='clockrates.c:$(n)' targetID='tracelog' inputName='log'
if='inlikelihood(clockrates.c:$(n))'/>
<connect srcID='meanClockRate.c:$(n)' targetID='tracelog' inputName='log'
if='inposterior(RandomLocalClock.c:$(n)) and meanClockRate.c:$(n)/estimate=true'/>
<connect srcID='MeanRRatePrior.c:$(n)' targetID='prior' inputName='distribution'
if='inlikelihood(meanClockRate.c:$(n)) and meanClockRate.c:$(n)/estimate=true'>substitution rate of
partition c:$(n)
</connect>
<connect srcID='RandomLocalClock.c:$(n)' targetID='TreeWithMetaDataLogger.t:$(n)'
inputName='branchratemodel' if='inposterior(RandomLocalClock.c:$(n))'/>
</subtemplate>
</mergewith>
</beast>