Search in sources :

Example 1 with MatrixParameter

use of dr.inference.model.MatrixParameter in project beast-mcmc by beast-dev.

the class DataFromTreeTipsParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    TreeTraitParserUtilities utilities = new TreeTraitParserUtilities();
    String traitName = (String) xo.getAttribute(TreeTraitParserUtilities.TRAIT_NAME);
    MultivariateTraitTree treeModel = (MultivariateTraitTree) xo.getChild(MultivariateTraitTree.class);
    TreeTraitParserUtilities.TraitsAndMissingIndices returnValue = utilities.parseTraitsFromTaxonAttributes(xo, traitName, treeModel, true);
    MatrixParameter dataParameter = MatrixParameter.recast(returnValue.traitParameter.getId(), returnValue.traitParameter);
    if (xo.hasChildNamed(TreeTraitParserUtilities.MISSING)) {
        Parameter missing = (Parameter) xo.getChild(TreeTraitParserUtilities.MISSING).getChild(Parameter.class);
        missing.setDimension(dataParameter.getDimension());
        for (int i = 0; i < missing.getDimension(); i++) {
            if (returnValue.missingIndices.contains(i)) {
                missing.setParameterValue(i, 1);
            } else {
                missing.setParameterValue(i, 0);
            }
        }
    }
    return dataParameter;
}
Also used : MatrixParameter(dr.inference.model.MatrixParameter) TreeTraitParserUtilities(dr.evomodelxml.treelikelihood.TreeTraitParserUtilities) Parameter(dr.inference.model.Parameter) MatrixParameter(dr.inference.model.MatrixParameter) MultivariateTraitTree(dr.evolution.tree.MultivariateTraitTree)

Example 2 with MatrixParameter

use of dr.inference.model.MatrixParameter in project beast-mcmc by beast-dev.

the class MultivariateNormalDistributionModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    XMLObject cxo = xo.getChild(MultivariateDistributionLikelihood.MVN_MEAN);
    Parameter mean = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(MultivariateDistributionLikelihood.MVN_PRECISION);
    MatrixParameter precision = (MatrixParameter) cxo.getChild(MatrixParameter.class);
    if (mean.getDimension() != precision.getRowDimension() || mean.getDimension() != precision.getColumnDimension())
        throw new XMLParseException("Mean and precision have wrong dimensions in " + xo.getName() + " element");
    return new MultivariateNormalDistributionModel(mean, precision);
}
Also used : MatrixParameter(dr.inference.model.MatrixParameter) MultivariateNormalDistributionModel(dr.inference.distribution.MultivariateNormalDistributionModel) Parameter(dr.inference.model.Parameter) MatrixParameter(dr.inference.model.MatrixParameter)

Example 3 with MatrixParameter

use of dr.inference.model.MatrixParameter in project beast-mcmc by beast-dev.

the class MultivariateOUModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    SubstitutionModel substitutionModel = (SubstitutionModel) xo.getChild(SubstitutionModel.class);
    Parameter effectParameter = (Parameter) ((XMLObject) xo.getChild(DATA)).getChild(Parameter.class);
    Parameter timesParameter = (Parameter) ((XMLObject) xo.getChild(TIME)).getChild(Parameter.class);
    Parameter designParameter = (Parameter) ((XMLObject) xo.getChild(DESIGN)).getChild(Parameter.class);
    MatrixParameter gammaParameter = (MatrixParameter) xo.getChild(MatrixParameter.class);
    if (effectParameter.getDimension() != timesParameter.getDimension() || effectParameter.getDimension() != designParameter.getDimension()) {
        //				System.err.println("dim(design) "+designParameter.getDimension());
        throw new XMLParseException("dim(" + effectParameter.getStatisticName() + ") != dim(" + timesParameter.getStatisticName() + ") != dim(" + designParameter.getStatisticName() + ") in " + xo.getName() + " element");
    }
    MultivariateOUModel glm = new MultivariateOUModel(substitutionModel, effectParameter, gammaParameter, timesParameter.getParameterValues(), designParameter.getParameterValues());
    addIndependentParameters(xo, glm, effectParameter);
    return glm;
}
Also used : MatrixParameter(dr.inference.model.MatrixParameter) MultivariateOUModel(dr.inferencexml.distribution.MultivariateOUModel) Parameter(dr.inference.model.Parameter) MatrixParameter(dr.inference.model.MatrixParameter) SubstitutionModel(dr.oldevomodel.substmodel.SubstitutionModel)

Example 4 with MatrixParameter

use of dr.inference.model.MatrixParameter in project beast-mcmc by beast-dev.

