Introduce --site(-float)-weights options and implement Bayesian Bootstrap#157
Introduce --site(-float)-weights options and implement Bayesian Bootstrap#157trongnhanuit wants to merge 36 commits into
Conversation
…ly read the file multiple times
…read the weight file once
… -bsam bayes:<factor>
…outputs integer weights for the standard bootstrap and floating-point weights for the Bayesian bootstrap
# Conflicts: # .gitignore # alignment/alignment.cpp # utils/tools.cpp
…branches in bootstrap trees only (not the ML tree). This option is automatically set at True for Bayesian Bootstrap
… Bootstrap with UFBoot
…length for collapsing near-zero branches when computing Bayesian Bootstrap
|
Some issues below. I won't merge this yet into v3.1.2 but aiming for v3.1.3 once you solved these. SummaryAdds Issues Found1. 2. Unused variable size_t pos = 0;
weight = convert_double(token.c_str());
3. 4. 5. const bool bayes_boot = (params->num_bootstrap_samples > 0 &&
params->bootstrap_spec &&
strncasecmp(params->bootstrap_spec, "BAYES", 5) == 0);This checks global params, not whether this specific alignment is a bootstrap replicate. During standard tree search (before bootstrap), this condition is false, but if someone runs 6. 7. 8. int pars_scale = (spec[5] == ':') ? max(1, convert_int(spec + 6)) : 10;If spec is 9. Duplicated weight-writing code 10. Minor Issues
VerdictThe core Bayesian bootstrap implementation (Dirichlet sampling, weight integration) is correct. The main concerns are: (1) |
…hen conducting Bayesian bootstrap; add --site-weights and --site-float-weights in command reference
# Conflicts: # alignment/alignment.cpp # alignment/alignment.h
|
Dear Nhan @trongnhanuit, I haven't dug deeply into your changes, but I'm pretty sure that your "Merge master" commit is going to significantly mess up bootstrapping, unless you:
Due to my recent changes,
with this: and remove the following chunk: Nothing deeply wrong here, but since you've set pattern's frequency before adding the pattern, by using
with this: The reason is clear: the bootstrap alignment is a Actually, I was expecting that your pull request would be merged before mine, so that it would be my headache to resolve merging conflicts, since you've introduced far fewer changes than I did. So I'll be happy to help if needed! Best, |
|
Hi @StefanFlaumberg , Thanks a lot for checking this and for the very helpful information. I was halfway through merging your changes and revising my code accordingly yesterday, and I planned to continue working on it today. Your message came at the right time and will save me a lot of time and effort. I really appreciate it. I’ll let you know once I’ve finished the revision. Many thanks, |
…-float weights for Bayesian bootstrap alignments
|
Hi @StefanFlaumberg, Cheers, |
|
Hi Nhan @trongnhanuit, From what I see, now the changes do not interfere with anything in standard analyses (i.e. when run without the new options) -- thanks for applying the amendments! Regarding the new options themselves, there clearly exist some problems: site weights should be banned/made compatible with partitions and AliSim, site weight members should be properly copied by alignment copying functions, the logic of when to use raw site number and when to use weight-corrected site number is likely not well-considered. But since this seems to be only a test version yet and the code may still evolve, it might be easier to solve these problems later, based on more mature code. It is easier to put this all in code, than in words, but I hope my logic is clear. This is only my superficial analysis, so maybe my suggestions are nonsense. What do you think? I'm interested in proceeding the discussion. Best regards, |
|
Thanks for feedback! This option will be quite useful for the community, both users and developers (I'm aware of several asking about this) |
|
Hi @StefanFlaumberg and @bqminh, Stefan’s comments sound reasonable to me, and I could directly apply some of them (e.g., banning site weights for AliSim, properly copying site weights in alignment copy functions, and improving the logic for using raw versus user-specified site weights). However, I am a bit concerned about simplifying the code logic by storing both integer and floating-point site weights in pattern_weight, given the current design of the two options:
These two options can be used simultaneously, where the integer weights are applied throughout the analysis except during likelihood maximizations, which instead use the floating-point weights. In addition, as Stefan mentioned, the proposed approach is not compatible with PLL. Therefore, to fully apply all the proposed changes, we may need to consider:
What do you think, @bqminh and @StefanFlaumberg? |
|
It'd be good to have both options working together in a single run, they are not mutually exclusive. If both options are specified, then --site-float-weights will be used for likelihood calculation, whereas --site-weights are used for others like parsimony calculation. I'd recommend to turn off PLL with --site-weights, just switch to our own parsimony kernel, like with -t PARS option, if that simplifies things. |
|
@trongnhanuit, There are two core ideas that should apply whatever logic we choose to follow:
The issue is that Nhan's idea:
is incompatible with my idea 1. If "the integer weights are applied throughout the analysis" means adding site repeats to the alignment, then it increases the number of sites. This, in turn, should affect I can envision the following 3 directions:
I still think that direction 3 is the best solution because it doesn't changes the alignment (in contrast to 1), it treats parsimony and likelihood in the same way (in contrast to 1 and 2), and it gives weights a single universal meaning (much easier to explain and use than in the directions 1 and 2!). It might be easier for me to implement the pattern regrouping and weight copying features myself, as I've recently done this for |
|
Hi @StefanFlaumberg, If allowing switching from PLL to IQ-TREE's parsimony kernel, we can consider directions 2 and 3. Regarding direction 2, if I understand correctly, it keeps the code for "--site-float-weights" from direction 1 (but normalizing ptn_freq sums to the number of sites). It will change the code for "--site-weights" so that we don't extend the alignment, but we need to switch to IQ-TREE's parsimony kernel. Am I right? If yes, would you mind making the changes, and we'll review them. Btw, if you find any inconsistencies in the merging, please make a pull request to my fork-branch. Highly appreciate that. Cheers, |
Yes, correct. Once we consider the following details, I will try to implement it. Within a week, I shall provide a pull request or shall report if insurmountable problems appear. The implementation details:
I think either of these variants makes usage much more understandable and predictable than direction 2 original or the current version. Since I like direction 3 the most, I will put a couple of additional arguments for it: I hope we could choose the best design before applying any actual changes. What do you think of this? Best regards, |
|
Hi @StefanFlaumberg, Thank you so much for your willingness to make changes and your thoughtful consideration. Regarding the Bayesian bootstrap, we want to improve the support for short branches that contain a very limited number of substitutions. So, we use Regarding the two site weight options, we insist on keeping them separate for flexibility. In particular, in another project, we only want to apply float weights for likelihood calculations while preserving all other steps unchanged. So direction 2 seems more appropriate than direction 3. I'll leave it to @bqminh to decide the directions. To save your time, here is a summary, Minh. In the current implementation, integer weights alone are applied both to parsimony and likelihood; float weights alone are applied only to likelihood; the combined usage applies integer weights to parsimony and float weights to likelihood. The current implementation is compatible with PLL, but at the cost of extending the alignment. Stefan is happy to update the implementation to switch to IQ-TREE's parsimony kernel, removing the need to extend the alignment. Three potential directions:
For me, either Direction 2 original or Direction 2 simplified is more favorable given the current designed features. Direction 3 is a simpler option if we are willing to change the designed features and the Bayesian bootstrap behavior. @StefanFlaumberg, pls correct me if anything is incorrect or unclear. Thanks a lot @StefanFlaumberg and @bqminh. Cheers, |
|
Hi @trongnhanuit, thanks for the summary! Everything's accurate here. |
This pull request includes: