Mutsel implementation - #193
Conversation
|
Hi @benjamin-lieser, A very interesting development! Surely, there will be some code conflicts between the changes in this PR and in my PR for the PMSFR model. Most notably, in the way the ModelSet object is constructed. There are also some problems here regarding how site-specific matrices are handled by different functions of the Alignment class (now they are not handled at all, yet they should be). And, possibly, the file-reading functions could be merged or be using a common helper. The only thing that seems very off to me in your changes is the
Take a look at this from the following angle: the new code, possibly not parallelization-safe, is added only to allow for a feature that is not only unnecessary, but also promotes a potentially suboptimal practice! Best regards, |
|
Hi, thanks for the comments. We want to have a preprint out soon, so there the details of the model will be explained. Maybe two key points here. Overfitting is not prevented by Phylograd, but by regularizing the parameters against a posterior mean model (PMSF like, but made a bit faster). The second is that Mutsel allows us to use no rate categories at all, all the rate variation can be explained extremely well just by Mutation Selection (as is would make a lot of sense biologically). Having a common file format to specify site specific models would probably be very useful. I guess the features needed would be exchangebility, equlibirum and rate for every column (or I guess pattern, we do not need different parameters for the same pattern). Plus an optional RHAS model. So if you implement such a thing in the PMSFR model, we could merge after and use this. The -ft AUTO option is really just a convenience, for inexperienced people wanting a tree in one command. Our model is very insensitive to the guide tree. |
|
Hi @benjamin-lieser, Thanks for the explanations! I will look forward to your preprint to learn more details on how you've managed to overcome overfitting and sensitivity to the guide tree topology. Sounds like a real breakthrough. Since you're having the preprint almost ready, I guess you would like the code to be merged as soon as possible. Then we will have to fix conflicts with PMSFR and refine the interface/input handling already after your merge. Hope it won't take long. And yet some more against the All of these surely are just minor points that could be solved later, after merging the main changes. But I think they are worth mentioning anyway. It's also noteworthy that process spawning, though perfectly fine in general, looks kind of hacky in this context and possibly could be substituted with something like what is done in Best, |
bqminh
left a comment
There was a problem hiding this comment.
A few comments from Minh and Thomas, which we added also into the source code of the PR. We'll merge it now. But some comments for future release:
Major:
- It doesn't seem to us that you normalise the site-specific Q matrices across all sites. We understand that each individual Q per site is not normalised. But then you still need to make sure that all mu (normalising factor) across sites must normalise to 1, in order to have branch lengths interpreted as the number of substitutions per site. More specifically: (1/nsites) * sum_i mu_i should equal to 1.0, where mu_i = -sum_j pi^i_j * Q^i_{jj}.
Others:
- If possible (for later), rename site_rate_matrices to ptn_rate_matrices
- This is hard coded to contain 190 entries, which only works for AA data and REV model. Better change it to nstates*(nstates-1)/2 for REV and nstates*nstates for NON-REV models.
- What is Cargo.lock file in musel_rust? Is it really necessary to include this file within IQ-TREE code?
- What's the reason for changing cmake req from 10.12 to 11.0.1? Make sure that IQ-TREE can still run on old Mac, such as with Intel chips
- the design of spawning process is not great because you need to load the alignment again causing overhead. It's better to run inside IQ-TREE. Suggest that we do not announce -ft AUTO option for now, and just ask users to explicitly infer a guide tree themselves.
- Better have some option like --max-mutsel-brlen with the default of 200.0. So users can change. We don't like hard-coded constant in the code. Also this has to be in the utils.cpp file, not here, which is hard to debug.
| tree->setCheckpoint(checkpoint); | ||
| // Increase the maximum branch length if MutSel is used because the time unit is different. | ||
| if (params.model_name.rfind("MUTSEL") == 0) { | ||
| // Minh/Thomas: Better have some option like --max-mutsel-brlen with the |
There was a problem hiding this comment.
This is already a hardcoded constant in IQTREE (10.0), do you want to leave this?
| It's better to run inside IQ-TREE. Suggest that we do not | ||
| announce -ft AUTO option for now, and just ask users to explicitly | ||
| infer a guide tree themselves. | ||
| */ |
There was a problem hiding this comment.
The overhead is minimal, but I agree that doing this internal would avoid the arguably a bit ugly process spwan.
I am also open to remove this feature.
There was a problem hiding this comment.
It's not only about spawning a new process, but this actually doesn't work with several other options in IQ-TREE, that you may have overlooked. @StefanFlaumberg pointed out some. Other features like -g option (constraint tree) is not considered (i.e. your guideline won't obey the constraint). A better neat design is to call function runTreeReconstruction(...) instead. You can set params.model_name appropriately, before calling this function.
| } | ||
| ptn_state_freq.push_back(state_freq); | ||
| if (!aln->site_rate_matrices.empty()) { | ||
| /* Minh/Thomas: Better change 190 to num_states*(numstates-1)/2 so that if you want to |
There was a problem hiding this comment.
Maybe a general discussion about how to store these values. For the site frequencies it is a vector of pointers, which is arguably brittle with respect to memory leaks or even use after free.
I think a simple vector of vectors should be fine, I doubt we loose performance here.
Would you agree to do this for both?
There was a problem hiding this comment.
I understand. But better leave site frequencies untouched for the moment, as Stefan might touch this variable in another PR. So I prefer not doing both at the moment.
They are normalized in this way in the Rust part.
I agree, I will rework this. But maybe we merge the other PR which touch this first.
It makes the build 100% reproducible, because all dependencies are pinned. I think this is useful and also how IQ-TREE handles most of it's dependencies (except Eigen and Boost)
10.12 does not support C++17 and is not supported by apple anymore at all. You can run 11.0 on an Intel Mac and one absolutely should. Any hardware from 2013 should support it.
I have put a comment to the code here.
I also but a comment to the code for this |
|
I see thanks |
|
Hi @bqminh and @benjamin-lieser, Since these are directly related to my previous bug-fixing PRs and the PMSR model PR, I address your first two comments in #211. Rate matrices are stored now in EDIT: Best, |
This is a implementation of a novel Phylogenetic model, based on Mutation Selection.
It does depend on PhyloGrad, therefore this introduces Rust in the building process.
I also updates the windows and Mac Ci build to use C++17.
It generalizes the PMSF optimization, and allows arbitrary rate matrices. The estimation of the MUTSEL model parameters happens in Rust code, using an automatic differentiation framework.
The final binary does not have any Rust specific dependencies, which allows to distribute static binaries for the supported platforms.