Search in sources :

Example 1 with TreeIntervals

use of dr.evolution.coalescent.TreeIntervals in project beast-mcmc by beast-dev.

the class MRCAOlderThanStatistic method getSummaryStatistic.

public double[] getSummaryStatistic(Tree tree) {
    TreeIntervals intervals = new TreeIntervals(tree);
    double totalTime = 0.0;
    for (int i = 0; i < intervals.getIntervalCount(); i++) {
        totalTime += intervals.getInterval(i);
        if (totalTime > t) {
            return new double[] { 1.0 };
        }
    }
    return new double[] { 0.0 };
}
Also used : TreeIntervals(dr.evolution.coalescent.TreeIntervals)

Example 2 with TreeIntervals

use of dr.evolution.coalescent.TreeIntervals in project beast-mcmc by beast-dev.

the class IntervalKStatistic method getSummaryStatistic.

public double[] getSummaryStatistic(Tree tree) {
    TreeIntervals intervals = new TreeIntervals(tree);
    double totalTime = 0.0;
    int intervalCount = intervals.getIntervalCount();
    for (int i = 0; i < intervalCount; i++) {
        if (intervals.getLineageCount(i) == k) {
            totalTime += intervals.getInterval(i);
        }
    }
    return new double[] { totalTime };
}
Also used : TreeIntervals(dr.evolution.coalescent.TreeIntervals)

Example 3 with TreeIntervals

use of dr.evolution.coalescent.TreeIntervals in project beast-mcmc by beast-dev.

the class LineageCountStatistic method getSummaryStatistic.

public double[] getSummaryStatistic(Tree tree) {
    TreeIntervals intervals = new TreeIntervals(tree);
    double totalTime = 0.0;
    for (int i = 0; i < intervals.getIntervalCount(); i++) {
        totalTime += intervals.getInterval(i);
        if (totalTime > t) {
            return new double[] { intervals.getLineageCount(i) };
        }
    }
    return new double[] { 1.0 };
}
Also used : TreeIntervals(dr.evolution.coalescent.TreeIntervals)

Example 4 with TreeIntervals

use of dr.evolution.coalescent.TreeIntervals in project beast-mcmc by beast-dev.

the class LineageProportionStatistic method getSummaryStatistic.

public double[] getSummaryStatistic(Tree tree) {
    TreeIntervals intervals = new TreeIntervals(tree);
    int tipCount = tree.getExternalNodeCount();
    double totalTime = 0.0;
    for (int i = 0; i < intervals.getIntervalCount(); i++) {
        totalTime += intervals.getInterval(i);
        if (totalTime > t) {
            return new double[] { ((double) intervals.getLineageCount(i)) / tipCount };
        }
    }
    return new double[] { 1.0 / tipCount };
}
Also used : TreeIntervals(dr.evolution.coalescent.TreeIntervals)

Example 5 with TreeIntervals

use of dr.evolution.coalescent.TreeIntervals in project beast-mcmc by beast-dev.

the class VDdemographicFunction method setTreeTimes.

private boolean setTreeTimes(int nt, Tree[] trees) {
    if (dirtyTrees[nt]) {
        /*double[] doubles = null;
            if( ! dirtyTrees[nt] ) {
               doubles = ttimes[nt].clone();

            }*/
        ti[nt] = new TreeIntervals(trees[nt]);
        TreeIntervals nti = ti[nt];
        // make sure we get each coalescent event individually
        nti.setMultifurcationLimit(0);
        // code probably incorrect for serial samples
        final int nLineages = nti.getIntervalCount();
        assert nLineages >= ttimes[nt].length : nLineages + " " + ttimes[nt].length;
        int iCount = 0;
        for (int k = 0; k < ttimes[nt].length; ++k) {
            double timeToCoal = nti.getInterval(iCount);
            while (nti.getIntervalType(iCount) != IntervalType.COALESCENT) {
                ++iCount;
                timeToCoal += nti.getInterval(iCount);
            }
            int linAtStart = nti.getLineageCount(iCount);
            ++iCount;
            assert !(iCount == nLineages && linAtStart != 2);
            int linAtEnd = (iCount == nLineages) ? 1 : nti.getLineageCount(iCount);
            while (linAtStart <= linAtEnd) {
                ++iCount;
                timeToCoal += nti.getInterval(iCount);
                linAtStart = linAtEnd;
                ++iCount;
                linAtEnd = nti.getLineageCount(iCount);
            }
            ttimes[nt][k] = timeToCoal + (k == 0 ? 0 : ttimes[nt][k - 1]);
        }
        /*if( doubles != null ) {
                if( ! Arrays.equals(doubles, ttimes[nt]) ) {
                   System.out.println(Arrays.toString(doubles) + " != " + Arrays.toString(ttimes[nt])
                           + Arrays.toString(dirtyTrees) + " " + dirtyTrees);
                }
            }*/
        dirtyTrees[nt] = false;
        // System.out.print(nt + " " + Arrays.toString(dirtyTrees) + " " + dirtyTrees);
        return true;
    }
    return false;
}
Also used : TreeIntervals(dr.evolution.coalescent.TreeIntervals)

Aggregations

TreeIntervals (dr.evolution.coalescent.TreeIntervals)6 Tree (dr.evolution.tree.Tree)1 TreeModel (dr.evomodel.tree.TreeModel)1