Search in sources :

Example 1 with BayesianSkylineLikelihood

use of dr.evomodel.coalescent.BayesianSkylineLikelihood in project beast-mcmc by beast-dev.

the class BayesianSkylineGibbsOperatorParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
    final double lowerBound = xo.getAttribute(LOWER, 0.0);
    final double upperBound = xo.getAttribute(UPPER, Double.MAX_VALUE);
    final boolean jeffreysPrior = xo.getAttribute(JEFFREYS, true);
    boolean exponentialMarkovPrior = xo.getAttribute(EXPONENTIALMARKOV, false);
    double shape = xo.getAttribute(SHAPE, 1.0);
    boolean reverse = xo.getAttribute(REVERSE, false);
    int iterations = xo.getAttribute(ITERATIONS, 1);
    BayesianSkylineLikelihood bayesianSkylineLikelihood = (BayesianSkylineLikelihood) xo.getChild(BayesianSkylineLikelihood.class);
    // This is the parameter on which this operator acts
    Parameter paramPops = (Parameter) xo.getChild(Parameter.class);
    Parameter paramGroups = bayesianSkylineLikelihood.getGroupSizeParameter();
    final int type = bayesianSkylineLikelihood.getType();
    if (type != BayesianSkylineLikelihood.STEPWISE_TYPE) {
        throw new XMLParseException("Need stepwise control points (set 'linear=\"false\"' in skyline Gibbs operator)");
    }
    return new BayesianSkylineGibbsOperator(bayesianSkylineLikelihood, paramPops, paramGroups, type, weight, lowerBound, upperBound, jeffreysPrior, exponentialMarkovPrior, shape, reverse, iterations);
}
Also used : BayesianSkylineGibbsOperator(dr.evomodel.coalescent.operators.BayesianSkylineGibbsOperator) Parameter(dr.inference.model.Parameter) BayesianSkylineLikelihood(dr.evomodel.coalescent.BayesianSkylineLikelihood)

Example 2 with BayesianSkylineLikelihood

use of dr.evomodel.coalescent.BayesianSkylineLikelihood in project beast-mcmc by beast-dev.

the class BayesianSkylinePopSizeStatisticParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    double time = xo.getDoubleAttribute(TIME);
    BayesianSkylineLikelihood bsl = (BayesianSkylineLikelihood) xo.getChild(BayesianSkylineLikelihood.class);
    return new BayesianSkylinePopSizeStatistic(time, bsl);
}
Also used : BayesianSkylinePopSizeStatistic(dr.evomodel.coalescent.BayesianSkylinePopSizeStatistic) BayesianSkylineLikelihood(dr.evomodel.coalescent.BayesianSkylineLikelihood)

Example 3 with BayesianSkylineLikelihood

use of dr.evomodel.coalescent.BayesianSkylineLikelihood in project beast-mcmc by beast-dev.

the class BayesianSkylineLikelihoodParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    XMLObject cxo = xo.getChild(POPULATION_SIZES);
    Parameter param = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(GROUP_SIZES);
    Parameter param2 = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(CoalescentLikelihoodParser.POPULATION_TREE);
    TreeModel treeModel = (TreeModel) cxo.getChild(TreeModel.class);
    int type = BayesianSkylineLikelihood.LINEAR_TYPE;
    String typeName = LINEAR;
    if (xo.hasAttribute(LINEAR) && !xo.getBooleanAttribute(LINEAR)) {
        type = BayesianSkylineLikelihood.STEPWISE_TYPE;
        typeName = STEPWISE;
    }
    if (xo.hasAttribute(TYPE)) {
        if (xo.getStringAttribute(TYPE).equalsIgnoreCase(STEPWISE)) {
            type = BayesianSkylineLikelihood.STEPWISE_TYPE;
            typeName = STEPWISE;
        } else if (xo.getStringAttribute(TYPE).equalsIgnoreCase(LINEAR)) {
            type = BayesianSkylineLikelihood.LINEAR_TYPE;
            typeName = LINEAR;
        } else if (xo.getStringAttribute(TYPE).equalsIgnoreCase(EXPONENTIAL)) {
            type = BayesianSkylineLikelihood.EXPONENTIAL_TYPE;
            typeName = EXPONENTIAL;
        } else
            throw new XMLParseException("Unknown Bayesian Skyline type: " + xo.getStringAttribute(TYPE));
    }
    if (param2.getDimension() > (treeModel.getExternalNodeCount() - 1)) {
        throw new XMLParseException("There are more groups (" + param2.getDimension() + ") than coalescent nodes in the tree (" + (treeModel.getExternalNodeCount() - 1) + ").");
    }
    Logger.getLogger("dr.evomodel").info("Bayesian skyline plot: " + param.getDimension() + " " + typeName + " control points");
    return new BayesianSkylineLikelihood(treeModel, param, param2, type);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) Parameter(dr.inference.model.Parameter) BayesianSkylineLikelihood(dr.evomodel.coalescent.BayesianSkylineLikelihood)

Aggregations

BayesianSkylineLikelihood (dr.evomodel.coalescent.BayesianSkylineLikelihood)3 Parameter (dr.inference.model.Parameter)2 BayesianSkylinePopSizeStatistic (dr.evomodel.coalescent.BayesianSkylinePopSizeStatistic)1 BayesianSkylineGibbsOperator (dr.evomodel.coalescent.operators.BayesianSkylineGibbsOperator)1 TreeModel (dr.evomodel.tree.TreeModel)1