Learn R Programming

phylosim (version 3.0.5)

detachHookFromNode.PhyloSim: Detach a node hook function from a given node of a phylo object aggregated by a PhyloSim object

Description

Detach a node hook function from a given node of a phylo object aggregated by a PhyloSim object.

Usage

# S3 method for PhyloSim
detachHookFromNode(this, node=NA, ...)

Arguments

this

A PhyloSim object.

node

Node identifier.

...

Not used.

Value

The PhyloSim object (invisible).

See Also

attachHookToNode PhyloSim Simulate.PhyloSim

Examples

Run this code
# NOT RUN {
	# Create a PhyloSim object.
	# Provide the phylo object
	# and the root sequence.
	sim<-PhyloSim(
		name="TinySim",
		phylo=rcoal(3),
		root.seq=NucleotideSequence(string="ATGC",processes=list(list(JC69())))
	);
	# create a node hook function
	hook<-function(seq=NA){
		# replace the substitution process with F84
		if(inherits(seq,"NucleotideSequence")){
			cat("Replacing JC69 with F84.\n");
			seq$processes<-list(list(F84(rate.params=list("Kappa" = 2))));
		}
		return(seq);
	}
	# attach hook function to node 5
	attachHookToNode(sim,5,hook);
	# detach hook from node 5
	detachHookFromNode(sim,5);
	# Run the simulation again
	Simulate(sim);	# You should not see the message printed out by the "hook" function.

 
# }

Run the code above in your browser using DataLab