Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extending the epochal discrete CTMC model #1135

Open
wants to merge 3 commits into
base: hmc-clock
Choose a base branch
from

Conversation

jsigao
Copy link
Contributor

@jsigao jsigao commented Jul 6, 2022

This PR is modified from a previous PR following @msuchard's suggestion. One of the commits (commit 859f33f) contained in this pull request has been fully revised to remove the unnecessary code duplication caused by the (trivial version of) getBranchRateModelMapping function copied across all the branchratemodel classes (now the trivial version of this function is implemented in the AbstractBranchRateModel class so this function has been removed from all the branchRate classes extending the abstract class). (The other two commits in this PR remain unchanged.)

I have done an additional experiment to validate the implementation extension contained in this pull request. Please see this synopsis.pdf document for a brief summary of the experiment. (The supplementary files that I used to perform this experiment is available in this Qmu_bothvary_test.zip folder).

Please let me know if there is anything unclear or missing in the experiment. I have also changed the target branch of this pull request to hmc-clock as advised. Thanks again for reviewing this PR.

For the sake of completeness, the PR message from the previous PR is included below.

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 a getBranchRateModelMapping function to each BranchRateModel class (where the only non-trivial implementation is in the RateEpochBranchRateModel class), imitating the getBranchModelMapping function of the BranchModel classes.

In the second commit (e86792c), this added mapping function is invoked in the SubstitutionModelDelegate class very similarly as the getBranchModelMapping 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.

…long a branch when that branch overlaps with both multiple epochal matrices and multiple epochal rates
…istories under either an epochal matrix model or an epochal rate model (or both)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants