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:

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
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

524

Version

2.4.1

License

GPL-3

Last Published

October 2nd, 2024

Functions in FossilSim (2.4.1)

fossils.to.paleotree.record

Transforms a fossils dataframe and either taxonomy or tree into a fossilRecordSimulation object from package paleotree.
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.
subsample.fossils.youngest

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

Import fbdrange object from file
reconcile.fossils.taxonomy

Reconcile existing fossil and taxonomy objects
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
summary.taxonomy

Display taxonomy object
get.tip.descs

Obtain the tips that define each node in a tree
reconstructed.tree.fossils.objects

Returns tree and fossil objects that you can use to plot the reconstructed tree.
sim.fbd.rateshift.taxa

sim.fbd.rateshift.taxa: Simulating fossilized birth death trees incorporating rate shifts.
plot.fbdrange

Plot oriented tree with stratigraphic ranges
plot.fossils

Plot simulated fossils
tree.max

Find the maximum age in a phylo object (root age or origin time)
taxonomy

Taxonomy object
prune.fossils

Removes all intermediate fossils from a combined tree and labels the first and last fossils of each lineage. Can be used with sampled or complete trees. If only one fossil is present for a particular species it is labelled as first.
sim.gradient

Simulate an environmental gradient
sim.interval.ages

Reassign fossil ages to user-specified stratigraphic intervals
rangeplot.asymmetric

Make an asymmetric stratigraphic range plot from a tree object of class phylo
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.anagenetic.species

Simulate anagenetic species on a taxonomy object
sim.fossils.intervals

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

Simulate taxonomy
fossils.to.pyrate

Generate output in the format used by the program PyRate
species.end

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

Include extant and extinct tip samples in the fossil object, with optional rho sampling.
sim.fbd.taxa

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

Simulate trait values with variation across lineages
sim.fossils.poisson

Simulate fossils under a Poisson sampling model
sim.fossils.environment

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

Obtain a uniform random sample of fossil occurrences.
count.fossils.binned

Count the total number of fossils per interval
beast.fbd.format

Transforms a tree and fossils into a sampled tree in beast-usable format and writes it in Newick format. Designed to work with FBD.
fossils.to.BEAST.constraints

Create a set of BEAST2 constraints to construct a DPPDIV style fixed extant topology FBD analysis
FossilSim

FossilSim: A package for simulating and plotting fossil and taxonomy data
fbdrange

Creates an fbdrange object from provided tree and data
fossils

Fossils object
SAtree

Tree with sampled ancestors represented as zero-length edges
count.fossils

Count the total number of fossils
fossils.to.BEAST.start.tree

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

Transforms a tree and fossils dataframe to a combined SA tree. Sampled ancestors are represented as tips on zero-length edges to maintain compatibility with the ape format. Tip labels are set to "species id"_"index", where the most recent tip of a given species receives index 1 and indices increase towards the past.
paleotree.record.to.fossils

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

Plot simulated taxonomy
place.fossils

Place fossil samples from one tree in another tree, or find the ancestral node for each fossil sample in one tree.
prune.fossil.tips

Remove fossil lineages from a tree
sim.cryptic.species

Simulate cryptic species on a taxonomy object
sim.extant.samples

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

sim.fbd.age: Simulating fossilized birth-death trees of a fixed age.
remove.stem.fossils

Remove fossil samples that occur in the stem
remove.stem.lineages

Remove stem lineages from a tree.