Search in sources :

Example 86 with NodeRef

use of dr.evolution.tree.NodeRef in project beast-mcmc by beast-dev.

the class B1Statistic method getSummaryStatistic.

public double[] getSummaryStatistic(Tree tree) {
    double B1 = 0.0;
    int n = tree.getInternalNodeCount();
    for (int i = 0; i < n; i++) {
        NodeRef node = tree.getInternalNode(i);
        if (!tree.isRoot(node)) {
            B1 += 1.0 / getMi(tree, node);
        }
    }
    return new double[] { B1 };
}
Also used : NodeRef(dr.evolution.tree.NodeRef)

Example 87 with NodeRef

use of dr.evolution.tree.NodeRef in project beast-mcmc by beast-dev.

the class CherryStatistic method getSummaryStatistic.

public double[] getSummaryStatistic(Tree tree) {
    int cherryCount = 0;
    int internalNodeCount = tree.getInternalNodeCount();
    for (int i = 0; i < internalNodeCount; i++) {
        NodeRef node = tree.getInternalNode(i);
        boolean allChildrenExternal = true;
        for (int j = 0; j < tree.getChildCount(node); j++) {
            if (!tree.isExternal(tree.getChild(node, j))) {
                allChildrenExternal = false;
            }
        }
        if (allChildrenExternal)
            cherryCount += 1;
    }
    return new double[] { (double) cherryCount };
}
Also used : NodeRef(dr.evolution.tree.NodeRef)

Example 88 with NodeRef

use of dr.evolution.tree.NodeRef in project beast-mcmc by beast-dev.

the class CollessIndex method getSummaryStatistic.

/**
	 * Assumes strictly bifurcating tree.
	 */
public double[] getSummaryStatistic(Tree tree) {
    double C = 0.0;
    int n = tree.getInternalNodeCount();
    for (int i = 0; i < n; i++) {
        NodeRef node = tree.getInternalNode(i);
        int r = TreeUtils.getLeafCount(tree, tree.getChild(node, 0));
        int s = TreeUtils.getLeafCount(tree, tree.getChild(node, 1));
        C += Math.abs(r - s);
    }
    n = tree.getExternalNodeCount();
    C *= 2.0 / (n * (n - 3) + 2);
    return new double[] { C };
}
Also used : NodeRef(dr.evolution.tree.NodeRef)

Example 89 with NodeRef

use of dr.evolution.tree.NodeRef in project beast-mcmc by beast-dev.

the class ExternalBranchRates method getSummaryStatistic.

public double[] getSummaryStatistic(Tree tree) {
    int externalNodeCount = tree.getExternalNodeCount();
    double[] stats = new double[externalNodeCount];
    int count = 0;
    for (int i = 0; i < externalNodeCount; i++) {
        NodeRef node = tree.getExternalNode(i);
        stats[count++] = (Double) tree.getNodeAttribute(node, "rate");
    }
    return stats;
}
Also used : NodeRef(dr.evolution.tree.NodeRef)

Example 90 with NodeRef

use of dr.evolution.tree.NodeRef in project beast-mcmc by beast-dev.

the class FuLiD method getSummaryStatistic.

public double[] getSummaryStatistic(Tree tree) {
    double externalLength = 0.0;
    double internalLength = 0.0;
    int externalNodeCount = tree.getExternalNodeCount();
    for (int i = 0; i < externalNodeCount; i++) {
        NodeRef node = tree.getExternalNode(i);
        NodeRef parent = tree.getParent(node);
        externalLength += tree.getNodeHeight(parent) - tree.getNodeHeight(node);
    }
    int internalNodeCount = tree.getInternalNodeCount();
    for (int i = 0; i < internalNodeCount; i++) {
        NodeRef node = tree.getInternalNode(i);
        if (!tree.isRoot(node)) {
            NodeRef parent = tree.getParent(node);
            internalLength += tree.getNodeHeight(parent) - tree.getNodeHeight(node);
        }
    }
    int n = externalNodeCount;
    double total = externalLength + internalLength;
    // difference in expectations
    double D = total - a(n) * externalLength;
    // normalized
    D /= Math.sqrt(u(n) * total + (v(n) * (total * total)));
    return new double[] { D };
}
Also used : NodeRef(dr.evolution.tree.NodeRef)

Aggregations

NodeRef (dr.evolution.tree.NodeRef)426 ArrayList (java.util.ArrayList)38 LinkedList (java.util.LinkedList)20 Taxon (dr.evolution.util.Taxon)18 Tree (dr.evolution.tree.Tree)14 TreeModel (dr.evomodel.tree.TreeModel)14 Parameter (dr.inference.model.Parameter)14 Clade (dr.evolution.tree.Clade)13 MutableTree (dr.evolution.tree.MutableTree)9 Node (dr.evomodel.arg.ARGModel.Node)9 MultivariateTraitTree (dr.evolution.tree.MultivariateTraitTree)8 BranchMapModel (dr.evomodel.epidemiology.casetocase.BranchMapModel)8 BitSet (java.util.BitSet)8 FixedBitSet (jebl.util.FixedBitSet)8 FlexibleTree (dr.evolution.tree.FlexibleTree)7 AbstractCase (dr.evomodel.epidemiology.casetocase.AbstractCase)7 Matrix (dr.math.matrixAlgebra.Matrix)6 CompoundParameter (dr.inference.model.CompoundParameter)5 TimeScale (dr.evolution.util.TimeScale)4 MicrosatelliteSamplerTreeModel (dr.evomodel.tree.MicrosatelliteSamplerTreeModel)4