| 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 |
package dr.app.beauti.options; |
| 27 |
|
| 28 |
import dr.app.beauti.types.*; |
| 29 |
import dr.evolution.datatype.DataType; |
| 30 |
import dr.evolution.util.Taxa; |
| 31 |
|
| 32 |
import java.util.ArrayList; |
| 33 |
import java.util.List; |
| 34 |
|
| 35 |
import static dr.app.beauti.options.BeautiOptions.DEFAULT_QUANTILE_RELAXED_CLOCK; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public class PartitionClockModel extends PartitionOptions { |
| 44 |
private static final long serialVersionUID = -6904595851602060488L; |
| 45 |
|
| 46 |
private ClockType clockType = ClockType.STRICT_CLOCK; |
| 47 |
private ClockDistributionType clockDistributionType = ClockDistributionType.LOGNORMAL; |
| 48 |
private boolean continuousQuantile = DEFAULT_QUANTILE_RELAXED_CLOCK; |
| 49 |
private boolean performModelAveraging = false; |
| 50 |
|
| 51 |
private PartitionTreeModel treeModel = null; |
| 52 |
|
| 53 |
private final AbstractPartitionData partition; |
| 54 |
private final int dataLength; |
| 55 |
|
| 56 |
public PartitionClockModel(final BeautiOptions options, String name, AbstractPartitionData partition, PartitionTreeModel treeModel) { |
| 57 |
super(options, name); |
| 58 |
|
| 59 |
dataLength = partition.getSiteCount(); |
| 60 |
|
| 61 |
this.partition = partition; |
| 62 |
this.treeModel = treeModel; |
| 63 |
|
| 64 |
initModelParametersAndOpererators(); |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
public PartitionClockModel(BeautiOptions options, String name, PartitionClockModel source) { |
| 75 |
super(options, name); |
| 76 |
|
| 77 |
this.clockType = source.clockType; |
| 78 |
clockDistributionType = source.clockDistributionType; |
| 79 |
|
| 80 |
dataLength = source.dataLength; |
| 81 |
|
| 82 |
this.partition = source.partition; |
| 83 |
this.treeModel = source.treeModel; |
| 84 |
|
| 85 |
initModelParametersAndOpererators(); |
| 86 |
} |
| 87 |
|
| 88 |
public void initModelParametersAndOpererators() { |
| 89 |
double rate = 1.0; |
| 90 |
|
| 91 |
new Parameter.Builder("clock.rate", "substitution rate") |
| 92 |
.prior(PriorType.CTMC_RATE_REFERENCE_PRIOR).initial(rate) |
| 93 |
.isCMTCRate(true).isNonNegative(true).partitionOptions(this) |
| 94 |
.isAdaptiveMultivariateCompatible(true).build(parameters); |
| 95 |
|
| 96 |
new Parameter.Builder(ClockType.UCED_MEAN, "uncorrelated exponential relaxed clock mean"). |
| 97 |
prior(PriorType.CTMC_RATE_REFERENCE_PRIOR).initial(rate) |
| 98 |
.isCMTCRate(true).isNonNegative(true).partitionOptions(this) |
| 99 |
.isAdaptiveMultivariateCompatible(true).build(parameters); |
| 100 |
|
| 101 |
new Parameter.Builder(ClockType.UCLD_MEAN, "uncorrelated lognormal relaxed clock mean"). |
| 102 |
prior(PriorType.CTMC_RATE_REFERENCE_PRIOR).initial(rate) |
| 103 |
.isCMTCRate(true).isNonNegative(true).partitionOptions(this) |
| 104 |
.isAdaptiveMultivariateCompatible(true).build(parameters); |
| 105 |
|
| 106 |
new Parameter.Builder(ClockType.UCGD_MEAN, "uncorrelated gamma relaxed clock mean"). |
| 107 |
prior(PriorType.CTMC_RATE_REFERENCE_PRIOR).initial(rate) |
| 108 |
.isCMTCRate(true).isNonNegative(true).partitionOptions(this) |
| 109 |
.isAdaptiveMultivariateCompatible(true).build(parameters); |
| 110 |
|
| 111 |
new Parameter.Builder(ClockType.UCLD_STDEV, "uncorrelated lognormal relaxed clock stdev"). |
| 112 |
scaleType(PriorScaleType.LOG_STDEV_SCALE).prior(PriorType.EXPONENTIAL_PRIOR).isNonNegative(true) |
| 113 |
.initial(1.0 / 3.0).mean(1.0 / 3.0).offset(0.0).partitionOptions(this) |
| 114 |
.isAdaptiveMultivariateCompatible(true).build(parameters); |
| 115 |
|
| 116 |
new Parameter.Builder(ClockType.UCGD_SHAPE, "uncorrelated gamma relaxed clock shape"). |
| 117 |
prior(PriorType.EXPONENTIAL_PRIOR).isNonNegative(true) |
| 118 |
.initial(1.0 / 3.0).mean(1.0 / 3.0).offset(0.0).partitionOptions(this) |
| 119 |
.isAdaptiveMultivariateCompatible(true).build(parameters); |
| 120 |
|
| 121 |
|
| 122 |
createParameterGammaPrior(ClockType.LOCAL_CLOCK + ".relativeRates", "random local clock relative rates", |
| 123 |
PriorScaleType.SUBSTITUTION_RATE_SCALE, 1.0, 0.5, 2.0, false, false); |
| 124 |
createParameter(ClockType.LOCAL_CLOCK + ".changes", "random local clock rate change indicator"); |
| 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 |
createParameter("branchRates.categories", "relaxed clock branch rate categories"); |
| 150 |
|
| 151 |
|
| 152 |
createZeroOneParameterUniformPrior("branchRates.quantiles", "relaxed clock branch rate quantiles", 0.5); |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
new Parameter.Builder("branchRates.distributionIndex", "distribution integer index"). |
| 158 |
prior(PriorType.DISCRETE_UNIFORM_PRIOR).isNonNegative(true) |
| 159 |
.initial(0.0).uniformLower(0.0).uniformUpper(2.0).offset(0.0).partitionOptions(this) |
| 160 |
.isAdaptiveMultivariateCompatible(false).build(parameters); |
| 161 |
|
| 162 |
createScaleOperator("clock.rate", demoTuning, rateWeights); |
| 163 |
createScaleOperator(ClockType.UCED_MEAN, demoTuning, rateWeights); |
| 164 |
createScaleOperator(ClockType.UCLD_MEAN, demoTuning, rateWeights); |
| 165 |
createScaleOperator(ClockType.UCLD_STDEV, demoTuning, rateWeights); |
| 166 |
createScaleOperator(ClockType.UCGD_MEAN, demoTuning, rateWeights); |
| 167 |
createScaleOperator(ClockType.UCGD_SHAPE, demoTuning, rateWeights); |
| 168 |
|
| 169 |
|
| 170 |
createOperator(ClockType.LOCAL_CLOCK + ".relativeRates", OperatorType.RANDOM_WALK, demoTuning, treeWeights); |
| 171 |
createOperator(ClockType.LOCAL_CLOCK + ".changes", OperatorType.BITFLIP, 1, treeWeights); |
| 172 |
createDiscreteStatistic("rateChanges", "number of random local clocks"); |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
createNonNegativeParameterDirichletPrior("allNus", "relative rates amongst partitions parameter", this, 0, 1.0, true, true); |
| 177 |
createOperator("deltaNus", "allNus", |
| 178 |
"Change partition rates relative to each other maintaining mean", "allNus", |
| 179 |
OperatorType.DELTA_EXCHANGE, 0.01, 3.0); |
| 180 |
|
| 181 |
createNonNegativeParameterInfinitePrior("allMus", "relative rates amongst partitions parameter", this, PriorScaleType.SUBSTITUTION_PARAMETER_SCALE, 1.0, true); |
| 182 |
createOperator("deltaMus", "allMus", |
| 183 |
"Change partition rates relative to each other maintaining mean", "allMus", |
| 184 |
OperatorType.WEIGHTED_DELTA_EXCHANGE, 0.01, 3.0); |
| 185 |
|
| 186 |
|
| 187 |
createOperator("swapBranchRateCategories", "branchRates.categories", "Performs a swap of branch rate categories", |
| 188 |
"branchRates.categories", OperatorType.SWAP, 1, branchWeights / 3); |
| 189 |
createOperator("uniformBranchRateCategories", "branchRates.categories", "Performs an integer uniform draw of branch rate categories", |
| 190 |
"branchRates.categories", OperatorType.INTEGER_UNIFORM, 1, branchWeights / 3); |
| 191 |
|
| 192 |
|
| 193 |
createOperator("rwBranchRateQuantiles", "branchRates.quantiles", "Random walk of branch rate quantiles", |
| 194 |
"branchRates.quantiles", OperatorType.RANDOM_WALK_LOGIT, 1, branchWeights / 3); |
| 195 |
|
| 196 |
createOperator("uniformBranchRateQuantiles", "branchRates.quantiles", "Performs an uniform draw of branch rate quantiles", |
| 197 |
"branchRates.quantiles", OperatorType.UNIFORM, 0, branchWeights / 3); |
| 198 |
|
| 199 |
|
| 200 |
createOperator("uniformBranchRateDistributionIndex", "branchRates.distributionIndex", "Performs a uniform draw of the distribution index", |
| 201 |
"branchRates.distributionIndex", OperatorType.INTEGER_UNIFORM, 0, branchWeights / 3); |
| 202 |
|
| 203 |
createUpDownOperator("upDownRateHeights", "Substitution rate and heights", |
| 204 |
"Scales substitution rates inversely to node heights of the tree", |
| 205 |
getPartitionTreeModel().getParameter("treeModel.allInternalNodeHeights"), |
| 206 |
getParameter("clock.rate"), OperatorType.UP_DOWN, demoTuning, rateWeights); |
| 207 |
createUpDownOperator("upDownUCEDMeanHeights", "UCED mean and heights", |
| 208 |
"Scales UCED mean inversely to node heights of the tree", |
| 209 |
getPartitionTreeModel().getParameter("treeModel.allInternalNodeHeights"), |
| 210 |
getParameter(ClockType.UCED_MEAN), OperatorType.UP_DOWN, demoTuning, rateWeights); |
| 211 |
createUpDownOperator("upDownUCLDMeanHeights", "UCLD mean and heights", |
| 212 |
"Scales UCLD mean inversely to node heights of the tree", |
| 213 |
getPartitionTreeModel().getParameter("treeModel.allInternalNodeHeights"), |
| 214 |
getParameter(ClockType.UCLD_MEAN), OperatorType.UP_DOWN, |
| 215 |
demoTuning, rateWeights); |
| 216 |
createUpDownOperator("upDownUCGDMeanHeights", "UCGD mean and heights", |
| 217 |
"Scales UCGD mean inversely to node heights of the tree", |
| 218 |
getPartitionTreeModel().getParameter("treeModel.allInternalNodeHeights"), |
| 219 |
getParameter(ClockType.UCGD_MEAN), OperatorType.UP_DOWN, demoTuning, rateWeights); |
| 220 |
|
| 221 |
createUpDownOperator("microsatUpDownRateHeights", "Substitution rate and heights", |
| 222 |
"Scales substitution rates inversely to node heights of the tree", |
| 223 |
getPartitionTreeModel().getParameter("treeModel.allInternalNodeHeights"), |
| 224 |
getParameter("clock.rate"),OperatorType.MICROSAT_UP_DOWN, demoTuning, branchWeights); |
| 225 |
} |
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
@Override |
| 255 |
public List<Parameter> selectParameters(List<Parameter> params) { |
| 256 |
|
| 257 |
double rate = 1.0; |
| 258 |
|
| 259 |
if (options.hasData()) { |
| 260 |
|
| 261 |
switch (clockType) { |
| 262 |
case STRICT_CLOCK: |
| 263 |
params.add(getClockRateParameter()); |
| 264 |
break; |
| 265 |
|
| 266 |
case RANDOM_LOCAL_CLOCK: |
| 267 |
params.add(getClockRateParameter()); |
| 268 |
getParameter(ClockType.LOCAL_CLOCK + ".changes"); |
| 269 |
params.add(getParameter("rateChanges")); |
| 270 |
params.add(getParameter(ClockType.LOCAL_CLOCK + ".relativeRates")); |
| 271 |
break; |
| 272 |
|
| 273 |
case FIXED_LOCAL_CLOCK: |
| 274 |
params.add(getClockRateParameter()); |
| 275 |
for (Taxa taxonSet : options.taxonSets) { |
| 276 |
if (options.taxonSetsMono.get(taxonSet)) { |
| 277 |
String parameterName = taxonSet.getId() + ".rate"; |
| 278 |
if (!hasParameter(parameterName)) { |
| 279 |
new Parameter.Builder(parameterName, "substitution rate") |
| 280 |
.prior(PriorType.CTMC_RATE_REFERENCE_PRIOR) |
| 281 |
.initial(rate) |
| 282 |
.isCMTCRate(true).isNonNegative(true) |
| 283 |
.partitionOptions(this) |
| 284 |
.taxonSet(taxonSet) |
| 285 |
.build(parameters); |
| 286 |
createScaleOperator(parameterName, demoTuning, rateWeights); |
| 287 |
} |
| 288 |
|
| 289 |
params.add(getParameter(taxonSet.getId() + ".rate")); |
| 290 |
} |
| 291 |
} |
| 292 |
break; |
| 293 |
|
| 294 |
case UNCORRELATED: |
| 295 |
|
| 296 |
|
| 297 |
switch (clockDistributionType) { |
| 298 |
case LOGNORMAL: |
| 299 |
params.add(getClockRateParameter()); |
| 300 |
params.add(getParameter(ClockType.UCLD_STDEV)); |
| 301 |
break; |
| 302 |
case GAMMA: |
| 303 |
params.add(getClockRateParameter()); |
| 304 |
params.add(getParameter(ClockType.UCGD_SHAPE)); |
| 305 |
break; |
| 306 |
case CAUCHY: |
| 307 |
throw new UnsupportedOperationException("Uncorrelated Cauchy clock not implemented yet"); |
| 308 |
|
| 309 |
case EXPONENTIAL: |
| 310 |
params.add(getClockRateParameter()); |
| 311 |
break; |
| 312 |
case MODEL_AVERAGING: |
| 313 |
params.add(getClockRateParameter(ClockType.UNCORRELATED, ClockDistributionType.LOGNORMAL)); |
| 314 |
params.add(getParameter(ClockType.UCLD_STDEV)); |
| 315 |
params.add(getClockRateParameter(ClockType.UNCORRELATED, ClockDistributionType.GAMMA)); |
| 316 |
params.add(getParameter(ClockType.UCGD_SHAPE)); |
| 317 |
params.add(getClockRateParameter(ClockType.UNCORRELATED, ClockDistributionType.EXPONENTIAL)); |
| 318 |
params.add(getParameter("branchRates.quantiles")); |
| 319 |
params.add(getParameter("branchRates.distributionIndex")); |
| 320 |
break; |
| 321 |
} |
| 322 |
break; |
| 323 |
|
| 324 |
case AUTOCORRELATED: |
| 325 |
throw new UnsupportedOperationException("Autocorrelated clock not implemented yet"); |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
default: |
| 330 |
throw new IllegalArgumentException("Unknown clock model"); |
| 331 |
} |
| 332 |
|
| 333 |
|
| 334 |
} |
| 335 |
|
| 336 |
return params; |
| 337 |
} |
| 338 |
|
| 339 |
public Parameter getClockRateParameter() { |
| 340 |
return getClockRateParameter(clockType, clockDistributionType); |
| 341 |
} |
| 342 |
|
| 343 |
private Parameter getClockRateParameter(ClockType clockType, ClockDistributionType clockDistributionType) { |
| 344 |
Parameter rateParam = null; |
| 345 |
switch (clockType) { |
| 346 |
case STRICT_CLOCK: |
| 347 |
rateParam = getParameter("clock.rate"); |
| 348 |
break; |
| 349 |
|
| 350 |
case RANDOM_LOCAL_CLOCK: |
| 351 |
rateParam = getParameter("clock.rate"); |
| 352 |
break; |
| 353 |
|
| 354 |
case FIXED_LOCAL_CLOCK: |
| 355 |
rateParam = getParameter("clock.rate"); |
| 356 |
break; |
| 357 |
|
| 358 |
case UNCORRELATED: |
| 359 |
switch (clockDistributionType) { |
| 360 |
case LOGNORMAL: |
| 361 |
rateParam = getParameter(ClockType.UCLD_MEAN); |
| 362 |
break; |
| 363 |
case GAMMA: |
| 364 |
rateParam = getParameter(ClockType.UCGD_MEAN); |
| 365 |
break; |
| 366 |
case CAUCHY: |
| 367 |
throw new UnsupportedOperationException("Uncorrelated Cauchy clock not implemented yet"); |
| 368 |
|
| 369 |
case EXPONENTIAL: |
| 370 |
rateParam = getParameter(ClockType.UCED_MEAN); |
| 371 |
break; |
| 372 |
case MODEL_AVERAGING: |
| 373 |
break; |
| 374 |
} |
| 375 |
break; |
| 376 |
|
| 377 |
case AUTOCORRELATED: |
| 378 |
throw new UnsupportedOperationException("Autocorrelated clock not implemented yet"); |
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
default: |
| 383 |
throw new IllegalArgumentException("Unknown clock model"); |
| 384 |
} |
| 385 |
|
| 386 |
if (!rateParam.isPriorEdited()) { |
| 387 |
if (options.treeModelOptions.isNodeCalibrated(partition.treeModel) < 0 |
| 388 |
&& !options.useTipDates) { |
| 389 |
rateParam.setFixed(true); |
| 390 |
} else { |
| 391 |
rateParam.priorType = PriorType.CTMC_RATE_REFERENCE_PRIOR; |
| 392 |
} |
| 393 |
} |
| 394 |
|
| 395 |
return rateParam; |
| 396 |
} |
| 397 |
|
| 398 |
private Operator getUpDownOperator() { |
| 399 |
switch (clockType) { |
| 400 |
case STRICT_CLOCK: |
| 401 |
return getOperator("upDownRateHeights"); |
| 402 |
case RANDOM_LOCAL_CLOCK: |
| 403 |
return getOperator("upDownRateHeights"); |
| 404 |
case FIXED_LOCAL_CLOCK: |
| 405 |
return getOperator("upDownRateHeights"); |
| 406 |
|
| 407 |
case UNCORRELATED: |
| 408 |
switch (clockDistributionType) { |
| 409 |
case LOGNORMAL: |
| 410 |
return getOperator("upDownUCLDMeanHeights"); |
| 411 |
case GAMMA: |
| 412 |
return getOperator("upDownUCGDMeanHeights"); |
| 413 |
case CAUCHY: |
| 414 |
throw new UnsupportedOperationException("Uncorrelated Cauchy clock not implemented yet"); |
| 415 |
|
| 416 |
case EXPONENTIAL: |
| 417 |
return getOperator("upDownUCEDMeanHeights"); |
| 418 |
} |
| 419 |
break; |
| 420 |
|
| 421 |
case AUTOCORRELATED: |
| 422 |
throw new UnsupportedOperationException("Autocorrelated clock not implemented yet"); |
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
default: |
| 427 |
throw new IllegalArgumentException("Unknown clock model"); |
| 428 |
} |
| 429 |
return null; |
| 430 |
} |
| 431 |
|
| 432 |
@Override |
| 433 |
public List<Operator> selectOperators(List<Operator> operators) { |
| 434 |
List<Operator> ops = new ArrayList<Operator>(); |
| 435 |
|
| 436 |
if (options.hasData()) { |
| 437 |
Operator op; |
| 438 |
if (getDataType().getType() == DataType.MICRO_SAT) { |
| 439 |
if (getClockType() == ClockType.STRICT_CLOCK) { |
| 440 |
op = getOperator("microsatUpDownRateHeights"); |
| 441 |
ops.add(op); |
| 442 |
} else { |
| 443 |
throw new UnsupportedOperationException("Microsatellite only supports strict clock model"); |
| 444 |
} |
| 445 |
|
| 446 |
} else { |
| 447 |
|
| 448 |
Operator rateOperator = getOperator("clock.rate"); |
| 449 |
switch (clockType) { |
| 450 |
case STRICT_CLOCK: |
| 451 |
ops.add(rateOperator); |
| 452 |
addUpDownOperator(ops, rateOperator); |
| 453 |
break; |
| 454 |
|
| 455 |
case RANDOM_LOCAL_CLOCK: |
| 456 |
ops.add(rateOperator); |
| 457 |
ops.add(getOperator(ClockType.LOCAL_CLOCK + ".relativeRates")); |
| 458 |
ops.add(getOperator(ClockType.LOCAL_CLOCK + ".changes")); |
| 459 |
break; |
| 460 |
|
| 461 |
case FIXED_LOCAL_CLOCK: |
| 462 |
ops.add(rateOperator); |
| 463 |
for (Taxa taxonSet : options.taxonSets) { |
| 464 |
if (options.taxonSetsMono.get(taxonSet)) { |
| 465 |
ops.add(getOperator(taxonSet.getId() + ".rate")); |
| 466 |
} |
| 467 |
} |
| 468 |
break; |
| 469 |
|
| 470 |
case UNCORRELATED: |
| 471 |
switch (clockDistributionType) { |
| 472 |
case LOGNORMAL: |
| 473 |
ops.add(rateOperator = getOperator(ClockType.UCLD_MEAN)); |
| 474 |
ops.add(getOperator(ClockType.UCLD_STDEV)); |
| 475 |
addUpDownOperator(ops, rateOperator); |
| 476 |
break; |
| 477 |
case GAMMA: |
| 478 |
ops.add(rateOperator = getOperator(ClockType.UCGD_MEAN)); |
| 479 |
ops.add(getOperator(ClockType.UCGD_SHAPE)); |
| 480 |
addUpDownOperator(ops, rateOperator); |
| 481 |
break; |
| 482 |
case CAUCHY: |
| 483 |
|
| 484 |
break; |
| 485 |
case EXPONENTIAL: |
| 486 |
ops.add(rateOperator = getOperator(ClockType.UCED_MEAN)); |
| 487 |
addUpDownOperator(ops, rateOperator); |
| 488 |
break; |
| 489 |
case MODEL_AVERAGING: |
| 490 |
ops.add(getOperator(ClockType.UCLD_MEAN)); |
| 491 |
ops.add(getOperator(ClockType.UCLD_STDEV)); |
| 492 |
ops.add(getOperator(ClockType.UCGD_MEAN)); |
| 493 |
ops.add(getOperator(ClockType.UCGD_SHAPE)); |
| 494 |
ops.add(getOperator(ClockType.UCED_MEAN)); |
| 495 |
|
| 496 |
if (!getOperator(ClockType.UCLD_MEAN).isParameterFixed()) { |
| 497 |
ops.add(getOperator("upDownUCLDMeanHeights")); |
| 498 |
} |
| 499 |
if (!getOperator(ClockType.UCGD_MEAN).isParameterFixed()) { |
| 500 |
ops.add(getOperator("upDownUCGDMeanHeights")); |
| 501 |
} |
| 502 |
if (!getOperator(ClockType.UCED_MEAN).isParameterFixed()) { |
| 503 |
ops.add(getOperator("upDownUCEDMeanHeights")); |
| 504 |
} |
| 505 |
|
| 506 |
ops.add(getOperator("uniformBranchRateDistributionIndex")); |
| 507 |
break; |
| 508 |
} |
| 509 |
|
| 510 |
if (isContinuousQuantile()) { |
| 511 |
if (!options.useClassicOperatorsAndPriors()) { |
| 512 |
ops.add(getOperator("rwBranchRateQuantiles")); |
| 513 |
} else { |
| 514 |
ops.add(getOperator("uniformBranchRateQuantiles")); |
| 515 |
} |
| 516 |
} else { |
| 517 |
ops.add(getOperator("swapBranchRateCategories")); |
| 518 |
ops.add(getOperator("uniformBranchRateCategories")); |
| 519 |
} |
| 520 |
break; |
| 521 |
|
| 522 |
case AUTOCORRELATED: |
| 523 |
throw new UnsupportedOperationException("Autocorrelated clock not implemented yet"); |
| 524 |
|
| 525 |
|
| 526 |
default: |
| 527 |
throw new IllegalArgumentException("Unknown clock model"); |
| 528 |
} |
| 529 |
|
| 530 |
} |
| 531 |
} |
| 532 |
|
| 533 |
Parameter allMuNus = getParameter(options.useNuRelativeRates() ? "allNus" : "allMus"); |
| 534 |
|
| 535 |
if (allMuNus.getSubParameters().size() > 1) { |
| 536 |
ops.add(getOperator(options.useNuRelativeRates() ? "deltaNus" : "deltaMus")); |
| 537 |
} |
| 538 |
|
| 539 |
if (options.operatorSetType != OperatorSetType.CUSTOM) { |
| 540 |
|
| 541 |
for (Operator op : ops) { |
| 542 |
if (op.getParameter1().isAdaptiveMultivariateCompatible) { |
| 543 |
op.setUsed(options.operatorSetType != OperatorSetType.ADAPTIVE_MULTIVARIATE); |
| 544 |
} |
| 545 |
} |
| 546 |
} |
| 547 |
|
| 548 |
operators.addAll(ops); |
| 549 |
|
| 550 |
return ops; |
| 551 |
} |
| 552 |
|
| 553 |
private void addUpDownOperator(List<Operator> ops, Operator rateOperator) { |
| 554 |
if (!rateOperator.isParameterFixed()) { |
| 555 |
Operator upDownOperator = getUpDownOperator(); |
| 556 |
|
| 557 |
upDownOperator.setParameter1( |
| 558 |
getPartitionTreeModel().getParameter("treeModel.allInternalNodeHeights")); |
| 559 |
ops.add(upDownOperator); |
| 560 |
} else { |
| 561 |
ops.add(getPartitionTreeModel().getOperator("treeModel.allInternalNodeHeights")); |
| 562 |
} |
| 563 |
} |
| 564 |
|
| 565 |
|
| 566 |
public void setClockType(ClockType clockType) { |
| 567 |
this.clockType = clockType; |
| 568 |
} |
| 569 |
|
| 570 |
public ClockType getClockType() { |
| 571 |
return clockType; |
| 572 |
} |
| 573 |
|
| 574 |
public ClockDistributionType getClockDistributionType() { |
| 575 |
return clockDistributionType; |
| 576 |
} |
| 577 |
|
| 578 |
public void setClockDistributionType(final ClockDistributionType clockDistributionType) { |
| 579 |
this.clockDistributionType = clockDistributionType; |
| 580 |
} |
| 581 |
|
| 582 |
public boolean performModelAveraging() { |
| 583 |
return performModelAveraging; |
| 584 |
} |
| 585 |
|
| 586 |
public void setPerformModelAveraging(boolean performModelAveraging) { |
| 587 |
this.performModelAveraging = performModelAveraging; |
| 588 |
} |
| 589 |
|
| 590 |
public boolean isContinuousQuantile() { |
| 591 |
return continuousQuantile; |
| 592 |
} |
| 593 |
|
| 594 |
public void setContinuousQuantile(boolean continuousQuantile) { |
| 595 |
this.continuousQuantile = continuousQuantile; |
| 596 |
} |
| 597 |
|
| 598 |
public String getPrefix() { |
| 599 |
String prefix = ""; |
| 600 |
if (options.getPartitionClockModels().size() > 1) { |
| 601 |
|
| 602 |
prefix += getName() + "."; |
| 603 |
} |
| 604 |
return prefix; |
| 605 |
} |
| 606 |
|
| 607 |
public PartitionTreeModel getPartitionTreeModel() { |
| 608 |
return treeModel; |
| 609 |
} |
| 610 |
|
| 611 |
public void setPartitionTreeModel(PartitionTreeModel treeModel) { |
| 612 |
options.clearDataPartitionCaches(); |
| 613 |
this.treeModel = treeModel; |
| 614 |
} |
| 615 |
|
| 616 |
public void copyFrom(PartitionClockModel source) { |
| 617 |
clockType = source.clockType; |
| 618 |
clockDistributionType = source.clockDistributionType; |
| 619 |
continuousQuantile = source.continuousQuantile; |
| 620 |
performModelAveraging = source.performModelAveraging; |
| 621 |
} |
| 622 |
} |