extractSimmapDensity: Extract posterior values from densityMap and/or contMap...

Description Usage Arguments Details Value Examples

View source: R/extractSimmapDensity.R

Description

This function takes a list of densityMap and/or contMap objects and extracts and aggregates the posterior values across them. The age and edge index of each posterior value are also included.

Usage

1

Arguments

...

A vector of values.

Details

Assumes that the gradient resolution is identical for all objects (specified with res in densityMap and contMap). If the tree has a root.time element, this will be used as the max age, otherwise max(nodeHeights(tree)) will be used.

Value

A data.frame where rows represent the mapped traits through time and columns represent each of the supplied objects in .... The column names are set to the names of objects. Also includes a column for the edge index and a column for the age (in the units of the tree).

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
library(phytools)
# simulate tree
tree <- pbtree(n=70,scale=1)

# simulate discrete trait
Q <- matrix(c(-1,1,1,-1),2,2)
rownames(Q) <- colnames(Q)<-c(0,1)
x1 <- sim.history(tree,Q)$states

# generate stochastic maps and density map
mtrees <- make.simmap(tree,x1,nsim=100)
map1 <- densityMap(mtrees)

# simulate continuous trait
x2 <- fastBM(tree,sig2=0.1)

# generate cont map
map2 <- contMap(tree, x2)

# extract posterior densities
pp_data <- extractSimmapDensity(map1, map2)

# plot to see how traits have evolved with respect to one another
plot(pp_data$map1, pp_data$map2)

willgearty/pcmtools documentation built on Nov. 5, 2019, 12:20 p.m.