Skip to content

Commit

Permalink
generate distribution likelihoods for mixed effects clock model
Browse files Browse the repository at this point in the history
  • Loading branch information
GuyBaele committed May 14, 2024
1 parent 8169c40 commit f84235f
Showing 1 changed file with 121 additions and 3 deletions.
124 changes: 121 additions & 3 deletions src/dr/app/beauti/generator/ClockModelGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
import dr.inference.model.CompoundParameter;
import dr.inference.model.StatisticParser;
import dr.inferencexml.SignTransformParser;
import dr.inferencexml.distribution.DistributionLikelihoodParser;
import dr.inferencexml.distribution.MixedDistributionLikelihoodParser;
import dr.inferencexml.distribution.*;
import dr.inferencexml.distribution.shrinkage.BayesianBridgeDistributionModelParser;
import dr.inferencexml.hmc.GradientWrtIncrementParser;
import dr.inferencexml.operators.shrinkage.BayesianBridgeShrinkageOperatorParser;
Expand All @@ -59,7 +58,6 @@
import dr.inference.distribution.ExponentialDistributionModel;
import dr.inference.distribution.GammaDistributionModel;
import dr.inference.model.ParameterParser;
import dr.inferencexml.distribution.LogNormalDistributionModelParser;
import dr.inferencexml.model.CompoundParameterParser;
import dr.inferencexml.model.SumStatisticParser;
import dr.util.Attribute;
Expand Down Expand Up @@ -640,6 +638,126 @@ public void writeBranchRatesModel(PartitionClockModel clockModel, XMLWriter writ
writer.writeIDref(DefaultTreeModel.TREE_MODEL, treePrefix + DefaultTreeModel.TREE_MODEL);

writer.writeCloseTag(tag);

tag = DistributionLikelihood.DISTRIBUTION_LIKELIHOOD;

// branch rates prior
writer.writeOpenTag(tag,
new Attribute[]{
new Attribute.Default<String>(XMLParser.ID, "ratesPrior")
}
);
writer.writeOpenTag(DistributionLikelihoodParser.DATA);
writer.writeIDref(PARAMETER, ClockType.ME_CLOCK_LOCATION);
writer.writeCloseTag(DistributionLikelihoodParser.DATA);
writer.writeOpenTag(DistributionLikelihoodParser.DISTRIBUTION);
writer.writeOpenTag(LogNormalDistributionModelParser.LOGNORMAL_DISTRIBUTION_MODEL,
new Attribute[]{
new Attribute.Default<String>(LogNormalDistributionModelParser.MEAN_IN_REAL_SPACE, "true")
}
);
writer.writeOpenTag(LogNormalDistributionModelParser.MEAN);
writer.writeTag(PARAMETER,
new Attribute[]{
new Attribute.Default<String>(ParameterParser.VALUE, "1.0"),
new Attribute.Default<String>(ParameterParser.LOWER, "0.0")
}, true);
writer.writeCloseTag(LogNormalDistributionModelParser.MEAN);
writer.writeOpenTag(LogNormalDistributionModelParser.STDEV);
writer.writeTag(PARAMETER,
new Attribute[]{
new Attribute.Default<String>(ParameterParser.VALUE, "1.0"),
new Attribute.Default<String>(ParameterParser.LOWER, "0.0")
}, true);
writer.writeCloseTag(LogNormalDistributionModelParser.STDEV);
writer.writeCloseTag(LogNormalDistributionModelParser.LOGNORMAL_DISTRIBUTION_MODEL);
writer.writeCloseTag(DistributionLikelihoodParser.DISTRIBUTION);
writer.writeCloseTag(tag);

// branch rates scale prior
writer.writeOpenTag(tag,
new Attribute[]{
new Attribute.Default<String>(XMLParser.ID, "scalePrior")
}
);
writer.writeOpenTag(DistributionLikelihoodParser.DATA);
writer.writeIDref(PARAMETER, ClockType.ME_CLOCK_SCALE);
writer.writeCloseTag(DistributionLikelihoodParser.DATA);
writer.writeOpenTag(ExponentialDistributionModel.EXPONENTIAL_DISTRIBUTION_MODEL);
writer.writeOpenTag(ExponentialDistributionModelParser.MEAN);
writer.writeTag(PARAMETER,
new Attribute[]{
new Attribute.Default<String>(ParameterParser.VALUE, "1.0"),
new Attribute.Default<String>(ParameterParser.LOWER, "0.0")
}, true);
writer.writeCloseTag(ExponentialDistributionModelParser.MEAN);
writer.writeCloseTag(ExponentialDistributionModel.EXPONENTIAL_DISTRIBUTION_MODEL);
writer.writeCloseTag(DistributionLikelihoodParser.DISTRIBUTION);
writer.writeCloseTag(tag);

// intercept prior
writer.writeOpenTag(tag,
new Attribute[]{
new Attribute.Default<String>(XMLParser.ID, "interceptPrior")
}
);
writer.writeOpenTag(DistributionLikelihoodParser.DATA);
writer.writeIDref(PARAMETER, BranchSpecificFixedEffectsParser.INTERCEPT);
writer.writeCloseTag(DistributionLikelihoodParser.DATA);
writer.writeOpenTag(DistributionLikelihoodParser.DISTRIBUTION);
writer.writeOpenTag(NormalDistributionModelParser.NORMAL_DISTRIBUTION_MODEL);
writer.writeOpenTag(LogNormalDistributionModelParser.MEAN);
writer.writeTag(PARAMETER,
new Attribute[]{
new Attribute.Default<String>(ParameterParser.VALUE, "0.0"),
new Attribute.Default<String>(ParameterParser.LOWER, "0.0")
}, true);
writer.writeCloseTag(LogNormalDistributionModelParser.MEAN);
writer.writeOpenTag(LogNormalDistributionModelParser.STDEV);
writer.writeTag(PARAMETER,
new Attribute[]{
new Attribute.Default<String>(ParameterParser.VALUE, "100.0"),
new Attribute.Default<String>(ParameterParser.LOWER, "0.0")
}, true);
writer.writeCloseTag(LogNormalDistributionModelParser.STDEV);
writer.writeCloseTag(NormalDistributionModelParser.NORMAL_DISTRIBUTION_MODEL);
writer.writeCloseTag(DistributionLikelihoodParser.DISTRIBUTION);
writer.writeCloseTag(tag);

// fixed effects priors
counter = 1;
for (Taxa taxonSet : options.taxonSets) {
writer.writeOpenTag(tag,
new Attribute[]{
new Attribute.Default<String>(XMLParser.ID, BranchSpecificFixedEffectsParser.FIXED_EFFECTS + "Likelihood" + counter)
}
);
writer.writeOpenTag(DistributionLikelihoodParser.DATA);
writer.writeIDref(PARAMETER, BranchSpecificFixedEffectsParser.COEFFICIENT + counter);
writer.writeCloseTag(DistributionLikelihoodParser.DATA);
writer.writeOpenTag(DistributionLikelihoodParser.DISTRIBUTION);
writer.writeOpenTag(NormalDistributionModelParser.NORMAL_DISTRIBUTION_MODEL);
writer.writeOpenTag(LogNormalDistributionModelParser.MEAN);
writer.writeTag(PARAMETER,
new Attribute[]{
new Attribute.Default<String>(ParameterParser.VALUE, "0.0"),
new Attribute.Default<String>(ParameterParser.LOWER, "0.0")
}, true);
writer.writeCloseTag(LogNormalDistributionModelParser.MEAN);
writer.writeOpenTag(LogNormalDistributionModelParser.STDEV);
writer.writeTag(PARAMETER,
new Attribute[]{
new Attribute.Default<String>(XMLParser.ID, "betweenGroupStd" + counter),
new Attribute.Default<String>(ParameterParser.VALUE, "100.0"),
new Attribute.Default<String>(ParameterParser.LOWER, "0.0")
}, true);
writer.writeCloseTag(LogNormalDistributionModelParser.STDEV);
writer.writeCloseTag(NormalDistributionModelParser.NORMAL_DISTRIBUTION_MODEL);
writer.writeCloseTag(DistributionLikelihoodParser.DISTRIBUTION);
writer.writeCloseTag(tag);
counter++;
}

break;

default:
Expand Down

0 comments on commit f84235f

Please sign in to comment.