PhyloSim: an R package for the Monte Carlo simulation of sequence evolution


PhyloSim is an extensible object-oriented framework for the Monte Carlo simulation of sequence evolution written in 100 percent R. It is built on the top of the R.oo and ape packages and uses the Gillespie algorithm to simulate substitutions, insertions and deletions.

Package source repository:

Key features

  • Simulation of the evolution of a set of discrete characters with arbitrary states evolving by a continuous-time Markov process with an arbitrary rate matrix.

  • Explicit implementations of the most popular substitution models (nucleotide, amino acid and codon substitution models).

  • Simulation under the popular models of among-sites rate variation, like the gamma (+G) and invariant sites plus gamma (+I+G) models.

  • The possibility to simulate under arbitrarily complex patterns of among-sites rate variation by setting the site specific rates according to any R expression.

  • Simulation of one or more separate insertion and/or deletion processes acting on the sequences and which sample the insertion/deletion length from an arbitrary discrete distribution or an R expression (so all the probability distributions implemented in R are readily available for this purpose).

  • Simulation of the effects of variable functional constraints over the sites by site-process specific insertion and deletion tolerance parameters which determine the rejection probability of a proposed insertion/deletion.

  • The possibility of having a different set of processes and site-process specific parameters for every site, which allows for an arbitrary number of partitions in the simulated data.

  • The possibility to evolve sites by a mixture of substitution processes along a single branch.

  • Simulation of heterotachy and other cases of non-homogeneous evolution by allowing the user to set "node hook" functions altering the site properties at internal nodes.

  • The possibility to export the counts of various events ("branch statistics") as phylo objects (see the man page of exportStatTree.PhyloSim).

More information is available in the package reference manual and the package vignette. Additional examples are available from the examples directory of the package source repository.


The released packages are available under the GNU General Public Licence version 3 (see for further information) from the download page and CRAN.