From 17d7c93d3c8dbf7b78408d2040ad193217201ab0 Mon Sep 17 00:00:00 2001 From: Walter Date: Fri, 4 Oct 2024 15:11:26 +1300 Subject: [PATCH] Add rates prior for UCLN, and TODO for logging LinguaPhylo/linguaPhylo#488 --- .../tobeast/generators/PhyloCTMCToBEAST.java | 2 -- .../generators/UCLNRelaxedClockToBEAST.java | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lphybeast/src/main/java/lphybeast/tobeast/generators/PhyloCTMCToBEAST.java b/lphybeast/src/main/java/lphybeast/tobeast/generators/PhyloCTMCToBEAST.java index 34bbc13..9b7622a 100644 --- a/lphybeast/src/main/java/lphybeast/tobeast/generators/PhyloCTMCToBEAST.java +++ b/lphybeast/src/main/java/lphybeast/tobeast/generators/PhyloCTMCToBEAST.java @@ -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) { diff --git a/lphybeast/src/main/java/lphybeast/tobeast/generators/UCLNRelaxedClockToBEAST.java b/lphybeast/src/main/java/lphybeast/tobeast/generators/UCLNRelaxedClockToBEAST.java index c6b0691..a5b4aa9 100644 --- a/lphybeast/src/main/java/lphybeast/tobeast/generators/UCLNRelaxedClockToBEAST.java +++ b/lphybeast/src/main/java/lphybeast/tobeast/generators/UCLNRelaxedClockToBEAST.java @@ -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; @@ -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 + // + return ucRelaxedClockModel; }