Ancestral state reconstruction in *BEAST (ambiguities)

282 views
Skip to first unread message

Luiz JQ

unread,
Nov 16, 2017, 2:01:54 PM11/16/17
to beast-users

Dear all,

I’ve been trying to reconstruct ancestral states of a given trait using *Beast (v 2.4.7).

When I don’t set ambiguities in the XML file, it runs smoothly. However, when I include them, I always get an error message. I’ve trying to find an effective solution from the beast-users’ discussion, but I can’t succeed. That’s why I’m asking this here. Maybe someone could give me a little help.

Basically, I included the flag useAmbiguities=”true”, and added a new code.

Below, you can see the part of the XML file where the modifications have been done, and then the error message.

Many thanks in advance.



<distribution id="traitedtreeLikelihood.area" spec="AncestralStateTreeLikelihood" tag="location" tree="@Tree.t:Species" useAmbiguities="true">

                <data

id="area"

spec="AlignmentFromTrait">

                    <traitSet id="traitSet.area" spec="beast.evolution.tree.TraitSet" taxa="@taxonsuperset" traitname="discrete">sp1=ori,

sp2=aml_mad,

sp3=gui,

sp4=mar,

sp5=aml,

sp6=mad,

sp7=aml</traitSet>

                    <userDataType id="traitDataType.area" spec="beast.evolution.datatype.UserDataType" codeMap="aml=0,gui=1,mad=2,mar=3,ori=4,aml_mad = 0 2, ? = 0 1 2 3 4 " codelength="-1" states="5"/>




        Sample      posterior ESS(posterior)     likelihood          prior

Fatal exception: null

java.lang.NullPointerException

at java.lang.System.arraycopy(Native Method)

at beast.evolution.likelihood.BeerLikelihoodCore.getNodeStates(Unknown Source)

at beast.evolution.likelihood.AncestralStateTreeLikelihood.traverseSample(Unknown Source)

at beast.evolution.likelihood.AncestralStateTreeLikelihood.traverseSample(Unknown Source)

at beast.evolution.likelihood.AncestralStateTreeLikelihood.traverseSample(Unknown Source)

at beast.evolution.likelihood.AncestralStateTreeLikelihood.traverseSample(Unknown Source)

at beast.evolution.likelihood.AncestralStateTreeLikelihood.traverseSample(Unknown Source)

at beast.evolution.likelihood.AncestralStateTreeLikelihood.traverseSample(Unknown Source)

at beast.evolution.likelihood.AncestralStateTreeLikelihood.redrawAncestralStates(Unknown Source)

at beast.evolution.likelihood.AncestralStateTreeLikelihood.getStatesForNode(Unknown Source)

at beast.evolution.likelihood.AncestralStateTreeLikelihood$1.getTraitString(Unknown Source)

at beast.evolution.tree.TreeWithTraitLogger.toNewick(Unknown Source)

at beast.evolution.tree.TreeWithTraitLogger.toNewick(Unknown Source)

at beast.evolution.tree.TreeWithTraitLogger.toNewick(Unknown Source)

at beast.evolution.tree.TreeWithTraitLogger.toNewick(Unknown Source)

at beast.evolution.tree.TreeWithTraitLogger.toNewick(Unknown Source)

at beast.evolution.tree.TreeWithTraitLogger.toNewick(Unknown Source)

at beast.evolution.tree.TreeWithTraitLogger.log(Unknown Source)

at beast.core.Logger.log(Unknown Source)

at beast.core.MCMC.log(Unknown Source)

at beast.core.MCMC.propagateState(Unknown Source)

at beast.core.MCMC.doLoop(Unknown Source)

at beast.core.MCMC.run(Unknown Source)

at beast.app.BeastMCMC.run(Unknown Source)

at beast.app.beastapp.BeastMain.<init>(Unknown Source)

at beast.app.beastapp.BeastMain.main(Unknown Source)

at beast.app.beastapp.BeastLauncher.main(Unknown Source)

Fatal exception: null

Luiz JQ

unread,
Nov 20, 2017, 12:02:50 PM11/20/17
to beast-users
I tried to run the same xml file, but without the flag useAmbiguities="true". It ran. However, the analysis is estimating the most likely distribution area for the the sp2 between the two I gave with my ambiguous code (sp2=aml_mad), instead of considering a priori both areas as true distribution areas. So, I suppose that somehow I must include the flag. Am I wright? 

Remco Bouckaert

unread,
Nov 27, 2017, 3:35:02 AM11/27/17
to beast...@googlegroups.com
Hi Luiz,

Thanks for the XML, that was helpful in finding the problem. There was a bug in the ancestral state reconstruction code when not using BEAGLE. I think I fixed it now, and when you update to BEAST_CLASSIC v1.3.1 your file should run.

However, given you have just 7 taxa in the species tree from 5 locations, and one of the tips is ambiguous, it will be very hard to say something about ancestral states based on this information alone. You might consider reducing the number of locations, or use a diffusions based geographical reconstruction instead (if a random walk model is appropriate for your species).
Cheers,

Remco



On 21/11/2017, at 6:02 AM, Luiz JQ <ljq...@gmail.com> wrote:

I tried to run the same xml file, but without the flag useAmbiguities="true". It ran. However, the analysis is estimating the most likely distribution area for the the sp2 between the two I gave with my ambiguous code (sp2=aml_mad), instead of considering a priori both areas as true distribution areas. So, I suppose that somehow I must include the flag. Am I wright? 

