Non-reversible models with branch-specific rates in v4.1?

8 views
Skip to first unread message

Joshua Mayoral

unread,
Sep 30, 2025, 4:08:30 PMSep 30
to bali-phy-users
Hi Ben,

Any possibility of updating the user's guide with a brief tutorial on using non-reversible substitution models with branch-specific insertion-deletion rates in version 4.1? 

I'd like to give these latest features a shot, but not quite sure how to setup those models based on the version 4.0 documentation. Apologies if I've missed their description somewhere.

Regards,
Josh

Benjamin Redelings

unread,
Oct 18, 2025, 3:12:49 PMOct 18
to bali-ph...@googlegroups.com, Joshua Mayoral

Hi Josh,

I'm sorry for the slow reply.  The short answer is that the syntax looks like this:

    bali-phy file.fasta -S nonrev --tree `~uniform_rooted_tree(taxa)`

Right now you have to specify the tree distribution manually because the default tree distribution is unrooted.  The root is going to be on an internal degree-3 node, not on a degree-2 node in the middle of a branch.  

You can use nonrev with rate heterogeneity models and write something like `-S 'nonrev +Rates.gamma'`, for example.  However, it seems that using it with covarion/markov-modulated models is not working quite right, so for the moment please don't do that. 

I will try and fix the combination with covarion/markov-modulated models and then put this into the users guide.

Note that model parameters for `nonrev` are the rates in the Q(i,j) not the exchangeabilities S(i,j) and the equilibrium frequencies pi(j).  I'm also computing and reporting pi(j) from Q -- if you have thoughts on what else should be logged, let me know.  Note that Q(i,j) is not expected to be symmetric even for reversible models -- instead it is Q(i,j)/pi(j) = S(i,j) that is symmetric for reversible models.  So possibly I should compute and log that in order to look at deviation from reversibility... thoughts?

-BenRI

--
You received this message because you are subscribed to the Google Groups "bali-phy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bali-phy-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bali-phy-users/f91736ad-8cbf-4186-b103-8dd77807d765n%40googlegroups.com.

Joshua Mayoral

unread,
Oct 20, 2025, 10:40:55 PMOct 20
to bali-phy-users
Hi Ben,

No worries, thank you for the detailed reply!

I think logging Q, pi, and deviation from reversibility would definitely be handy. Calculating deviation in the way you described reminds me of Fig. 5 from Dang et al, Sys Biol 2022 (nQMaker implementation in IQ-Tree). Seems logical to me.

Looking ahead to the covarion/markov-modulated modeling: would it be possible to estimate and log Q and pi for each branch, or is this impractical? My knowledge of markov-modulated models is limited, so apologies if this is a naive question. Depending on the dataset, I think it would be interesting to assess reversibility deviation in a branch-wise fashion.

Best,
Josh

Benjamin Redelings

unread,
Oct 31, 2025, 2:52:12 PM (9 days ago) Oct 31
to bali-ph...@googlegroups.com
Hi Josh,

I've fixed non-reversible markov-modulated models on the git master
branch.  So, you should be able to do for example:

    bali-phy file.fasta -S "nonRev +> Rates.gamma +> Covarion.hb02"
--tree '~uniform_rooted_tree(taxa)'

I also updated the documentation for nonRev and nonEq to the
documentation. (I renamed nonrev -> nonRev).  I've attached the PDF
here, but some information is only available when you install the new
version and type "bali-phy help nonRev".  Are you able to build the
version from git master?

On 10/20/25 10:40 PM, Joshua Mayoral wrote:
> I think logging Q, pi, and deviation from reversibility would
> definitely be handy. Calculating deviation in the way you described
> reminds me of Fig. 5 from Dang et al, Sys Biol 2022
> <https://academic.oup.com/sysbio/article/71/5/1110/6525257> (nQMaker
> implementation in IQ-Tree). Seems logical to me.

So far I ended up reporting flux and flow, where flow(i -> j) =
pi(i)Q(i,j) and flux(i ->j) = flow(i,j) - flow(j,i).  Flux is what the
nQMaker paper reports, and should be zero for reversible models.  I have
some ideas for other statistics, but I haven't implemented them yet.

> Looking ahead to the covarion/markov-modulated modeling: would it be
> possible to estimate and log Q and pi for each branch, or is this
> impractical? My knowledge of markov-modulated models is limited, so
> apologies if this is a naive question. Depending on the dataset, I
> think it would be interesting to assess reversibility deviation in a
> branch-wise fashion.

Can you clarify a bit what you are looking for here?  Also, I assume you
are looking at DNA instead of (say) amino-acid sequences?

Markov-modulated models let individual sites switch between different
evolutionary regimes over time.  But overall each branch has the same
regimes in the same proportion, although it might be different sites
that are occupying each regime.  So possibly you want to allow different
branches to have different models instead.

Letting every branch have completely independent parameters would be a
statistical problem, because there would be too many parameters and not
enough information to resolve them.  One possibility might be to allow
all branches to choose between two or three different Q matrices.

Another issue is just computing the likelihoods to run the model.  I
have some in-progress work on this.

-BenRI
>> <https://groups.google.com/d/msgid/bali-phy-users/f91736ad-8cbf-4186-b103-8dd77807d765n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "bali-phy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to bali-phy-user...@googlegroups.com.
> To view this discussion visit
> https://groups.google.com/d/msgid/bali-phy-users/e44cf175-5b3e-44f7-a19e-71cb00ec028en%40googlegroups.com
> <https://groups.google.com/d/msgid/bali-phy-users/e44cf175-5b3e-44f7-a19e-71cb00ec028en%40googlegroups.com?utm_medium=email&utm_source=footer>.
README.pdf

Joshua Mayoral

unread,
Nov 2, 2025, 8:51:24 PM (6 days ago) Nov 2
to bali-ph...@googlegroups.com
Hi Ben,

Thank you for the update. I was able to build version 4.2 from git master, and the "non-Rev help" command works on my build. 

Regarding the last point - I am looking to implement non-reversible models for amino acid alignments. Thank you for clarifying the way Markov-modulated models work. I was wanting to know whether each branch would have a unique Q matrix with the Markov-modulated models, but I didn't appreciate the issues arising from the large number of parameters.

- Josh

You received this message because you are subscribed to a topic in the Google Groups "bali-phy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bali-phy-users/cxBfN0NJELc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bali-phy-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bali-phy-users/643e6a7b-5445-487e-843d-f877f73b9afa%40gmail.com.

Benjamin Redelings

unread,
Nov 3, 2025, 11:43:34 AM (6 days ago) Nov 3
to bali-ph...@googlegroups.com, Joshua Mayoral

Hi Josh,

Great, glad to hear that it compiles and is working!

As you probably realize, inferring a non-reversible rate matrix for amino acids requires a LOT of data, even if all branches behave the same.  In the Bayesian context, too little data will manifest as wide credible intervals, where (for example) the credible interval for the flux always overlaps with 0.

-BenRI

Joshua Mayoral

unread,
Nov 3, 2025, 11:48:10 AM (6 days ago) Nov 3
to Benjamin Redelings, bali-ph...@googlegroups.com
Gotcha, thank you Ben!

I'll let you know if I encounter any issues with version 4.2

- Josh
Reply all
Reply to author
Forward
0 new messages