Re: [R-sig-phylo] Determining Order of Trait Evolution

2024-02-02 Thread O'Meara, Brian C
One could constrain the discrete model and then compare different ones using 
AICc or similar:

0 -> 1 <=>  2

vs

2->1->0

and so forth.

I worry about the univariate ancestral state estimation approach because it 
does a reconstruction using a particular model (one where the traits are 
independent) and then tries to figure out from reconstructions under that model 
if there is correlation; it’s also asking a ton of the data (take N datapoints, 
estimate the parameters for the model AND N-1 reconstructions). There’s also 
issues from branch lengths: one expects more changes on longer branches, so one 
could find associations of changes between the characters driven by tree 
structure rather than true correlation (though parametric bootstrapping could 
help assess the null expectation, much like what Heath is suggesting). Also 
worth noting that a single stochastic character mapping is just one instance of 
a possible ancestral history – it’s not the likeliest reconstruction of states 
at nodes nor changes along edges (though one could do a bunch and the 
distribution of those should give you a good estimate of the relative 
likelihoods of changes along edges).

Best,
Brian
_

Brian O’Meara
He/Him
Professor, Dept. of Ecology & Evolutionary Biology
University of Tennessee, Knoxville


From: Rafael S Marcondes 
Date: Friday, February 2, 2024 at 1:45 PM
To: O'Meara, Brian C 
Cc: r-sig-phylo 
Subject: Re: [R-sig-phylo] Determining Order of Trait Evolution
I've read the hOUwie paper, but it wasn't clear to me that it allowed 
estimating the *order* of changes.

Thanks,

-Rafa

--
Rafael S. Marcondes, Ph.D.
https://www.rafaelmarcondes.com/
Faculty Fellow in EEB
Department of BioSciences
Rice University
Houston TX 77005

Pronouns: he/him

"Eu quase que nada não sei. Mas desconfio de muita coisa"
"I almost don't know nothing. But I suspect many things"
  -João Guimarães Rosa, Brazilian novelist
(Portuguese original and free English translation by me)


On Fri, Feb 2, 2024 at 12:42 PM O'Meara, Brian C 
mailto:bome...@utk.edu>> wrote:
Isn’t that what houwie does (which is fairly recently published)? 
https://doi.org/10.1093/evolut/qpad002

Note my conflict of interest as a coauthor.

Best,
Brian

_

Brian O’Meara
He/Him
Professor, Dept. of Ecology & Evolutionary Biology
University of Tennessee, Knoxville


From: R-sig-phylo 
mailto:r-sig-phylo-boun...@r-project.org>> 
on behalf of Rafael S Marcondes 
mailto:raf.marcon...@gmail.com>>
Date: Friday, February 2, 2024 at 1:06 PM
To: r-sig-phylo mailto:r-sig-phylo@r-project.org>>
Subject: Re: [R-sig-phylo] Determining Order of Trait Evolution
Hi all,

This is a reply to an ancient thread that I pasted below. My question is
the same as the original one: how to determine the relative order of
changes between a discrete and a continuous traits. I came up with the
approach I describe below (inspired by Heath Blackmon in the original
thread), but I don't feel great about it. So I was wondering if anything
better has been developed since, or if anyone has any better ideas.

Here's what I've got:

Next, we will test hypothesis 3, that transitions in [discrete trait] occur
proximate in time to changes in [continuous trait]. To do that, we will
adapt the approach from Blackmon et al. (2015). Briefly, we will first
conduct ancestral state estimation of the discrete trait using stochastic
character mapping (Huelsenbeck et al. 2003) in phytools, and separately an
ancestral state estimation of each continuous trait using the function ace
in the package ape (Paradis et al 2023). We will then assess whether the
continuous trait displayed a tendency of change either before or after each
discrete transition: we will extract the value of the continuous trait at
each discrete trait transition, as well as in the immediate parent and
ancestral nodes, and calculate the difference between the latter trait
values and the value at the transition. We will also generate a null
distribution by doing the same based on points sampled randomly along the
tree. The overlap between distribution of continuous trait value-changes
immediately before/after a transition and the continuous trait
value-changes immediately before/after random points will determine if the
two characters tend to change near each other in time. For example, if the
distribution of continuous trait value-changes immediately before a
discrete transition shows little overlap with the random distribution, that
would indicate that changes in [redacted continuous-valued] morphology tend
to precede changes in [redacted discrete valued ecology]. Likewise, if the
distribution of continuous trait value-changes immediately after a discrete
transition shows little overlap with the random distribution, that would
indicate that changes in [redacted continuous-valued] morphology tend
instead to fo

