Learn R Programming

phylosim (version 3.0.5)

exportStatTree.PhyloSim: Export the per-branch counts of an event as a phylo object

Description

Export the per-branch counts of an event as a phylo object.

During simulation the number of events performed on every branch is recorded. The recorded events can be "basic" events, like "insertion", "deletion" and "A->T" or events which are sums of basic events, like "substituion". The getBranchEvents method returns a character vector with the names of the events having per-branch statistics recorded. The method should be called after the simulation is finished.

The per-branch statistics can be exported as phylo objects by using the exportStatTree method. The branch lengths of the exported phylo objects are set to the value of the respective per-branch event count.

Usage

# S3 method for PhyloSim
exportStatTree(this, event, ...)

Arguments

this

A PhyloSim object.

event

The name of the event as returned by the getBranchEvents method.

...

Not used.

Value

A phylo object.

See Also

For more information see PhyloSim.

Examples

Run this code
# NOT RUN {
	# Create a PhyloSim object.
	# Provide the phylo object
	# and the root sequence.

	# NOTE: this will be a little bit slow
	sim<-PhyloSim(
		phylo=rcoal(3),
		root.seq=CodonSequence(
                               string="ATGATTATT",
                               processes=list(list(GY94(kappa=2,omega.default=0.5)))
                               )
	);
	# make the tree longer to have more events
	scaleTree(sim,5)
	# plot the tree
	plot(sim)
	# run simulation
	Simulate(sim)
	# get the list of recorded per-branch event counts
	getBranchEvents(sim)
	# export the number of substitutions as a phylo object
	subst<-exportStatTree(sim,"substitution")
	# plot the exported phylo object
	plot(subst)
	#export the number of synonymous substitutions as a phylo object
	subst<-exportStatTree(sim,"nr.syn.subst")
	# plot the exported phylo object
	plot(subst)
 
# }

Run the code above in your browser using DataLab