fossils.to.pyrate: Generate output in the format used by the program PyRate

Description Usage Arguments Examples

View source: R/conversions.R

Description

Generate output in the format used by the program PyRate

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
fossils.to.pyrate(
  fossils,
  python = TRUE,
  traits = NULL,
  cutoff = NULL,
  random = FALSE,
  min = NULL,
  exclude.extant.singletons = TRUE,
  file = "",
  use.sp.names = FALSE
)

Arguments

fossils

Fossils object.

python

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.

traits

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

cutoff

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

random

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.

min

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.

exclude.extant.singletons

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

file

Output file name.

use.sp.names

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
set.seed(123)

# 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
fossils.to.pyrate(f)
fossils.to.pyrate(f, python = FALSE)

# add trait values
traits = runif(length(unique(f$sp)))
fossils.to.pyrate(f, traits = traits)

FossilSim documentation built on April 6, 2021, 1:06 a.m.