Learn R Programming

FossilSim

R package for simulating fossil data on phylogenetic trees under mechanistic models of preservation and sampling

The latest version can be installed in R using the package devtools:

install.packages("BiocManager")
BiocManager::install("ggtree")
library(devtools)
install_github("fossilsim/fossilsim")

Quick start

Simulating data using FossilSim can be as simple as the following code snippets.

# simulate a tree using ape
tips = 8
t = ape::rtree(tips)
# simulate fossils using fossilsim
rate = 2
f = sim.fossils.poisson(rate, t)  
# plot the complete output
plot(f, t)
# plot the reconstructed output
plot(f, t, reconstructed = TRUE)
# simulate taxonomy using fossilsim
beta = 0.5 # probability of symmetric speciation
lambda.a = 0.1  # rate of anagenesis
s = sim.taxonomy(t, beta, lambda.a)  
# plot the output
plot(s, t, legend.position = "bottomright")

Package vignettes

The following vignettes are available via CRAN and provide detailed examples:

For further information and examples see the package documentation

Contributors

  • Joëlle Barido-Sottani
  • Walker Pett
  • Joseph O'Reilly
  • Ugnė Stolz
  • Rachel Warnock

Citation

Joëlle Barido-Sottani et al. 2019. Methods Evolution & Ecology. FossilSim: an R package for simulating fossil occurrence data under mechanistic models of preservation and recovery

Copy Link

Version

Install

install.packages('FossilSim')

Monthly Downloads

643

Version

2.4.2

License

GPL-3

Maintainer

Joelle Barido-Sottani

Last Published

October 28th, 2025

Functions in FossilSim (2.4.2)

fossils

Fossils object
fossils.to.pyrate

Generate output in the format used by the program PyRate
fossils.to.paleotree.record

Transforms a fossils dataframe and either taxonomy or tree into a fossilRecordSimulation object from package paleotree.
plot.taxonomy

Plot simulated taxonomy
prune.fossil.tips

Remove fossil lineages from a tree
plot.fossils

Plot simulated fossils
get_fbdrange_from_file

Import fbdrange object from file
reconcile.fossils.taxonomy

Reconcile existing fossil and taxonomy objects
reconstructed.tree.fossils.objects

Returns tree and fossil objects that you can use to plot the reconstructed tree.
plot.fbdrange

Plot oriented tree with stratigraphic ranges
get.tip.descs

Obtain the tips that define each node in a tree
sim.taxonomy

Simulate taxonomy
sim.cryptic.species

Simulate cryptic species on a taxonomy object
sim.fossils.poisson

Simulate fossils under a Poisson sampling model
sim.anagenetic.species

Simulate anagenetic species on a taxonomy object
sampled.tree.from.combined

Removes all unsampled lineages from a combined tree. Extinct tips are only sampled if they are fossils. With default settings all extant tips are sampled.
sim.extant.samples

Include extant samples in the fossil object, with optional rho sampling.
sim.tip.samples

Include extant and extinct tip samples in the fossil object, with optional rho sampling.
subsample.fossils.oldest.and.youngest

Obtain a subsample of fossil occurrences containing the oldest and youngest fossil sample found at each node of the tree.
sim.gradient

Simulate an environmental gradient
sim.fossils.intervals

Simulate fossils under a non-uniform model of preservation for a given set of consecutive time intervals
sim.interval.ages

Reassign fossil ages to user-specified stratigraphic intervals
paleotree.record.to.fossils

Transforms a fossilRecordSimulation object from package paleotree to a tree and taxonomy and fossils objects.
species.end

Find a species' end (i.e extinction) time from a taxonomy object
sim.trait.values

Simulate trait values with variation across lineages
remove.stem.fossils

Remove fossil samples that occur in the stem
sim.fbd.age

sim.fbd.age: Simulating fossilized birth-death trees of a fixed age.
sim.fbd.rateshift.taxa

sim.fbd.rateshift.taxa: Simulating fossilized birth death trees incorporating rate shifts.
remove.stem.lineages

Remove stem lineages from a tree.
prune.fossils

Removes all intermediate fossils from a combined tree and labels the first and last fossils of each lineage.
rangeplot.asymmetric

Make an asymmetric stratigraphic range plot from a tree object of class phylo
place.fossils

Place fossil samples from one tree in another tree, or find the ancestral node for each fossil sample in one tree.
sim.fbd.taxa

sim.fbd.taxa: Simulating fossilized birth-death trees on a fixed number of extant taxa.
sim.fossils.environment

Simulate fossils under an environment-dependent model of preservation (Holland, 1995)
subsample.fossils.youngest

Obtain a subsample of fossil occurrences containing the youngest fossil sample in each node of the tree.
subsample.fossils.uniform

Obtain a uniform random sample of fossil occurrences.
summary.taxonomy

Display taxonomy object
taxonomy

Taxonomy object
tree.max

Find the maximum age in a phylo object (root age or origin time)
subsample.fossils.oldest

Obtain a subsample of fossil occurrences containing the oldest fossil sample in each node of the tree.
species.start

Find a species' start (i.e speciation) time from a taxonomy object
beast.fbd.format

Transforms a tree and fossils into a sampled tree in BEAST-usable format and writes it in Newick format.
fbdrange

Creates an fbdrange object from provided tree and data
count.fossils.binned

Count the total number of fossils per interval
SAtree

Tree with sampled ancestors represented as zero-length edges
FossilSim

FossilSim: A package for simulating and plotting fossil and taxonomy data
fossils.to.BEAST.constraints

Create a set of BEAST2 constraints to construct a DPPDIV style fixed extant topology FBD analysis
SAtree.from.fossils

Transforms a tree and fossils dataframe to a combined SA tree.
fossils.to.BEAST.start.tree

Create a suitable starting tree for a DPPDIV style FBD analysis in BEAST2
count.fossils

Count the total number of fossils