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 #1129

Closed
wants to merge 3 commits into from

Conversation

jsigao
Copy link
Contributor

@jsigao jsigao commented Mar 8, 2022

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.

jsigao added 3 commits March 4, 2022 22:05
…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)
Copy link
Member

@msuchard msuchard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsigao -- i am going to reject this pr for a couple of reasons that are straight-forward to fix:

  1. please target a development branch, like hmc-clock since this is a rather large change of behavior
  2. pleaser remove massive amounts of code duplication (i.e. with the getBranchRateModelMapping copied across many files.

@jsigao
Copy link
Contributor Author

jsigao commented May 30, 2022

Dear @msuchard -- thanks very much for your review! I'll make the requested changes to this PR as soon as possible.

@jsigao jsigao changed the base branch from master to hmc-clock July 6, 2022 01:25
@jsigao
Copy link
Contributor Author

jsigao commented Jul 6, 2022

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.

@jsigao jsigao closed this Jul 6, 2022
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.

2 participants