Learn R Programming

mvMORPH (version 1.2.2)

mapping.asr: Mapping ancestral character estimates onto a phylogenetic tree

Description

The function constructs a phylogenetic tree of class simmap that maps ancestral state of discrete characters at the nodes of a phylogenetic tree. Ancestral character estimates can be obtained from the ace function of the package "ape", or from a set of stochastic mappings summarized by the describe.simmap function.

Usage

mapping.asr(tree, ancestral, tips)

Value

A phylogenetic tree of class simmap. Two elements are added:

mapped.edge

matrix describing the duration time of each state per edge

maps

list. Its elements indicate the time spent in each state per branch, in chronological order

Arguments

tree

Phylogenetic tree (class phylo).

ancestral

Ancestral state estimates. Either an object of class describe.simmap or from the function ace.

tips

Character states at the tips. Either an object of class character or factor, which elements are named and ordered as in the phylogenetic tree.

Author

Julien Clavel

Details

The function follows the structure of the function make.simmap() from the package phytools, adding two elements describing the time spent in each state per edge. A phylogenetic tree with the ancestral state estimate mapped onto it is used to model trait evolution under multiple selective regimes in functions such as mvgls() or mvBM() and mvOU.

See Also

mvgls ace make.simmap

Examples

Run this code
# \donttest{
#### Example starts ####

library(mvMORPH)
library(ape)

set.seed(2508)

# Loading the data
data(phyllostomid)
phyllos_tree = phyllostomid$tree
phyllos_trait = phyllostomid$grp1

# The states at the tips should follow the order of the phylogenetic tree
phyllos_trait = phyllos_trait[phyllos_tree$tip.label]

# Estimating the ancestral character states
anc_state = ace(phyllos_trait, phyllos_tree, type="discrete",
    model="SYM")

# Mapping the reconstruction on the phylogenetic tree
new_tree = mapping.asr(tree=phyllos_tree, ancestral=anc_state, tips=phyllos_trait)
plot(new_tree)


# Character states estimated by stochastic mapping
simmap_trees = make.simmap(phyllos_tree, phyllos_trait, nsim="10")
simmap_list = describe.simmap(simmap_trees)

# Mapping the reconstruction on the phylogenetic tree
new_tree2 = mapping.asr(tree=phyllos_tree, ancestral=simmap_list, tips=phyllos_trait)
plot(new_tree2)

# For comparison
plot(phyllos_tree)
nodelabels(pie =simmap_list$ace)
#### Example ends ####
# }

Run the code above in your browser using DataLab