Re: [R-sig-phylo] Determining Order of Trait Evolution

2024-02-02 Thread O'Meara, Brian C
Isn’t that what houwie does (which is fairly recently published)? 
https://doi.org/10.1093/evolut/qpad002

Note my conflict of interest as a coauthor.

Best,
Brian

_

Brian O’Meara
He/Him
Professor, Dept. of Ecology & Evolutionary Biology
University of Tennessee, Knoxville


From: R-sig-phylo  on behalf of Rafael S 
Marcondes 
Date: Friday, February 2, 2024 at 1:06 PM
To: r-sig-phylo 
Subject: Re: [R-sig-phylo] Determining Order of Trait Evolution
Hi all,

This is a reply to an ancient thread that I pasted below. My question is
the same as the original one: how to determine the relative order of
changes between a discrete and a continuous traits. I came up with the
approach I describe below (inspired by Heath Blackmon in the original
thread), but I don't feel great about it. So I was wondering if anything
better has been developed since, or if anyone has any better ideas.

Here's what I've got:

Next, we will test hypothesis 3, that transitions in [discrete trait] occur
proximate in time to changes in [continuous trait]. To do that, we will
adapt the approach from Blackmon et al. (2015). Briefly, we will first
conduct ancestral state estimation of the discrete trait using stochastic
character mapping (Huelsenbeck et al. 2003) in phytools, and separately an
ancestral state estimation of each continuous trait using the function ace
in the package ape (Paradis et al 2023). We will then assess whether the
continuous trait displayed a tendency of change either before or after each
discrete transition: we will extract the value of the continuous trait at
each discrete trait transition, as well as in the immediate parent and
ancestral nodes, and calculate the difference between the latter trait
values and the value at the transition. We will also generate a null
distribution by doing the same based on points sampled randomly along the
tree. The overlap between distribution of continuous trait value-changes
immediately before/after a transition and the continuous trait
value-changes immediately before/after random points will determine if the
two characters tend to change near each other in time. For example, if the
distribution of continuous trait value-changes immediately before a
discrete transition shows little overlap with the random distribution, that
would indicate that changes in [redacted continuous-valued] morphology tend
to precede changes in [redacted discrete valued ecology]. Likewise, if the
distribution of continuous trait value-changes immediately after a discrete
transition shows little overlap with the random distribution, that would
indicate that changes in [redacted continuous-valued] morphology tend
instead to follow changes in [redacted discrete valued ecology].

Thanks!

-Rafa

*--*
*Rafael S. Marcondes, Ph.D.*
*https://www.rafaelmarcondes.com/ *
Faculty Fellow in EEB
Department of BioSciences
Rice University
Houston TX 77005

Pronouns: he/him


*"Eu quase que nada não sei. Mas desconfio de muita coisa"*
*"I almost don't know nothing. But I suspect many things"*
  -João Guimarães Rosa, Brazilian novelist
(Portuguese original and free English translation by me)

Heath Blackmon

 Mon, 04 Apr 2016 13:26:02 -0700


An alternative that doesn't require discretization of the continuous trait
would be an approach I used
inhttp://onlinelibrary.wiley.com/doi/10./evo.12792/abstract.
Briefly you
do standard ASR of both traits (continuous = ML brownian motion; discrete =
stochastic mappings) independently. Then extract the continuous trait value
distribution at inferred transition points & compare to a null generated by
simulating the discrete trait. If your interested in doing this  email me
off list and I can give you the latest version of the code for doing this
using phytools stochastic mapping results.

Cheers

Heath

On Monday, April 4, 2016, Alejandro Gonzalez Voyer
 wrote:

> Hello Gavin,
>
> You could have a look at the method for evolutionary contingency, which
> works only for binary traits (meaning you’d have to transform your
> continuous trait into a binary one). See Pagel and Meade 2006 (Bayesian
> Analysis of Correlated Evolution of Discrete Characters by Reversible-Jump
> Markov Chain Monte Carlo in Am Nat) for details on the method.
> Note that it will provide information on whether evolutionary transitions
> in trait state for one of the traits is contingent on the state of the
> second one. You can infer the probable history of transitions from the
> results. However, you should be careful as the method is sensitive to
> trait-state distribution.
>
> Cheers
>
> Alejandro
>
>
>
> ___
> Dr Alejandro Gonzalez Voyer
>
> Laboratorio de Conducta Animal
> Instituto de Ecología
> Circuito Exterior S/N
> 

