Description Usage Value Author(s) See Also Examples
Generate starting tree with tips that correspond to the taxa in df
. See Examples.
1 2 | beast.get.startingtree(ph, df, starttree.rootHeight = NA, origin.value = NA,
verbose = 1)
|
Starting tree in newick format
Oliver Ratmann
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | require(rBEAST)
infile.seq <- system.file(package="rBEAST", 'extra','sim_150416_seq.R')
infile.tree <- system.file(package="rBEAST", 'extra','sim_150416_njtree.R')
infile.xml.template <- system.file(package="rBEAST", 'xml_templates','BEAST_template_um192rhU2080.xml')
outdir.xml <- getwd()
outfile.xml <- 'sim_150416_um192rhU2080.xml'
# load data
load(infile.seq)
# expect data.table "df.seq" with columns
# "TAXON_ID" taxon ID
# "TAXON_NAME" taxon name
# "SAMPLINGTIME" taxon sampling time
# "GAG" gag sequence as character string
# "POL" pol sequence as character string
# "ENV" env sequence as character string
# "CLU_ID" phylogenetic cluster ID of sequence
# use POL sequences
setnames(df.seq,'POL','SEQ')
# load tree
load(infile.tree)
# expect ape tree 'ph'
# illustrate automatic generation of multiple XML files, each for one pool of sequences
# with monophyly constraints on phylogenetic clusters.
# with this option, an appropriate starting tree should be specified
#
# group clusters into separate pools
df.clupool <- beast.pool.clusters(df.seq, how='by.samplingtime', pool.ntip=300, verbose=1)
# generate XML file from template
for( pid in seq_along(df.clupool) )
{
df <- df.clupool[[pid]]
# get newick start tree for all sequences in pool
start.tree <- beast.get.startingtree(ph, df, verbose=1)
# get xml file from template
bxml <- beastxml.from.template(infile.xml.template, df, start.tree=start.tree, xml.taxonsets4clusters=1, xml.monophyly4clusters=1, verbose=1)
# adjust xml file depending on the template that is used
beast.adjust.gmrfSkyrideLikelihood(bxml, df, verbose=1)
beast.adjust.prior.rootheight(bxml, df, rootHeight.idref='treeModel.rootHeight', verbose=1)
beast.adjust.mcmc(bxml,
mcmc.chainLength=beast.mcmc.chainLength,
mcmc.logEvery=beast.mcmc.chainLength/1e4,
mcmc.outfile=gsub('.xml', paste('_pool',pid,'.xml',sep=''),outfile.xml),
verbose=1)
# write to file
saveXML(bxml, file=paste(outdir.xml,gsub('.xml', paste('_pool',pid,'.xml',sep=''),outfile.xml),sep='/'))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.