Skip to content

Mixlen refactoring: Make GHOST compatible with PMSF#174

Merged
bqminh merged 1 commit into
iqtree:masterfrom
StefanFlaumberg:fixmixlen
Jun 19, 2026
Merged

Mixlen refactoring: Make GHOST compatible with PMSF#174
bqminh merged 1 commit into
iqtree:masterfrom
StefanFlaumberg:fixmixlen

Conversation

@StefanFlaumberg

Copy link
Copy Markdown
Contributor

This pull request implements the GHOST rate heterogeneity model for the PMSF model, a long-awaited feature requested several times before:  iqtree/iqtree2#391 (comment) and iqtree/iqtree2#459.

Implementation details:

  • Fix a latent bug in the PhyloTreeMixlen::computeFuncDerv() function by switching the condition for using the base class-version function from if (cur_mixture < 0) to if (initializing_mixlen) and by asserting that cur_mixture is set. The rationale is that the base class-version function should be called only when the heterotachy model is not used yet, i.e. when initializing_mixlen is true. Otherwise, it would, in turn, call PhyloTree::computeLikelihoodDerv(Generic)SIMD() that would run in the mixlen mode, thus returning partial derivatives instead of the single ordinary derivative. Also, the unused code duplicating the one from phylokernelnew.h is now removed from this function.
  • In the PhyloTree::computeLikelihoodDerv(Generic)SIMD() function, in the if (isMixlen()) branch, duplicate the if (SITE_MODEL) block of the else branch with the only difference that the length is considered category-specific here. Make the two code branches more similar.
  • Change ->length to ->getLength(c) throughout the phylokernelnew.h code, most importantly in the if (SITE_MODEL) blocks, to ensure that all computations are compatible with the mixlen mode.
  • For now, the PMSF model can be run only under the BFGS optimization of heterotachous branch lengths. Users running the default command with the EM algorithm will get the annoying error message advising switching to the BFGS algorithm. This inconvenience is intended to make the users informed that they have to run the optimization algorithm different from the one used in the original GHOST model paper. However, in another upcoming pull request, I am going to make the EM optimization work as well, so the restriction should be lifted soon.

A simple test to check the new likelihood calculations:
Run cmd1: iqtree3 --seed 123 -nt 1 -s aln.faa -m LG+F+H2 -optlen BFGS --keep-ident -pre test_LG_F_H
and cmd2: iqtree3 --seed 123 -nt 1 -s aln.faa -m LG+H2 -fs empty.sitefreq -optlen BFGS --keep-ident -pre test_LG_SSF_H,
where empty.sitefreq is literally an empty text file:

$ wc empty.sitefreq
0 0 0 empty.sitefreq

This two runs should have exactly the same likelihood, tree, and parameter estimates, since -fs empty.sitefreq activates a +SSF model that uses the +F state probability vector for each alignment pattern, which simulates the simpler +F model yet using site-specific computations.

@StefanFlaumberg

Copy link
Copy Markdown
Contributor Author

@bqminh,
I was hoping it'd be included in the v3.1.3 release...

@bqminh

bqminh commented Jun 19, 2026

Copy link
Copy Markdown
Member

I'm reviewing this now ... it's touching the kernel, so need be to thorough

@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 great. thanks. Suggestion: for future pull requests, better separate into smaller PRs, instead of combining many into one.

@bqminh bqminh merged commit 6401e06 into iqtree:master Jun 19, 2026
5 of 7 checks passed
@bqminh

bqminh commented Jun 19, 2026

Copy link
Copy Markdown
Member

It's now released in v3.1.3

@StefanFlaumberg

Copy link
Copy Markdown
Contributor Author

It's now released in v3.1.3

@bqminh, thank you!

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