Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 1c51cf90e4
Fetching contributors…

Cannot retrieve contributors at this time

executable file 50 lines (35 sloc) 1.062 kb
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 50
#!/usr/bin/env Rscript

##
## Example V2.1.1: Simulating substitutions under the JC69 model - "unrolled" example
## See also the package vignette (vignette("PhyloSim",package="phylosim")).
##

# load PhyloSim
library("phylosim")

#Construct the root sequence object:
root.seq<-NucleotideSequence(length=50)

# Print out the root sequence:
print(root.seq)
# Note, that all states are still undefined.

# Construct a JC69 substitution process object:
p<-JC69()

# Attach the substitution process to root sequence:
attachProcess(root.seq,p)

# Sample the site states from the equilibrium distribution of the JC69
# substitution process:
sampleStates(root.seq)

#Print out the root sequence, now with the sampled states:
print(root.seq)

#Read in tree from file using APE:
tree<-read.tree("data/3taxa.nwk")

#Plot the tree:
plot(tree)

#Construct a PhyloSim object:
sim<-PhyloSim()

# Set the phylo object:
sim$phylo<-tree

# Set the root sequence:
sim$rootSeq<-root.seq

# Run the simulation:
Simulate(sim)

# Display the resulting alignment matrix:
sim$alignment
Something went wrong with that request. Please try again.