Support Exporting Model and Partition Selections to MrBayes #29
+525
−30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
This PR ports over iqtree/iqtree2#267 into IQTree 3, as well as implementing all review requests previously on that PR.
Similarly, iqtree/iqtree2#195 has been implemented for all MrBayes supported sequence types. (DNA/RNA, Protein, Binary, Morphological & Codon) This PR is complete, excluding any changes required further from suggestions and bug fixes after testing has been conducted.
General Implementation Details
-mset mrbayes
, or adds the-mrbayes
flag.mr_bayes.nex
)GTR+G+I
(DNA) will be used, with warnings printed to log and file.+R
has been mapped to+G+I
(with warnings printed to log + file)DNA Fallbacks
For DNA, MrBayes supports three models: JR/F81 (
nst=1
), HKY (nst=2
) and GTR (nst=6
) (excluding their fixed frequency counterparts)Therefore, when a model is used that is not supported in MrBayes, it will default to GTR, due to the lower impact of increased parameters when using Bayesian Inference.
Protein Fallbacks
For Protein, when a model is used that is not supported by MrBayes, a default of
GTR
will be used. Then there will be a rate and state frequency matrix of the model included. The rate matrix will be set tofixed
, unless the model used by IQTree wasGTR20
, in which casedirichlet
will be used. This appears to be a mandatory parameter for MrBayes GTR models.Binary, Morphological and Codon Data Exclusions
Codon Implementation Details
Codon Models in MrBayes: Introduction
The basic structure for codon models in MrBayes is quite similar to mechanistic codon models in IQTree, following the same formulation of the model by Goldman & Yang 1994 and Muse & Gaut 1994. However, the settings for MrBayes are under different names, and most inputs cannot be ported directly, making it the most difficult model to port to MrBayes format.
Instead of using named models, such as
MG
orGY
, MrBayes uses only one main parameter, which acts similar to DNA model selection: Nucleotide Substitution Model (FromJC
,HKY
andGTR
), set throughlset nst
(nst = 1
forJC
,nst = 2
forHKY
,nst = 6
forGTR
)(Source: MrBayes Manual (Chapter 6.1.3 & Appendix A), MrBayes
help lset
andhelp prset
commands, IQTree Documentation on Substitution Models (Section on Codon Models))Mechanistic Model Output
Nucleotide Substitution Model
For retrieving the nucleotide substitution model that should be used as input into MrBayes, the implemented code does the following:
fix_kappa
is true, then the model will be set tonst = 1
(JC)fix_kappa
is false, then the model will be set tonst = 2
(HKY)This implementation means that GTR is not used, appropriate considering the inputs for Mechanistic Codon Models in IQTree (ds/dt ratio + ts/tv ratio).
Note that
fix_kappa
is only set to true under the Codon ModelsMGK
andGY0K
(which are the only models without ats/tv
input ratio). This can be shown through theinitCodon
function, which only callsinitMG94
orinitGY94
withfix_kappa
as true for those two models. That input is then read into thefix_kappa
field here for MG Models and here for GY Models.Empirical Model Output
MrBayes does not support Empirical Codon Models, so when such a model is being used (or a mixture of Empirical + Mechanistic), a warning is printed to the log and file. However, a model is still outputted, with
nst = 6
(GTR-like model).Codon Codes
Whilst IQTree uses Number IDs for its Codon Codes (CODON1, CODON2, etc.), MrBayes uses Text IDs. (
vertmt
,invermt
, etc.) There is no clear documentation or description for most of the codes, but below shows the final table to transfer from IQTree Codon Codes to MrBayes Codon Codes.An
XXX
in the MrBayes column represents a code that MrBayes does not support.If a code is used that MrBayes does not support, it defaults to the universal code, and prints a warning to the log and file.
Example Output Files
Without Partitions
With Partitions