Skip to content

Commit

Permalink
Added median clade credibility reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
rambaut committed Nov 6, 2024
1 parent ab851ec commit b65c694
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/dr/app/tools/newtreeannotator/CladeSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
import dr.evolution.tree.Tree;
import dr.evolution.util.Taxon;
import dr.evolution.util.TaxonList;
import dr.stats.DiscreteStatistics;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
* @author Andrew Rambaut
Expand Down Expand Up @@ -258,6 +258,28 @@ public boolean expectAllClades() {
return minCladeCredibility[0] / tree.getInternalNodeCount();
}

public double getMedianCladeCredibility(Tree tree) {
final double[] cladeCredibility = new double[tree.getInternalNodeCount()];
final int[] i = { 0 };
traverseTree(tree, new CladeAction() {
@Override
public void actOnClade(Clade clade, Tree tree, NodeRef node) {
if (clade.getTaxon() == null) {
cladeCredibility[i[0]] = clade.getCredibility();
i[0] += 1;
}
}

@Override
public boolean expectAllClades() {
return true;
}
});


return DiscreteStatistics.median(cladeCredibility);
}

/**
* Returns the number of clades in the tree with threshold credibility or higher
* @param tree
Expand Down
1 change: 1 addition & 0 deletions src/dr/app/tools/newtreeannotator/TreeAnnotator.java
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ private MutableTree getHIPSTRTree(CladeSystem cladeSystem) {
private static void reportStatistics(CladeSystem cladeSystem, Tree tree) {
progressStream.println("Lowest individual clade credibility: " + String.format("%.4f", cladeSystem.getMinimumCladeCredibility(tree)));
progressStream.println("Mean individual clade credibility: " + String.format("%.4f", cladeSystem.getMeanCladeCredibility(tree)));
progressStream.println("Median individual clade credibility: " + String.format("%.4f", cladeSystem.getMedianCladeCredibility(tree)));
progressStream.println("Number of clades with credibility 1.0: " + cladeSystem.getTopCladeCredibility(tree, 1.0));
progressStream.println("Number of clades with credibility > 0.99: " + cladeSystem.getTopCladeCredibility(tree, 0.99) +
" (out of " + cladeSystem.getTopCladeCredibility(0.99) + " in all trees)");
Expand Down

0 comments on commit b65c694

Please sign in to comment.