Closed jsigao closed 2 years ago
Dear @msuchard -- thanks very much for your review! I'll make the requested changes to this PR as soon as possible.
Dear @msuchard -- sorry for the delay in making the requested changes. As the code-duplication removal affects many files, I've created a new pull request as a revised version of this PR to make the commit history a bit cleaner. To avoid potential confusion, I'll close this PR for now.
This pull request contains three commits that extend the epochal discrete CTMC (substitution/dispersal) model. Specifically, this extension allows the transition-probability (P) matrix to be computed correctly along a branch that overlaps with multiple Q-matrix epochs (Bielejec et al., 2014) and multiple average-substitution/dispersal-rate epochs (Membrebe et al., 2019), and the stochastic-mapping function (the endpoint-conditioned uniformization algorithm; Hobolth and Stone, 2009) to work under the epochal model (either epochal matrices or epochal rates or both). A more detailed description about the extension can be found in S1 (S1.1 for the P-matrix computation and S1.2 for the stochastic-mapping function) of Gao et al., 2021.
The first commit (
94e91fe
) added agetBranchRateModelMapping
function to eachBranchRateModel
class (where the only non-trivial implementation is in theRateEpochBranchRateModel
class), imitating thegetBranchModelMapping
function of theBranchModel
classes.In the second commit (
e86792c
), this added mapping function is invoked in theSubstitutionModelDelegate
class very similarly as thegetBranchModelMapping
function, allowing the average rate of each Q-matrix epoch that overlaps with a given branch to be computed correctly (instead of assuming that it is the average rate of the entire branch).The third commit (
9e81125
) extends the endpoint-conditioned uniformization algorithm to work under the epochal model by (1) dividing a branch into pieces (where each piece only overlaps with one Q-matrix epoch and one average-rate epoch), (2) drawing the state at the end of each piece according to the probability conditioned on the start state of the piece and the end state of the branch, and (3) simulating history over each piece using the time-homogeneous algorithm.Please let me know if I failed to follow the preferred coding style in this extension or if some of the functionalities introduced here would be preferred to be implemented in an alternative way. Thank you in advance for reviewing this PR.