Skip to content

Use proper, wide log-normal default priors in BEAUti - #208

Merged
walterxie merged 1 commit into
masterfrom
fix/proper-template-priors
Nov 6, 2026
Merged

walterxie merged 1 commit into
masterfrom
fix/proper-template-priors

Conversation

@alexeid

@alexeid alexeid commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

This PR makes all of BEAUti's default priors proper, and wide enough for any time unit. The default is LogNormal(M = 0, S = 8) in log space: median 1, 95% from 1.6×10⁻⁷ to 6.4×10⁶. BEAST 2.7's BEAUti gets the same defaults (CompEvol/BeastFX#111).

Default priors

  • Gamma(0.01, 100) → LogNormal(0, 8), in all 12 places: clock rate (2), relaxed-clock mean rate, mutation rate (2), Yule birth rate (2), calibrated-Yule birth rate, birth–death birth rate, constant and exponential coalescent population sizes, and EBSP populationMean. Gamma(0.01, 100) is proper, but about half its mass lies below 10⁻²⁸. In practice it's a 1/x prior with an arbitrary cutoff far below any meaningful value.
  • The GTR rate priors, Gamma(0.05, 10), are unchanged.
  • Bayesian skyline: the first population size had an improper Jeffreys (1/x) prior (jeffreys="true" on unbounded popSizes). It now has an exponential prior with an estimated mean (bPopSizesInitialMean), which has a LogNormal(0, 8) prior, a scale operator and a trace-log column.

Hyperprior

Ticking "estimate" on a prior's own parameter added a LogUniform hyperprior with a scale operator, whatever the parameter's domain. For a Real-domain parameter such as a LogNormal's M, that's invalid whenever M ≤ 0. With M = 0, which is now the default, BEAUti wrote XML that failed to parse ("Tensor param is not valid"). Now:

  • A non-negative parameter (PositiveReal, NonNegativeReal, UnitInterval) gets LogNormal(0, 8) with a scale operator. A continuous parameter is exactly 0 with probability 0, so these are in practice positive.
  • A Real-domain parameter gets Normal(0, 8) with a random-walk operator.

Tests

  • SimpleTreePriorTest is updated for the skyline's new parameter, and HyperPriorTest for the new hyperprior distributions.
  • All beast-fx tests pass: 52 run, 0 failures, 4 skipped, plus the slow ones (BeautiCLITest, BeautiDivergenceDatingTest, BeautiRateTutorialTest, BeautiStarBeastTest).

Independent of #199 and #201. It touches the same template files as #201, which changes only the subtree-slide size, but different lines.

Replace the Gamma(0.01, 100) default priors in the templates with
LogNormal(M=0, S=8) in log space (median 1, 95% from 1.6e-7 to 6.4e6):
the clock rate (strict and the relaxed-clock mean rate), the mutation
rate, the Yule, calibrated-Yule and birth-death birth rates, the
constant and exponential coalescent population sizes, and the EBSP
populationMean. Gamma(0.01, 100) has about half its mass below 1e-28,
so it acts like a 1/x prior with an arbitrary cutoff far below any
meaningful value. The GTR rate priors, Gamma(0.05, 10), are unchanged.

The Bayesian skyline template put an improper Jeffreys (1/x) prior on
the first population size. The first population size now has an
exponential prior with an estimated mean (bPopSizesInitialMean) that
has a LogNormal(0, 8) prior, a scale operator and a trace-log column.

BEAUti's hyperprior, added when a prior's own parameter is estimated,
was always LogUniform with a scale operator. That is invalid for a
parameter that may be negative, such as a LogNormal's M; with the new
defaults M = 0, so estimating it made BEAUti write XML that did not
parse. A non-negative parameter now gets a LogNormal(0, 8) hyperprior
with a scale operator, and a Real-domain one a Normal(0, 8) hyperprior
with a random-walk operator.

Update SimpleTreePriorTest for the skyline's new parameter and
HyperPriorTest for the hyperprior distributions. The beast-fx tests
pass, slow ones included.
@walterxie
walterxie merged commit aed9e4f into master Nov 6, 2026
1 check passed
@walterxie
walterxie deleted the fix/proper-template-priors branch November 6, 2026 01:37
walterxie added a commit that referenced this pull request Nov 6, 2026
…odel input

Review requests from alexeid on #204:

1. Proper priors, in both versions (BEAST 3 examples and the BEAST 2 files
   in legacy/), as in #199 and BEAUti's defaults (#208): LogNormal(0, 8) for
   rates and sizes, LogNormal(1, 1.25) for kappa. Replaces the improper flat,
   OneOnX and Uniform(0, Infinity) priors, and the LogUniform stand-ins.
2. BactrianSubtreeSlide starts at its tuned size (BEAST 3 runs, acceptance
   about 0.3) instead of 1.0. The sizes are kept rather than BEAUti's new
   0.01 (#201); each file's comment says why.
4. SequenceSimulator / SimulatedAlignment: branchRateModel takes the
   BranchRateModel interface, so legacy clocks are accepted too.

Also:
- Move the BEAST 2 seqgen files to beast.fx/examples/legacy/, next to their
  BEAST 3 conversions (they need beast-fx classes).
- legacy/README.md: the legacy/ files are BEAST 2 XML, not converted, and
  must still run in BEAST 2.8.x with the old (deprecated) classes.
- Test that the legacy examples still parse: a new method in beast-base's
  ExampleXmlParsingTest, and a beast-fx ExampleXmlParsingTest for the
  beast-fx examples and their legacy sources.
- Update MIGRATION-REPORT-batch2.md; add TODO-migrate-legacy-xmls-batch2.md
  for the open requests (3: posterior comparison with 2.7.9; 5: release
  scripts end to end).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants