SAtree.from.fossils: Transforms a tree and fossils dataframe to a combined SA...

View source: R/SAtree.R

SAtree.from.fossilsR Documentation

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

Description

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". The order of the indexes is given by 'tip_order': either the oldest tip of a given species receives index 1 and indexes increase towards the present (default) or the reverse.

Usage

SAtree.from.fossils(
  tree,
  fossils,
  tip_order = c("oldest_first", "youngest_first")
)

Arguments

tree

Phylo object.

fossils

Fossils object.

tip_order

Order of indexes to assign to the tips, either 'oldest_first' (by default, indexes increase towards the present) or 'youngest_first' (indexes increase towards the past).

Value

A list of 'tree', the SA tree integrating the fossils, and 'fossils', the fossils object updated with the tip label of each sample.

Examples

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

# simulate fossils
f = sim.fossils.poisson(rate = 2, tree = t)

# transform format
t2 = SAtree.from.fossils(t,f)
plot(t2$tree)

rachelwarnock/fossilsim documentation built on June 2, 2025, 9:34 a.m.