map_stochastic_changes: Finds all state changes on a tree using stochastic character...

Description Usage Arguments Details Value Author(s) Examples

View source: R/map_stochastic_changes.R

Description

Takes a cladistic matrix and time-scaled tree and makes point estimates for every character change using stochastic character mapping.

Usage

1
2
3
4
5
6
7
8
9
map_stochastic_changes(
  cladistic_matrix,
  time_tree,
  time_bins,
  n_simulations = 10,
  polymorphism_behaviour = "equalp",
  uncertainty_behaviour = "equalp",
  inapplicable_behaviour = "missing"
)

Arguments

cladistic_matrix

A character-taxon matrix in the format imported by read_nexus_matrix.

time_tree

A time-scaled tree (phylo object) that represents the relationships of the taxa in cladistic_matrix.

time_bins

A vector of ages representing the boundaries of a series of time bins.

n_simulations

The number of simulations to perform (passed to make.simmap.

polymorphism_behaviour

What to do with polymorphic (&) characters. One of "equalp", "missing", or "random". See details.

uncertainty_behaviour

What to do with uncertain (/) characters. One of "equalp", "missing", or "random". See details.

inapplicable_behaviour

What to do with inapplicable characters. Only one option currently ("missing"). See details.

Details

Important: this function is not yet complete and should not be used.

A wrapper function for make.simmap in the phytools package.

This function is intended to enumerate all possible changes on a tree (including to and from missing or inapplicable states) under the assumptions of stochastic character mapping as an alternative means of establishing branch-lengths (for rate analyses) or recording the state occupied at a particular point in time for disparity analyses.

Value

all_state_changes

A matrix of rows for each change with columns corresponding to the character, the simulation number, the edge number, the time the change occurred, and the start and end states.

character_times

A vector of the sampled tree-length (in Ma) for each character.

binned_edge_lengths

A matrix of time bins (columns) and characters (rows) indicating the sampled tree-length (in Ma).

binned_terminal_edge_lengths

As above, but for terminal edges only.

binned_internal_edge_lengths

As above, but for internal edges only.

Author(s)

Graeme T. Lloyd graemetlloyd@gmail.com

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Set random seed:
set.seed(2)

# Use Day 2016 as source matrix:
cladistic_matrix <- day_2016

# Prune out continuous characters:
cladistic_matrix <- prune_cladistic_matrix(
  cladistic_matrix =
    cladistic_matrix, blocks2prune = 1
)

# Prune out majority of characters so
# example runs quickly:
cladistic_matrix <- prune_cladistic_matrix(
  cladistic_matrix =
    cladistic_matrix, characters2prune = 1:32
)

# Generete random tree for matrix taxa:
time_tree <- ape::rtree(n = nrow(day_2016$matrix_1$matrix))

# Add taxon names to tree:
time_tree$tip.label <- rownames(x = day_2016$matrix_1$matrix)

# Add root age to tree:
time_tree$root.time <- max(diag(x = ape::vcv(phy = time_tree)))

# Get all state changes for two simulations:
state_changes <-
  map_stochastic_changes(
    cladistic_matrix = cladistic_matrix,
    time_tree = time_tree, time_bins = seq(time_tree$root.time, 0,
      length.out = 3
    ), n_simulations = 2
  )

# View matrix of all stochstic character changes:
state_changes$all_state_changes

# View vector of sampled time for each character:
state_changes$character_times

# View matrix of edge lengths in each time bin:
state_changes$binned_edge_lengths

# View matrix of terminal edge lengths in each time bin:
state_changes$binned_terminal_edge_lengths

# View matrix of internal edge lengths in each time bin:
state_changes$binned_internal_edge_lengths

Claddis documentation built on Oct. 23, 2020, 8:04 p.m.