beastxml.from.template: Create BEAST XML file from template

Description Usage Arguments Author(s) Examples

Description

See Examples.

Usage

1
2
beastxml.from.template(btemplate, df, start.tree = NULL,
  xml.taxonsets4clusters = 1, xml.monophyly4clusters = 1, verbose = 1)

Arguments

btemplate

BEAST XML template or file name of BEAST XML template

df

Taxon data.table

start.tree

Starting tree containing the taxa in the taxon data.table (optional)

xml.taxonsets4clusters

If true, add taxon sets for each phylogenetic cluster in the taxon data.table

xml.monophyly4clusters

If true, add monophyly contraints to each phylogenetic cluster in the taxon data.table

verbose

If true, run in verbose mode

Author(s)

Oliver Ratmann

Examples

 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='/'))	
}

olli0601/rBEAST documentation built on May 24, 2019, 12:53 p.m.