Learn R Programming

pcrcoal (version 1.2.0)

PCRcoal-class: The PCRcoal class

Description

PCRcoal is a class implementing the coalescent approach to PCR simulation developed by Weiss and von Haeseler (NAR, 1997).

Arguments

Usage

PCRcoal( initial.size, nr.cycles, efficiencies, sample.size, max.tries=100 ) Returns a PCRcoal S4 object.

Slots

Methods

References

Weiss, G, von Haeseler, A (1997) A coalescent approach to the polymerase chain reaction. NAR 25(15): 3082-3087 http://dx.doi.org/10.1093/nar/25.15.3082

See Also

The ape and phylosim packages.

Examples

Run this code
	# Construct a PCRcoal object 
        # and specify the experimental conditions:
        sim <-PCRcoal(
        initial.size    =5,
        sample.size     =10,
        nr.cycles       =20,
        efficiencies    =c(rep(0.1, 30))
        )

	##
	## Method: sample.tree
	##

	 # Sample a coalescent tree:
        tree <- sample.tree(sim)

        # Print tree info:
        print(tree)

        # Plot the tree:
        plot(tree)
	
	##
	## Method: sample.tnt
	##

	# Sample a coalescent tree with subsample sizes and
	# size trajectories:
        res <- sample.tnt(sim)

        # Print subsample sizes:
        print(res$subsamples)

        # Print size trajectories:
        print(res$trajectories)

        # Print tree info:
        print(res$phylo)
	
	##
	## Method: sample.trs
	##

	# Sample subsample sizes and size trajectories:
        res <- sample.trs(sim)

        # Print subsample sizes:
        print(res$subsamples)

        # Print size trajectories:
        print(res$trajectories)

	##
	## Simulating mutations using PhyloSim
	##

	# Sample tree:
	tree <- sample.tree(sim)

	# Load the phylosim package
	library(phylosim)
	# Construct a PhyloSim object, set up the root
	# sequence and the substitution process:	
	psim <- PhyloSim(
		phylo = tree,
		root.seq=sampleStates( NucleotideSequence(length=10,processes=list(list(JC69())) ) )
	)
	# Scale the tree:	
	scaleTree(psim,0.1)

	# Simulate mutations:
	Simulate(psim)

	# Plot the resulting alignment:
	plot(psim,plot.ancestors=FALSE)

Run the code above in your browser using DataLab