calc_prob_forward_onebranch_dense: Dense matrix exponentiation forward on a branch, with...

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/calc_loglike_sp_v01.R

Description

Take input probabilities, and get the probabilities at the end of a branch using matrix exponentiation.

Usage

1
2
  calc_prob_forward_onebranch_dense(relprobs_branch_bottom,
    branch_length, Qmat)

Arguments

relprobs_branch_bottom

The relative probability of each state at the base of the branch (should sum to 1).

branch_length

The length of the branch.

Qmat

A Q transition matrix in square (dense) format

Details

The calc_loglike_sp function calculates most transition probabilities internally via rexpokit. These are then stored and can be used again when an uppass is being done for ancestral state estimates. However, if there is a root branch below the lowest fork, the uppass needs to calculate the forward probabilities.

Value

actual_probs_after_forward_exponentiation The probabilities of each state at the top of the branch.

Note

Go BEARS!

Author(s)

Nicholas J. Matzke matzke@berkeley.edu

References

http://phylo.wikidot.com/matzke-2013-international-biogeography-society-poster http://www.bioinf.org/molsys/data/idiots.pdf

Matzke_2012_IBS

FosterIdiots

See Also

expokit_dgpadm_Qmat2, expokit_dgpadm_Qmat, rexpokit

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Make a square instantaneous rate matrix (Q matrix)
# This matrix is taken from Peter Foster's (2001) "The Idiot's Guide
# to the Zen of Likelihood in a Nutshell in Seven Days for Dummies,
# Unleashed" at:
# \url{http://www.bioinf.org/molsys/data/idiots.pdf}
#
# The Q matrix includes the stationary base freqencies, which Pmat
# converges to as t becomes large.
Qmat = matrix(c(-1.218, 0.504, 0.336, 0.378, 0.126, -0.882, 0.252, 0.504, 0.168,
0.504, -1.05, 0.378, 0.126, 0.672, 0.252, -1.05), nrow=4, byrow=TRUE)

relprobs_branch_bottom = c(0.25, 0.25, 0.25, 0.25)

# Make a series of t values
branch_length = 0.1

calc_prob_forward_onebranch_dense(relprobs_branch_bottom, branch_length, Qmat)
calc_prob_forward_onebranch_dense(relprobs_branch_bottom, branch_length=0.5, Qmat)
calc_prob_forward_onebranch_dense(relprobs_branch_bottom, branch_length=1, Qmat)
calc_prob_forward_onebranch_dense(relprobs_branch_bottom, branch_length=2, Qmat)
calc_prob_forward_onebranch_dense(relprobs_branch_bottom, branch_length=10, Qmat)
calc_prob_forward_onebranch_dense(relprobs_branch_bottom, branch_length=20, Qmat)

BioGeoBEARS documentation built on May 29, 2017, 8:36 p.m.