sumstatMCMCks: Phylogenetic Stochastic Mapping for a 2 state trait with an...

Description Usage Arguments Value

View source: R/sumstatMCMCks.R

Description

Creates an MCMC chain of substitution histories conditional on a phylogenetic tree, and observed states at the tips of the tree. Returns summary statisitics of each sampled substitution history. This function uses a hidden rates model of evolution allowing for different transition rates across the tree.

Usage

1
sumstatMCMCks(z,Q,pid,Omega,N,prior)

Arguments

z

a phylogenetic tree in phytools format (a list). One of the list elements, "mapnames", must be added to the phylosim format. "mapnames" is a list of vectors. Each vector is composed of integers that are the names in phylosim's "maps" list. The "mapnames" list has a vector for each branch composed of the states visited along each branch (in order).

Q

an nxn rate matrix where n is an even integer strictly greater than 2, the rows sum to zero

pid

a probability vector containing the prior probabilities that the root is in each state

Omega

a positive real number, the absolute value of each diagonal element of Q will be less than Omega

N

a positive integer: the number of substitution histories to be sampled

prior

a vector of length 6. The first two elements are the shape and rate parameters for the prior on Q[1,2] and Q[2,1]. The second two elements are the shape and rate parameters for all the priors on the rates of transitioning between regimes (kappas). The final two elements are the shape and rate parameters for all the priors governing the multiplicative factors that distinguish the different regime transition rates (gammas).

Value

sumstatMCMCks returns a matrix, each row contains a summary statistic of one of the N sampled substitution histories. The first n elements of each row contain the amount of time spent over the entire tree in each state. The amount of time spent in state 1 is in the first column, the amount of time spent in state 2 is in the second column, ... , and the amount of time spent in state n is found in the nth column. The next n^2 columns contain the number of transitions between each pair of states (including virtual transitions). We start with the number of transitions from state 1 to state 1, then from state 1 to state 2, on to the number of transitions from state 1 to state n. We continue with the number of transitions from state 2 to state 1, then from state 2 to state 2, and on to the number of transitions from state 2 to state n. After n+n^2 columns we move on to reporting rate matrix parameters. In column n+n^2+1 we report the forward transition rate, Q[1,2] (l01). In column n+n^2+2 we report the backward transition rate, Q[2,1] (l10). The following (n/2)-1 columns contain regime forward transitions rates (kappa_i(i+1)). The following (n/2)-1 columns contain regime backward transitions rates (kappa_(i+1)i). The following (n/2)-1 columns contain the multiplicative factors that distinguish the different regime transition rates (gamma_i). The final column contains the state of the root node (starting with state 0, sorry for the lack of consistency).


vnminin/phylomap documentation built on May 3, 2019, 6:38 p.m.