Package: online-beast
online-BEASTThis command line tool can be used to add sequences to an ongoing analysis in BEAST2. This framework is called online Bayesian phylodynamic inference (seeGill et al., 2020).InstallInstallonline-beastwith pip (requires python -V >= 3.6.2).pipinstallonline-beastUsageGiveonline-beastbeast the path to a XML file from a previous BEAST2 run (i.e. one that has an associated.statefile) and a fasta file of sequences to add to the analysis. Sequences in the fasta file must be aligned (i.e. to the sequences in the XML file) and the same length as the other sequences in the XML file. Only new sequences (new descriptors) will be added to the analysis, so new sequences can be append to the fasta file as they are acquired.online-beastdata/testGTR.xmldata/samples.fastaThe new sequences will by added to the XML file and the associated.statefile (produced automatically by BEAST2).The analysis can then be resumed (with the additional sequence data) using the BEAST2 resume flag.beast-resumetestGTR.xmlThe online analysis can be visualised in real-time usingBeastiary. The jumps in the trace show where new sequences have been added.Date trait data will be automatically parsed. The format of the date trait data (in the fasta descriptor) can be set with the--date-format(default%Y-%m-%d) and--delimiter(default_) flags. If there is no date trait in the xml use the--no-date-traitflag.online-beast data/ebola.xml data/ebola.fasta --dateformat %d/%m/%Y --date-delimiter _If there is trait data in the XML file you need to specify how to extract it from the fasta descriptor line using the--traitflag. The format is'traitname delimiter group'e.g. a string separated by spaces. For example to get thelocationtrait fromsample_wuhan_2022-04-05you would use--trait 'location _ 1'. The--traitflag can be used multiple times to specify multiple traits.online-beastcovid.xmldata/covid.fasta--trait'location _ 1'By default the new sequences will be appended to the input XML and state files. Output file names can be specified using the--outputflag. This will also create a new.statefile.online-beasttestGTR.xmlsamples.fasta--outputnew_testGTR.xmlIf you use the BEAST2-statefileflag to specify the filename of the state (i.e. it is notxml_filename + .state). Use the flag--state-fileto specify the state file path.online-beasttestGTR.xmlsamples.fasta--state-filebeast.stateExplanationA Markov chain started anywhere near the center of the stationary distribution needs no burn-in (Geyer 2011). Online Bayesian phylodynamic inference is akin to transfer learning in the deep learning field. By starting our MCMC with reasonable states (obtained from a previous run) we reduce the amount of optimisation (burn-in) that must be performed to reach convergence.Online-beast loosely follows the implementation ofGill et al., 2020for BEAST1. However, most of the implementation of online-beast is handled by the default state system in BEAST2. New sequences are added from the fasta file one at a time. The hamming distance is calculated between the new sequence and all the other sequences in the XML file. The new sequence is grafted onto the tree in the.statefile, half way along the branch of the closest sequence in the XML file. The new sequence is append to the BEAST XML file.Ebola exampleIn this example we will make use of a publicly available dataset of sequences from the 2013-2016Zaire ebolavirusoutbreak in Sierra Leone.In thedata/folder you'll find aebola.xmlfile and several fasta files that contain sequences from the outbreak broken up by date. The script below will run an online Bayesian phylodynamic analysis adding new sequences after each run finishes.#!/bin/bash# Run beast with initial samplesbeastdata/ebola.xml# Update analysis with new samplesonline-beastdata/ebola.xmldata/ebola1.fasta--date-format"%d/%m/%Y"--state-fileebola.xml.state--outputebola.xml# Resume the analysisbeast-resumeebola.xml# Update analysis with new samplesonline-beastebola.xmldata/ebola2.fasta--date-format"%d/%m/%Y"--outputebola.xml# Resume the analysisbeast-resumeebola.xml# Update analysis with new samplesonline-beastebola.xmldata/ebola3.fasta--date-format"%d/%m/%Y"--outputebola.xml# Resume the analysisbeast-resumeebola.xml