the class MatrixMatrixProductParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    MatrixParameter[] temp = new MatrixParameter[3];
    temp[0] = (MatrixParameter) xo.getChild(LEFT).getChild(MatrixParameter.class);
    temp[1] = MatrixParameter.recast(((CompoundParameter) xo.getChild(RIGHT).getChild(CompoundParameter.class)).getVariableName(), (CompoundParameter) xo.getChild(RIGHT).getChild(CompoundParameter.class));
    if (xo.getChild(IN_PLACE) != null) {
        temp[2] = (MatrixParameter) xo.getChild(IN_PLACE).getChild(MatrixParameter.class);
    } else {
        int rowDim = temp[0].getRowDimension();
        int colDim = temp[1].getColumnDimension();
        Parameter[] params = new Parameter[colDim];
        for (int i = 0; i < colDim; i++) {
            params[i] = new Parameter.Default(rowDim);
        }
        temp[2] = new MatrixParameter(null, params);
    }
    Parameter ColumnMask;
    if (xo.getChild(COLUMN_MASK) != null)
        ColumnMask = (Parameter) xo.getChild(COLUMN_MASK).getChild(MatrixParameter.class);
    else
        ColumnMask = new Parameter.Default(null, temp[1].getColumnDimension(), 1);
    return new MatrixMatrixProduct(temp, ColumnMask);
}
Also used : CompoundParameter(dr.inference.model.CompoundParameter) MatrixParameter(dr.inference.model.MatrixParameter) MatrixMatrixProduct(dr.inference.model.MatrixMatrixProduct) CompoundParameter(dr.inference.model.CompoundParameter) Parameter(dr.inference.model.Parameter) MatrixParameter(dr.inference.model.MatrixParameter)

Example 5 with MatrixParameter

use of dr.inference.model.MatrixParameter in project beast-mcmc by beast-dev.

the class Tree_Clustering_Shared_Routines method setMembershipTreeToVirusIndexes.

public static int[] setMembershipTreeToVirusIndexes(int numdata, MatrixParameter virusLocations, int numNodes, TreeModel treeModel) {
    //I suspect this is an expensive operation, so I don't want to do it many times,
    //which is also unnecessary  - MAY have to update whenever a different tree is used.
    int[] correspondingTreeIndexForVirus = new int[numdata];
    for (int i = 0; i < numdata; i++) {
        Parameter v = virusLocations.getParameter(i);
        String curName = v.getParameterName();
        // System.out.println(curName);
        int isFound = 0;
        for (int j = 0; j < numNodes; j++) {
            String treeId = treeModel.getTaxonId(j);
            if (curName.equals(treeId)) {
                //	   System.out.println("  isFound at j=" + j);
                correspondingTreeIndexForVirus[i] = j;
                isFound = 1;
                break;
            }
        }
        if (isFound == 0) {
            System.out.println("not found. Exit now.");
            System.exit(0);
        }
    }
    return (correspondingTreeIndexForVirus);
}
Also used : Parameter(dr.inference.model.Parameter) MatrixParameter(dr.inference.model.MatrixParameter)

Aggregations

MatrixParameter (dr.inference.model.MatrixParameter)15 Parameter (dr.inference.model.Parameter)13 LinkedList (java.util.LinkedList)3 CoercionMode (dr.inference.operators.CoercionMode)2 MultivariateTraitTree (dr.evolution.tree.MultivariateTraitTree)1 NodeRef (dr.evolution.tree.NodeRef)1 Tree (dr.evolution.tree.Tree)1 GMRFMultilocusSkyrideLikelihood (dr.evomodel.coalescent.GMRFMultilocusSkyrideLikelihood)1 GMRFSkyrideLikelihood (dr.evomodel.coalescent.GMRFSkyrideLikelihood)1 TreeModel (dr.evomodel.tree.TreeModel)1 TreeTraitParserUtilities (dr.evomodelxml.treelikelihood.TreeTraitParserUtilities)1 HierarchicalGraphLikelihood (dr.inference.distribution.HierarchicalGraphLikelihood)1 MomentDistributionModel (dr.inference.distribution.MomentDistributionModel)1 MultivariateNormalDistributionModel (dr.inference.distribution.MultivariateNormalDistributionModel)1 CompoundParameter (dr.inference.model.CompoundParameter)1 LatentFactorModel (dr.inference.model.LatentFactorModel)1 MaskedParameter (dr.inference.model.MaskedParameter)1 MatrixMatrixProduct (dr.inference.model.MatrixMatrixProduct)1 MatrixVectorProductParameter (dr.inference.model.MatrixVectorProductParameter)1 MVOUCovarianceOperator (dr.inference.operators.MVOUCovarianceOperator)1