Search in sources :

Example 1 with ContinuousBranchValueProvider

use of dr.evomodel.branchratemodel.ContinuousBranchValueProvider in project beast-mcmc by beast-dev.

the class BranchSpecificFixedEffectsParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    // Parameter allocationParameter = (Parameter) xo.getElementFirstChild(ALLOCATION);
    TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
    Parameter coefficients = (Parameter) xo.getChild(Parameter.class);
    boolean includeIntercept = xo.getAttribute(INCLUDE_INTERCEPT, true);
    List<CountableBranchCategoryProvider> categories = new ArrayList<CountableBranchCategoryProvider>();
    for (XMLObject xoc : xo.getAllChildren(CATEGORY)) {
        CountableBranchCategoryProvider.CladeBranchCategoryModel cladeModel = new CountableBranchCategoryProvider.CladeBranchCategoryModel(treeModel, new Parameter.Default(treeModel.getNodeCount() - 1));
        parseCladeCategories(xoc, cladeModel);
        categories.add(cladeModel);
    }
    List<ContinuousBranchValueProvider> values = new ArrayList<ContinuousBranchValueProvider>();
    boolean timeDependentEffect = xo.getAttribute(TIME_DEPENDENT_EFFECT, false);
    if (timeDependentEffect) {
        values.add(new ContinuousBranchValueProvider.MidPoint());
    }
    List<BranchRates> branchRates = new ArrayList<BranchRates>();
    for (int i = 0; i < xo.getChildCount(); ++i) {
        Object obj = xo.getChild(i);
        if (obj instanceof BranchRates) {
            branchRates.add((BranchRates) obj);
        }
    }
    Transform transform = (Transform) xo.getChild(Transform.class);
    BranchSpecificFixedEffects.Default fixedEffects = new BranchSpecificFixedEffects.Default(xo.getId(), categories, values, branchRates, coefficients, includeIntercept);
    double[][] designMatrix = fixedEffects.getDesignMatrix(treeModel);
    Logger.getLogger("dr.evomodel").info("Using a fixed effects model with initial design matrix:\n" + annotateDesignMatrix(designMatrix, treeModel));
    if (transform != null) {
        return new BranchSpecificFixedEffects.Transformed(fixedEffects, transform);
    } else {
        return fixedEffects;
    }
}
Also used : ContinuousBranchValueProvider(dr.evomodel.branchratemodel.ContinuousBranchValueProvider) ArrayList(java.util.ArrayList) TreeModel(dr.evomodel.tree.TreeModel) Parameter(dr.inference.model.Parameter) CountableBranchCategoryProvider(dr.evomodel.branchratemodel.CountableBranchCategoryProvider) Transform(dr.util.Transform) BranchRates(dr.evolution.tree.BranchRates) BranchSpecificFixedEffects(dr.evomodel.branchratemodel.BranchSpecificFixedEffects)

Aggregations

BranchRates (dr.evolution.tree.BranchRates)1 BranchSpecificFixedEffects (dr.evomodel.branchratemodel.BranchSpecificFixedEffects)1 ContinuousBranchValueProvider (dr.evomodel.branchratemodel.ContinuousBranchValueProvider)1 CountableBranchCategoryProvider (dr.evomodel.branchratemodel.CountableBranchCategoryProvider)1 TreeModel (dr.evomodel.tree.TreeModel)1 Parameter (dr.inference.model.Parameter)1 Transform (dr.util.Transform)1 ArrayList (java.util.ArrayList)1