--
You received this message because you are subscribed to the Google Groups "beast-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beast-users...@googlegroups.com.
To post to this group, send email to beast...@googlegroups.com.
Visit this group at https://groups.google.com/group/beast-users.
For more options, visit https://groups.google.com/d/optout.

Luiz JQ

unread,
Nov 27, 2017, 5:40:46 AM11/27/17
to beast-users
Many thanks, Remco!
I updated beast_classic and it ran. 
Thank you for the advice as well. In fact, this is just a pilot analysis to make sure that it runs smoothly before running with the complete dataset. I have ~100 taxa distributed among ~300 samples. I'll see if it's enough for a good reconstruction soon.   
Have a nice week
Luiz

zany...@gmail.com

unread,
Apr 29, 2024, 5:44:22 AM4/29/24
to beast-users
Hello Dr Bouckaert,

I have a similar problem with multiple discrete states not being recognized. I am using BEAST_CLASSIC 1.5.0 with Beagle 3.1.0 and have included and excluded useAmbiguities="true", but either way I get an error in the attached screen output

Could I please have some help setting up the discrete states?

Best,

Zaynab


                        BEAST v2.6.7, 2002-2022
             Bayesian Evolutionary Analysis Sampling Trees
                       Designed and developed by
 Remco Bouckaert, Alexei J. Drummond, Andrew Rambaut & Marc A. Suchard
                                   
                   Centre for Computational Evolution
                         University of Auckland
                       r.bou...@auckland.ac.nz
                        ale...@cs.auckland.ac.nz
                                   
                   Institute of Evolutionary Biology
                        University of Edinburgh
                           a.ra...@ed.ac.uk
                                   
                    David Geffen School of Medicine
                 University of California, Los Angeles
                           msuc...@ucla.edu
                                   
                      Downloads, Help & Resources:
                           http://beast2.org/
                                   
  Source code distributed under the GNU Lesser General Public License:
                   http://github.com/CompEvol/beast2
                                   
                           BEAST developers:
   Alex Alekseyenko, Trevor Bedford, Erik Bloomquist, Joseph Heled,
 Sebastian Hoehna, Denise Kuehnert, Philippe Lemey, Wai Lok Sibon Li,
Gerton Lunter, Sidney Markowitz, Vladimir Minin, Michael Defoin Platel,
          Oliver Pybus, Tim Vaughan, Chieh-Hsi Wu, Walter Xie
                                   
                               Thanks to:
          Roald Forsberg, Beth Shapiro and Korbinian Strimmer

Random number seed: 1714383499870

Alignment(Disparago_ericoides_locus-17_aligned_taper)
  135 taxa
  1265 sites
  491 patterns

Starting frequencies: [0.2795511809463119, 0.17589763818718127, 0.21128346477161758, 0.33326771609540995]
  Using BEAGLE version: 3.1.0 resource 0: CPU
    with instance flags:  PRECISION_DOUBLE COMPUTATION_SYNCH EIGEN_REAL SCALING_MANUAL SCALERS_RAW VECTOR_SSE THREADING_NONE PROCESSOR_CPU FRAMEWORK_CPU
Amphiglossa_celans_S1.1_SK = SK (NaN)
Amphiglossa_celans_S1_SK = SK (NaN)
Amphiglossa_foliosa_S3.1_SK = SK (NaN)
Amphiglossa_foliosa_S3_SK = SK (NaN)
Amphiglossa_grisea_S4.1_NW = NW (NaN)
Amphiglossa_grisea_S4_NW = NW (NaN)
Amphiglossa_tomentosa_S11.1_NW_KM = NW_KM (NaN)
Amphiglossa_tomentosa_S11_NW_KM = NW_KM (NaN)
Amphiglossa_tomentosa_S12.1_NW_KM = NW_KM (NaN)
Amphiglossa_tomentosa_S12_NW_KM = NW_KM (NaN)
125 more...

Error 110 parsing the xml input file

validate and intialize error: Could not find code NW_KM in codemap

Error detected about here:
  <beast>
      <run id='mcmc' spec='MCMC'>
          <distribution id='posterior' spec='util.CompoundDistribution'>
              <distribution id='likelihood' spec='util.CompoundDistribution'>
                  <distribution id='traitedtreeLikelihood.Lojava.lang.IllegalArgumentException: Could not find code NW_KM in codemap
at beast.evolution.datatype.DataType$Base.stringToEncoding(Unknown Source)
at beast.evolution.datatype.DataType$Base.string2state(Unknown Source)
at beast.evolution.alignment.AlignmentFromTrait.initAndValidate(Unknown Source)
at beast.util.XMLParser.initBEASTObjects(Unknown Source)
at beast.util.XMLParser.parse(Unknown Source)
at beast.util.XMLParser.parseFile(Unknown Source)
at beast.app.BeastMCMC.parseArgs(Unknown Source)
at beast.app.beastapp.BeastMain.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at beast.app.beastapp.BeastLauncher.run(Unknown Source)
at beast.app.beastapp.BeastLauncher.main(Unknown Source)
cation' spec='AncestralStateTreeLikelihood'>
                      <data id='Location' spec='AlignmentFromTrait'>

Reply all
Reply to author
Forward
0 new messages