Skip to content

Commit

Permalink
prior problem in birthDeathOnRootAgeAndTaxa.lphy #492 #496
Browse files Browse the repository at this point in the history
  • Loading branch information
yxu927 committed Jun 14, 2024
1 parent 2b1fd6e commit c58147c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/birth-death/birthDeathOnRootAgeAndTaxa.lphy
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ model{
// Conditioned on root age and on number of taxa
ψ ~ BirthDeath(lambda=λ, mu=death_rate, rootAge=root_time, taxa=taxa);

ucln_mean ~ Exp(mean=2.0);
ucln_sigma ~ Exp(mean=3.0);
ucln_mean ~ Normal(mean=-4.5, sd=0.5);
ucln_sigma ~ Exp(mean=0.5);
branch_rates ~ LogNormal(meanlog=ucln_mean, sdlog=ucln_sigma, replicates=2*n - 2);

D ~ PhyloCTMC(tree=ψ, Q=Q, branchRates=branch_rates, L=L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lphy.base.evolution.alignment.SimpleAlignment;
import lphy.base.evolution.tree.TimeTree;
import lphy.base.evolution.tree.TimeTreeNode;
import lphy.core.logger.LoggerUtils;
import lphy.core.model.GenerativeDistribution;
import lphy.core.model.Value;
import lphy.core.simulator.RandomUtils;
Expand Down Expand Up @@ -47,11 +48,15 @@ public abstract class AbstractPhyloCTMC implements GenerativeDistribution<Alignm
protected Value<Double[]> rootFreqs;
protected SortedMap<String, Integer> idMap = new TreeMap<>();
protected double[][] transProb;
/**
* <code>e^{Qt} = Ee^{At}E^-1</code>, where A is a diagonal matrix of eigenvalues (Eval),
* E is the matrix of right eigenvectors (Evec), and E^-1 is the matrix of left eigenvectors (Ievc).
*/
private EigenDecomposition decomposition;
private double[][] Ievc;
private double[][] Evec;
private double[][] iexp;
private double[] Eval;
private double[][] Ievc; // inverse Eigen vectors
private double[][] Evec; // Eigen vectors
private double[][] iexp; // intermediate matrix
private double[] Eval; // Eigenvalues


public AbstractPhyloCTMC(Value<TimeTree> tree, Value<Number> clockRate, Value<Double[]> freq,
Expand All @@ -65,7 +70,17 @@ public AbstractPhyloCTMC(Value<TimeTree> tree, Value<Number> clockRate, Value<Do

this.random = RandomUtils.getRandom();

// checkCompatibilities();
Double[] treeBranchRates = tree.value().getBranchRates();

if (treeBranchRates != null && treeBranchRates.length > 0) {
if (this.branchRates != null) { // have branchRates from input but tree also has branch rates
LoggerUtils.log.warning("PhyloCTMC has branchRates from input parameter and tree has branch rates, " +
"default to using input parameter branchRates.");
} else { // if tree has branch rates, then use them
this.branchRates = new Value<>("branchRates", treeBranchRates);
}
}
// checkCompatibilities();
}

//+++ protected methods +++//
Expand Down

0 comments on commit c58147c

Please sign in to comment.