Search in sources :

Example 1 with VariableDemographicModel

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

the class OrnsteinUhlenbeckPriorLikelihoodParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Parameter mean = getParam(xo, MEAN);
    Parameter sigma = getParam(xo, SIGMA);
    Parameter lambda = getParam(xo, LAMBDA);
    final boolean logSpace = xo.getAttribute(LOG_SPACE, false);
    final boolean normalize = xo.getAttribute(NORMALIZE, false);
    VariableDemographicModel m = (VariableDemographicModel) xo.getChild(VariableDemographicModel.class);
    if (m != null) {
        ParametricDistributionModel popMeanPrior = (ParametricDistributionModel) xo.getChild(ParametricDistributionModel.class);
        return new OrnsteinUhlenbeckPriorLikelihood(mean, sigma, lambda, m, logSpace, normalize, popMeanPrior);
    }
    final XMLObject cxo1 = xo.getChild(DATA);
    Parameter dataParameter = (Parameter) cxo1.getChild(Parameter.class);
    final XMLObject cxo2 = xo.getChild(TIMES);
    final Parameter timesParameter = (Parameter) cxo2.getChild(Parameter.class);
    return new OrnsteinUhlenbeckPriorLikelihood(mean, sigma, lambda, dataParameter, timesParameter, logSpace, normalize);
}
Also used : OrnsteinUhlenbeckPriorLikelihood(dr.evomodel.coalescent.OrnsteinUhlenbeckPriorLikelihood) VariableDemographicModel(dr.evomodel.coalescent.VariableDemographicModel) ParametricDistributionModel(dr.inference.distribution.ParametricDistributionModel) Parameter(dr.inference.model.Parameter)

Example 2 with VariableDemographicModel

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

the class VariableDemographicModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    XMLObject cxo = xo.getChild(POPULATION_SIZES);
    Parameter popParam = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(INDICATOR_PARAMETER);
    Parameter indicatorParam = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(POPULATION_TREES);
    final int nc = cxo.getChildCount();
    TreeModel[] treeModels = new TreeModel[nc];
    double[] populationFactor = new double[nc];
    for (int k = 0; k < treeModels.length; ++k) {
        final XMLObject child = (XMLObject) cxo.getChild(k);
        populationFactor[k] = child.hasAttribute(PLOIDY) ? child.getDoubleAttribute(PLOIDY) : 1.0;
        treeModels[k] = (TreeModel) child.getChild(TreeModel.class);
    }
    VariableDemographicModel.Type type = VariableDemographicModel.Type.STEPWISE;
    if (xo.hasAttribute(TYPE)) {
        final String s = xo.getStringAttribute(TYPE);
        if (s.equalsIgnoreCase(VariableDemographicModel.Type.STEPWISE.toString())) {
            type = VariableDemographicModel.Type.STEPWISE;
        } else if (s.equalsIgnoreCase(VariableDemographicModel.Type.LINEAR.toString())) {
            type = VariableDemographicModel.Type.LINEAR;
        } else if (s.equalsIgnoreCase(VariableDemographicModel.Type.EXPONENTIAL.toString())) {
            type = VariableDemographicModel.Type.EXPONENTIAL;
        } else {
            throw new XMLParseException("Unknown Bayesian Skyline type: " + s);
        }
    }
    final boolean logSpace = xo.getAttribute(LOG_SPACE, false) || type == VariableDemographicModel.Type.EXPONENTIAL;
    final boolean useMid = xo.getAttribute(USE_MIDPOINTS, false);
    Logger.getLogger("dr.evomodel").info("Variable demographic: " + type.toString() + " control points");
    return new VariableDemographicModel(treeModels, populationFactor, popParam, indicatorParam, type, logSpace, useMid);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) VariableDemographicModel(dr.evomodel.coalescent.VariableDemographicModel) Parameter(dr.inference.model.Parameter)

Example 3 with VariableDemographicModel

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

the class BMPriorLikelihoodParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    // Parameter mean = getParam(xo, MEAN);
    Parameter sigma = getParam(xo, SIGMA);
    //  Parameter lambda = getParam(xo, LAMBDA);
    final boolean logSpace = xo.getAttribute(LOG_SPACE, false);
    //   final boolean normalize = xo.getAttribute(NORMALIZE, false);
    VariableDemographicModel m = (VariableDemographicModel) xo.getChild(VariableDemographicModel.class);
    ParametricDistributionModel popMeanPrior = (ParametricDistributionModel) xo.getChild(ParametricDistributionModel.class);
    return new BMPriorLikelihood(sigma, m, logSpace, popMeanPrior);
}
Also used : VariableDemographicModel(dr.evomodel.coalescent.VariableDemographicModel) ParametricDistributionModel(dr.inference.distribution.ParametricDistributionModel) Parameter(dr.inference.model.Parameter) BMPriorLikelihood(dr.evomodel.coalescent.BMPriorLikelihood)

Aggregations

VariableDemographicModel (dr.evomodel.coalescent.VariableDemographicModel)3 Parameter (dr.inference.model.Parameter)3 ParametricDistributionModel (dr.inference.distribution.ParametricDistributionModel)2 BMPriorLikelihood (dr.evomodel.coalescent.BMPriorLikelihood)1 OrnsteinUhlenbeckPriorLikelihood (dr.evomodel.coalescent.OrnsteinUhlenbeckPriorLikelihood)1 TreeModel (dr.evomodel.tree.TreeModel)1