Generate output in the format used by the program PyRate

View source: R/conversions.R Documentation

Generate output in the format used by the program PyRate


Generate output in the format used by the program PyRate

  python = TRUE,
  traits = NULL,
  cutoff = NULL,
  random = FALSE,
  min = NULL,
  exclude.extant.singletons = TRUE,
  file = "",
  use.sp.names = FALSE



Fossils object.


If TRUE the function outputs the data in the python format used by PyRate (default). If FALSE the function outputs a tab-delimited table used by tools associated with PyRate.


Vector of trait values equal to the number of unique species in the fossils dataframe. The order should correspond to the order in which they appear in unique(fossils$sp).


Exclude occurrences with age uncertainty greater than this value i.e. hmax - hmin > cutoff.


If TRUE use a random number from within the interval U(hmin, hmax) for specimen ages, otherwise use the midpoint of this interval (default). Applicable only when python = TRUE and for specimens with hmin != hmax.


Value used to represent the minimum possible interval age of extinct specimens with hmin = 0. By default min = NULL and the function will use the sampling times in the fossils dataframe.


If TRUE exclude species that have extant samples only (default = TRUE).


Output file name.


If TRUE use the value in fossils$sp as the complete taxon name, otherwise the function adds the prefix "taxa" (default = FALSE).



# simulate tree
t = ape::rtree(6)

# assign a max age based on tree height
max.age = tree.max(t)

# define a set of non-uniform length intervals
times = c(0, sort(runif(3, min = 0, max = max.age)), max.age)
rates = c(1,2,3,4)

# simulate fossils reflect age uncertainty
f = sim.fossils.intervals(tree = t, interval.ages = times, rates = rates,
    use.exact.times = FALSE)

# simulate extant samples
rho = 1
f = sim.extant.samples(f, t, rho = 1)

plot(f, t)

# generate input files for pyrate, python = FALSE)

# add trait values
traits = runif(length(unique(f$sp))), traits = traits)

FossilSim documentation built on July 20, 2022, 1:09 a.m.