Skip to content

Commit

Permalink
Add rates prior for UCLN, and TODO for logging LinguaPhylo/linguaPhyl…
Browse files Browse the repository at this point in the history
  • Loading branch information
walterxie committed Oct 4, 2024
1 parent 3e3c1ef commit 17d7c93
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ public static void constructTreeAndBranchRate(PhyloCTMC phyloCTMC, GenericTreeLi
if (generator instanceof UCLN ucln) {

UCRelaxedClockModel relaxedClockModel = (UCRelaxedClockModel) context.getBEASTObject(generator);
relaxedClockModel.setID(branchRates.getCanonicalId());

treeLikelihood.setInputValue("branchRateModel", relaxedClockModel);

if (skipBranchOperators == false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import beast.base.core.BEASTInterface;
import beast.base.evolution.branchratemodel.UCRelaxedClockModel;
import beast.base.inference.distribution.LogNormalDistributionModel;
import beast.base.inference.distribution.Prior;
import beast.base.inference.parameter.RealParameter;
import lphy.base.distribution.UCLN;
import lphy.base.evolution.tree.TimeTree;
import lphy.core.model.GraphicalModelNode;
import lphy.core.model.Value;
import lphybeast.BEASTContext;
import lphybeast.GeneratorToBEAST;
Expand All @@ -27,9 +29,21 @@ public UCRelaxedClockModel generatorToBEAST(UCLN ucln, BEASTInterface value, BEA

if (value instanceof RealParameter rates) {
ucRelaxedClockModel.setInputValue("rates", rates);

// rates prior, which is same LogNormal as UCLN
Prior ratesPrior = BEASTContext.createPrior(logNormDist, rates);
context.addBEASTObject(ratesPrior, ucln);

} else throw new IllegalArgumentException("Value sampled from LPhy UCLN should be mapped to RealParameter ! " + value);

ucRelaxedClockModel.initAndValidate();
GraphicalModelNode branchRates = context.getGraphicalModelNode(value);
// in case to duplicate with RandomValue id also called "branchRates"
ucRelaxedClockModel.setID(branchRates.getUniqueId() + ".model");

//TODO rm rates from log, replaced by
// <log id="ORCRatesStat" spec="beast.base.evolution.RateStatistic" branchratemodel="@OptimisedRelaxedClock" tree="@Tree"/>

return ucRelaxedClockModel;
}

Expand Down

0 comments on commit 17d7c93

Please sign in to comment.