Re: [R-sig-phylo] ancestral state reconstruction with a complex discrete trait

2022-11-14 Thread O'Meara, Brian C
In addition to the ideas so far, there is also corHMM. 
https://rdrr.io/cran/corHMM/man/corHMM.html is the main help for this, but you 
can also use corHMM::ancRECON, corHMM:rayDISC, and corHMM:corDISC. 
corHMM::plotRECON can plot ancestral state reconstructions.

For tip uncertainty, you can do 0&1 if you don�t know if the tip is state 0 or 
1, but that it is definitely not 2. You can also create models, so if you think 
the rates are 0 -> 01 <-> 1 <-> 2, you can fit that and then reconstruct states 
using that model. And of course the �HMM� is for hidden Markov models, so you 
can allow for rate heterogeneity over the tree.

Some things to remember with ancestral state reconstruction in general:


  1.  Results are really uncertain. Yes, you get some measurement of 
uncertainty, but it�s an underestimate: is your topology perfect? Branch 
lengths? Rate estimates? All of those are typically not included in the 
uncertainty estimation (well, rate uncertainty would be in most Bayesian 
approaches). And �all models are wrong� [there may be a longer version of the 
quote�] � it could be that certain states are not possible until after the 
Cretaceous, etc. but if that�s not built into the model, it doesn�t know that.
  2.  There was a dispute in the field on handling tip uncertainty. corHMM / 
hisse follow Felsenstein�s advice (from his book): if you don�t know if a state 
is 2 or 3 at a tip, the probability of seeing a 2 or a 3 at the tip is 100% 
when calculating the likelihood (the probability of the data). Some software in 
this space assumes it is 50% (but I haven�t checked in a few years, maybe it�s 
been updated?). It�s not clear what the effect of this difference in practice 
is.
  3.  Remember Maddison 
(2007), on confounding 
asymmetries. Your ancestral state estimates can be wrong if you assume there�s 
no differential diversification processes and use character-only models, and 
they can be wrong if you assume there�s no differential trait evolution 
processes and use diversification-only models. So, you can use joint models 
like in hisse or diversitree, but those might need more data to fit well than 
you have.
  4.  Your tree has N tips. You are trying to estimate some number of rates, 
while also reconstructing N-1 ancestral states (more if you want to try to 
understand what�s happening within branches, like with stochastic character 
mapping). This is� bold, to say the least. It could be that the question could 
be answered by looking at the rates alone: what�s the wait time between events, 
what are the magnitude of rates, etc.
  5.  Also note Maddison & FitzJohn 
(2015), which points to issues of 
inferring rates of correlation. Those rates are what are used for 
reconstructions� does the problem lead to problems in reconstruction?

Best,
Brian

_

Brian O�Meara
He/Him
Professor, Dept. of Ecology & Evolutionary Biology
University of Tenneseee, Knoxville


From: R-sig-phylo  on behalf of roee maor 

