Skip to content

Commit

Permalink
allow for cognate singletons
Browse files Browse the repository at this point in the history
  • Loading branch information
jordandouglas committed Apr 27, 2023
1 parent 3ad6e4e commit a0c45b7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/indeldollo/StochasticDolloTreeLikelihoodFast.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,20 @@ public double calculateLogP() {
// Mean birth rate (weighted by branch lengths)
double totalWeightedRate = 0.0;
double totalTreeLength = 0.0;
for (Node node : root.getAllChildNodesAndSelf()) {
double rate = branchRateModel.getRateForBranch(node);
double length = node == root ? (birthTime - node.getHeight()) : node.getLength();
if (root.isLeaf()) {
double rate = branchRateModel.getRateForBranch(root);
double length = birthTime - root.getHeight();
totalWeightedRate += rate * length;
totalTreeLength += length;
}else {
for (Node node : root.getAllChildNodesAndSelf()) {
double rate = branchRateModel.getRateForBranch(node);
double length = node == root ? (birthTime - node.getHeight()) : node.getLength();
totalWeightedRate += rate * length;
totalTreeLength += length;
}
}

double meanBranchRate = totalWeightedRate/totalTreeLength;
double meanBirthRate = lambda * mutationRate * meanBranchRate;

Expand Down

0 comments on commit a0c45b7

Please sign in to comment.