ropensci / babette

babette is an R package to work with BEAST2
https://docs.ropensci.org/babette
GNU General Public License v3.0
44 stars 6 forks source link

Example: tip dating #87

Closed ksw9 closed 4 years ago

ksw9 commented 4 years ago

Hi,

I'm writing to follow-up about a really helpful tip dating feature you added a while ago (thank you!). I used the tipdates_filename argument pointing towards a tab-delimited file of sample names and dates (attached), but am running into errors when I start running the XML in BEAST.

I define the model as follows:

# Define input model 
mean_sub_rate = 5.7694E-08
sd_sub_rate = (4.0324E-08 - 5.7694E-080)/2
sd_sub_rate

input_model = create_inference_model(
  site_model = create_gtr_site_model(),
  create_clock_model_strict(clock_rate_distr = create_log_normal_distr(m = mean_sub_rate, s = sd_sub_rate)),
  tree_prior = create_ccp_tree_prior(),
  mcmc = create_mcmc(chain_length = 1e8, store_every = 1000), 
  tipdates_filename = dates_filename
  )

# Use the default BEAUti settings to create a BEAST2 input file
create_beast2_input_file_from_model(
  input_filename,
  output_filename,
  inference_model = input_model 
 )

The error from BEAST:

Loading package BEAST v2.6.2

Error 170 parsing the xml input file

Could not find object associated with idref TaxonSet.G_VII_pre2003_msa

Error detected about here:
  <beast>
      <run id='mcmc' spec='MCMC'>
          <state id='state'>
              <tree id='Tree.t:cluster_10_dates' name='stateNode'>
                  <taxonset>

I believe this error has to do with specifying ids somewhere or not specifying the dates file with the appropriate syntax. Any suggestions would be great. Thank you in advance! Best,

tip_dating.zip

richelbilderbeek commented 4 years ago

Will answer today at around 17:00 Amsterdam time :+1:

richelbilderbeek commented 4 years ago

Note to self: TaxonSet.G_VII_pre2003_msa is probably a left-over from the tests. This is probably the first user that ever uses this feature (including me) :sunglasses:

richelbilderbeek commented 4 years ago

Note to self: Created repo richelbilderbeek/babette_issue_87

richelbilderbeek commented 4 years ago

Note to self: here is the bug:

<run id="mcmc" spec="MCMC" chainLength="3000" storeEvery="1000">
    <state id="state" storeEvery="5000">
        <tree id="Tree.t:cluster_10_dates" name="stateNode">
            <trait id="dateTrait.t:cluster_10_dates" spec="beast.evolution.tree.TraitSet" traitname="date-forward" value="2134-20-03-18-L-DNA-MTB-008988-S53-2017-06-22=2017,4151-13-03-18-L-DNA-MTB-008940-S13-2017-11-09=2017,4423-13-03-18-L-DNA-MTB-008950-S258-2017-10-10=2017,L-14-3447-S97-2014-07-11=2014,L-15-1237-S32-2015-06-03=2015,L-16-606-S90-2015-09-28=2015,T1-XX-2016-726-S164-2016-08-05=2016">
                <taxa id="TaxonSet.cluster_10_dates" spec="TaxonSet">
                    <alignment idref="cluster_10_dates"/>
                </taxa>
            </trait>
            <taxonset idref="TaxonSet.
        cluster_10_dates
        "/>
        </tree>
        <parameter id="clockRate.c:cluster_10_dates" name="stateNode">1.0</parameter>
        <parameter id="birthRate.t:cluster_10_dates" name="stateNode">1.0</parameter>
    </state>

Didn't immediately spot it? It's here:

            <taxonset idref="TaxonSet.
        cluster_10_dates
        "/>

That should have been one line. It appears cluster_10_dates has tabs at the start and end of it. Those should be removed :+1:

richelbilderbeek commented 4 years ago

Issue is fixed, I contacted and thanked @ksw9 for her help.

Done!

ksw9 commented 4 years ago

Thank you very much for the quick response! Tested and working! Best,

richelbilderbeek commented 4 years ago

Awesome, thanks :+1: