Skip to content

Honour user-defined codon frequencies (+FU) for GY-type models - #210

Merged
bqminh merged 1 commit into
iqtree:masterfrom
cindykrafft:fix/issue-192-codon-fu
Sep 9, 2026
Merged

Honour user-defined codon frequencies (+FU) for GY-type models#210
bqminh merged 1 commit into
iqtree:masterfrom
cindykrafft:fix/issue-192-codon-fu

Conversation

@cindykrafft

Copy link
Copy Markdown

ModelCodon::init replaced a user-defined frequency type with the model's default for every mechanistic model. The MG family needs that (its frequencies are nucleotide-targeted and +FU is turned into F3X4), but initGY94() returns FREQ_EMPIRICAL, so GY{...}+FU{f1,...,f61} became GY+F: the 61 values were never read, the report said GY+F with 60 free parameters and every +FU vector gave the same likelihood. 2.4.0 honoured the request.

Apply the fallback only when codon_freq_style == CF_TARGET_NT. GY-type models now keep FREQ_USER_DEFINED, read the frequencies and report +FU with no free frequency parameters; MG behaviour is unchanged.

Test: test_iqtree.sh/.ps1 run GY+FU with frequencies from test_data/codon_freq.txt and a GY+F3X4 control on a small codon alignment; expect_ans.txt carries their log-likelihoods. The +FU row fails by 26.4 on unmodified master.

Fixes #192

Claude-Session: https://claude.ai/code/session_01TaHntBDKuZJpMAAMenkC44

ModelCodon::init replaced a user-defined frequency type with the model's
default for every mechanistic model. The MG family needs that (its
frequencies are nucleotide-targeted and +FU is turned into F3X4), but
initGY94() returns FREQ_EMPIRICAL, so GY{...}+FU{f1,...,f61} became GY+F:
the 61 values were never read, the report said GY+F with 60 free
parameters and every +FU vector gave the same likelihood. 2.4.0 honoured
the request.

Apply the fallback only when codon_freq_style == CF_TARGET_NT. GY-type
models now keep FREQ_USER_DEFINED, read the frequencies and report +FU
with no free frequency parameters; MG behaviour is unchanged.

Test: test_iqtree.sh/.ps1 run GY+FU with frequencies from
test_data/codon_freq.txt and a GY+F3X4 control on a small codon
alignment; expect_ans.txt carries their log-likelihoods. The +FU row
fails by 26.4 on unmodified master.

Fixes iqtree#192

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaHntBDKuZJpMAAMenkC44

@bqminh bqminh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good, thank you

@bqminh
bqminh merged commit 6799c7f into iqtree:master Sep 9, 2026
2 of 7 checks passed
bqminh added a commit that referenced this pull request Sep 10, 2026
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.

+FU (user-defined frequencies) silently ignored for codon (GY) models in 3.1.2, correct in 2.4.0

3 participants