draw.sim {paleobuddy} | R Documentation |
Draw a sim object
Description
Draws species longevities for a paleobuddy simulation (a sim
object -
see ?sim
) in the graphics window. Allows for the assignment of
speciation and sampling events, and further customization.
Usage
draw.sim(sim, fossils = NULL, sortBy = "TS", lwdLin = 4, showLabel = TRUE, ...)
Arguments
sim |
A |
fossils |
A |
sortBy |
A single character or integer vector indicating how lineages
should be sorted in the plot. If it is a string (see example 3), it
indicates which element in the |
lwdLin |
The relative thickness/size of all elements (i.e., lines and
points in the plot. Default value is 4 (i.e. equal to |
showLabel |
A |
... |
Further arguments to be passed to |
Value
A plot of the simulation in the graphics window. If the
fossils
data.frame is supplied, its format will dictate how fossil
occurrences will be plotted. If fossils
has a SampT
column
(i.e. the occurrence times are exact), fossil occurrences are assigned as
dots. If fossils
has columns MaxT
and MinT
(i.e. the
early and late stage bounds associated with each occurrence), fossil
occurrences are represented as slightly jittered, semitransparent bars
indicating the early and late bounds of each fossil occurrence.
Author(s)
Matheus Januario
Examples
###
# we start drawing a simple simulation
# maximum simulation time
tMax <- 10
# set seed
set.seed(1)
# run a simulation
sim <- bd.sim(n0 = 1, lambda = 0.6, mu = 0.55, tMax = tMax,
nFinal = c(10,20))
# draw it
draw.sim(sim)
###
# we can add fossils to the drawing
# maximum simulation time
tMax <- 10
# set seed
set.seed(1)
# run a simulation
sim <- bd.sim(n0 = 1, lambda = 0.6, mu = 0.55, tMax = tMax,
nFinal = c(10,20))
# set seed
set.seed(1)
# simulate data resulting from a fossilization process
# with exact occurrence times
fossils <- sample.clade(sim = sim, rho = 4, tMax = tMax, returnTrue = TRUE)
# draw it
draw.sim(sim, fossils = fossils)
# we can order the vertical drawing of species based on
# any element of sim
draw.sim(sim, fossils = fossils, sortBy = "PAR")
# here we cluster lineages with their daughters by
# sorting them by the "PAR" list of the sim object
draw.sim(sim, fossils = fossils, sortBy = "TE")
# here we sort lineages by their extinction times
###
# try with fossil ranges
# maximum simulation time
tMax <- 10
# set seed
set.seed(1)
# run birth-death simulation
sim <- bd.sim(n0 = 1, lambda = 0.6, mu = 0.55, tMax = tMax,
nFinal = c(10,20))
# simulate data resulting from a fossilization process
# with fossil occurrence time ranges
# set seed
set.seed(20)
# create time bins randomly
bins <- c(tMax, 0, runif(n = rpois(1, lambda = 6), min = 0, max = tMax))
# set seed
set.seed(1)
# simulate fossil sampling
fossils <- sample.clade(sim = sim, rho = 2, tMax = tMax,
returnTrue = FALSE, bins = bins)
# draw it, sorting lineages by their parent
draw.sim(sim, fossils = fossils, sortBy = "PAR")
# adding the bounds of the simulated bins
abline(v = bins, lty = 2, col = "blue", lwd = 0.5)
###
# we can control how to sort displayed species exactly
# maximum simulation time
tMax <- 10
# set seed
set.seed(1)
# run birth-death simulations
sim <- bd.sim(n0 = 1, lambda = 0.6, mu = 0.55, tMax = tMax,
nFinal = c(10,20))
# set seed
set.seed(1)
# simulate fossil sampling
fossils <- sample.clade(sim = sim, rho = 4, tMax = tMax, returnTrue = TRUE)
# draw it with random sorting (in pratice this could be a trait
# value, for instance)
draw.sim(sim, fossils = fossils, sortBy = sample(1:length(sim$TS)))