Date: Monday, November 14, 2022 at 6:37 AM
To: r-sig-phylo@r-project.org 
Subject: Re: [R-sig-phylo] ancestral state reconstruction with a complex 
discrete trait
[You don't often get email from roeem...@gmail.com. Learn why this is important 
at https://aka.ms/LearnAboutSenderIdentification ]

Hi Chris,
I sent this message a few days ago but can't see any sign that it was
received so trying again. Apologies if anyone ends up seeing both.

To the question- in addition to the other (good) solutions given in this
thread, both HiSSE (R package) and BayesTraits (stand alone software) can
handle ASR of multi-level categorical traits.

I have used BayesTraits with option "Multi" for ASRs of traits with 3 and 4
states. Can't remember any limitations on using it for traits that take a
larger number of character states (but it was a while ago I admit).

Using HiSSE, coding your response character should be fairly
straightforward depending on the number of character states you're looking
at. If you have a trait with 4 observed states as you mention, it seems to
me that there is an implied assumption that transitions between "black" and
"white" must go through either "gray" (mixed) or "black-and-white"
(patched). In this case you can encode observed phenotypes as {00} ,{01},
{10}, {11} and disable transitions between any two states (e.g. between
{01} and {10}) based on your biological model/hypotheses.

The original HiSSE paper (Beaulieu & O'Meara 2016 Syst. Biol.) is very
clear, there is a helpful online tutorial. Nakov, Beaulieu & Alverston
(Evolution, 2019) was also useful to me.

HTH,
Roi

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org

Re: [R-sig-phylo] Fitting models with continous characteres

2021-05-18 Thread O'Meara, Brian C
Dear Sim�n,

Typically people do this by �painting� regimes on the tree using the discrete 
trait and then trying different OU models for the different regimes. For 
example, does being in the island regime lead to a higher rate of evolution 
(bigger sigma in the BMS model) than being in the mainland? Is rate difference 
large enough in magnitude to be biologically relevant? The discrete trait 
reconstruction can be done using likelihood (using stochastic character maps or 
a joint or marginal reconstruction) or parsimony. This does have problems: the 
discrete reconstruction is done �greedily� ignoring its effect on the 
continuous trait, and like all ancestral state reconstruction it can have error 
(so, for example, some branches painted �island� are actually �mainland�). See 
Revell (2003) (https://doi.org/10.1093/sysbio/sys084) for more about the 
potential deleterious effects. There�s work on fixing it (watch for a talk by 
James Boyko at Evolution in June, though James� work does more than just �fix�).

There are a couple of other issues you might encounter. First, OU/BM models 
aren�t great for proportions. They assume that a trait can increase or decrease 
by, say, 17, no matter its current value [though with OU, the probability of 
the change will vary based on where the trait is relative to theta]. If 
proportions are near the bounds, the bounds affect the motion: no species can 
spend 110% of its time on head bob displays. If they�re near the lower bound 
and don�t �feel� the upper bound, then perhaps just log transforming it as for 
other zero bounded traits is appropriate enough.

The second is the data set size of just 8 taxa. It could be enough if you have 
a ton of independent traits that evolve under the same model, but if not, 
you�re looking at something like 8 datapoints for fitting a model of, if say 
OUM with two regimes, 5 parameters. OUwie will give you warnings about this but 
still let you run it, but expect at best enormous uncertainty in parameter 
estimates, and possibly unidentifiability (OUwie now warns about some 
unidentifiability, but not all).

Best,
Brian

___
Brian O'Meara

Professor, Dept. of Ecology & Evolutionary Biology, UT Knoxville
Associate Head, Dept. of Ecology & Evolutionary Biology, UT Knoxville
President-Elect, Society of Systematic Biologists
He/Him/His


From: R-sig-phylo  on behalf of Simon Lobos 

Date: Sunday, May 16, 2021 at 9:39 PM
To: r-sig-phylo@r-project.org 
Subject: [R-sig-phylo] Fitting models with continous characteres
Dear all,



I am writing to seek for any advice with my phylogenetic comparative
analysis in behavioural traits.


I am trying to run an evolutionary model that contains other information
rather than BW, OU or EB. The variables I am using are continuous (time
proportion) and I want to fit them in a model that contains three different
scenarios: island effect, colonization time and sexual size dimorphism
(SSD).


I know I can do this kind of analysis with OUwie package from R, but I am
not so familiar with it, so I am having some issues setting up the
evolutionary model. I am working with eight species (2 from mainland and 6
from island). I am using this information to set up the island effect model
(1=island, 0=mainland), while for the colonization time I am using previous
published information (0=west, 1=east, 2=mainland). For the SSD model, I
plan to use my own morphological data collected from all my fieldwork
seasons (one value per species based on the SVL).


However, I am not sure how to include this information in the model using
OUwie package.


If any of you could help me with this I will really appreciate it.

--
Sim�n

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] units of sigsq

2021-03-19 Thread O'Meara, Brian C
(log(g)^2)/MY: it�s about the accumulation of variance with time, and variance 
has units squared.

And please don�t apologize for the question. You only have it because we as a 
field have been sloppy about not including units with our measurements in 
papers (I�m guilty of this, too). So it�s great that you�re doing the right 
thing and asking for help to do so.

Best,
Brian


___
Brian O'Meara

Professor, Dept. of Ecology & Evolutionary Biology, UT Knoxville
Acting Co-Head, Dept. of Ecology & Evolutionary Biology, UT Knoxville
President-Elect, Society of Systematic Biologists
He/Him/His



From: R-sig-phylo  on behalf of Karla Shikev 

Date: Friday, March 19, 2021 at 2:12 PM
To: R Sig Phylo Listserv 
Subject: [R-sig-phylo] units of sigsq
Dear all,

Please indulge me in a simple (newbie) question.

If I have a continuous trait (log(body size in g)) and a calibrated tree
and use fitContinuous to estimate sigsq using a BM model, what is the unit
of the siqsq estimate? log(g)/My?

Thanks for your patience,

Karla

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/