Title: | Visualizations for instantaneous rate matrices |
---|---|
Description: | This package uses an instantaneous rate matrix (such as is used for models of DNA evolution, morphological character change over evolutionary history, and other areas) and summarizes it in various ways. These could include bubble plots, a network showing transitions, or calculations to figure out likely paths between two states. |
Authors: | Brian C. O'Meara and Jeremy M. Beaulieu |
Maintainer: | Brian C. O'Meara <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0 |
Built: | 2024-11-23 03:18:08 UTC |
Source: | https://github.com/bomeara/RateViz |
This package uses an instantaneous rate matrix (such as is used for models of DNA evolution, morphological character change over evolutionary history, and other areas) and summarizes it in various ways. These could include bubble plots, a network showing transitions, or calculations to figure out likely paths between two states.
Package: | RateViz |
Type: | Package |
Version: | 1.0 |
Date: | 2015-02-17 |
License: | GPL (>=2) |
Brian C. O'Meara and Jeremy M. Beaulieu
Maintainer: Brian C. O'Meara <[email protected]>
#A random sample transition matrix Q <- matrix(runif(9), 3, 3) diag(Q) <- 0 diag(Q) <- -rowSums(Q) colnames(Q) <- c("A", "B", "C") rownames(Q) <- c("A", "B", "C") print(Q) ComputePathwayProbability(Q, from=1, to=3) PlotTransitionNetwork(Q)
#A random sample transition matrix Q <- matrix(runif(9), 3, 3) diag(Q) <- 0 diag(Q) <- -rowSums(Q) colnames(Q) <- c("A", "B", "C") rownames(Q) <- c("A", "B", "C") print(Q) ComputePathwayProbability(Q, from=1, to=3) PlotTransitionNetwork(Q)
This implements the rate summary used in Zanne et al. 2014. Using the rate matrix, one can calculate
ComputePathwayProbability(Q, from, to, correct.diag = TRUE, total.time = 1e+06)
ComputePathwayProbability(Q, from, to, correct.diag = TRUE, total.time = 1e+06)
Q |
Instantaneous rate matrix |
from |
Index (position) of start state in the matrix (i.e., the second character) |
to |
Index (position) of end state in the matrix |
correct.diag |
Normally the diagonal is the negative sum of the non-diagonal elements in a row. If TRUE, this verifies that this is so |
total.time |
A large enough time such that there is essentially no chance of remaining unchanged |
A vector with the probability of each path into the final state.
Brian C. O'Meara
Zanne et al. 2014
#A random sample transition matrix Q <- matrix(runif(9), 3, 3) diag(Q) <- 0 diag(Q) <- -rowSums(Q) colnames(Q) <- c("A", "B", "C") rownames(Q) <- c("A", "B", "C") print(Q) ComputePathwayProbability(Q, from=1, to=3)
#A random sample transition matrix Q <- matrix(runif(9), 3, 3) diag(Q) <- 0 diag(Q) <- -rowSums(Q) colnames(Q) <- c("A", "B", "C") rownames(Q) <- c("A", "B", "C") print(Q) ComputePathwayProbability(Q, from=1, to=3)
Plots a rate matrix such that circle area correlates with the rate
PlotBubbleMatrix(Q, main = "", special = Inf, cex = 1)
PlotBubbleMatrix(Q, main = "", special = Inf, cex = 1)
Q |
Instantaneous rate matrix |
main |
Optional plot title |
special |
If you want to highlight a particular element, input its number here |
cex |
Adjustment for text size |
None
Brian C. O'Meara
#A random sample transition matrix Q <- matrix(runif(9), 3, 3) diag(Q) <- 0 diag(Q) <- -rowSums(Q) colnames(Q) <- c("A", "B", "C") rownames(Q) <- c("A", "B", "C") print(Q) PlotBubbleMatrix(Q)
#A random sample transition matrix Q <- matrix(runif(9), 3, 3) diag(Q) <- 0 diag(Q) <- -rowSums(Q) colnames(Q) <- c("A", "B", "C") rownames(Q) <- c("A", "B", "C") print(Q) PlotBubbleMatrix(Q)
This plots a network showing transition rates between given states. It uses igraph for plotting.
PlotTransitionNetwork(Q, main = "", layout.fn = layout.circle, ...)
PlotTransitionNetwork(Q, main = "", layout.fn = layout.circle, ...)
Q |
Instantaneous rate matrix |
main |
Title for plot (optional) |
layout.fn |
Layout function from igraph. By default this uses a circle layout, but you may use other igraph functions. layout.fruchterman.reingold may generate a good looking graph. |
... |
Other arguments to pass to plot.igraph() |
No return
Brian C. O'Meara
#A random sample transition matrix Q <- matrix(runif(9), 3, 3) diag(Q) <- 0 diag(Q) <- -rowSums(Q) colnames(Q) <- c("A", "B", "C") rownames(Q) <- c("A", "B", "C") print(Q) PlotTransitionNetwork(Q)
#A random sample transition matrix Q <- matrix(runif(9), 3, 3) diag(Q) <- 0 diag(Q) <- -rowSums(Q) colnames(Q) <- c("A", "B", "C") rownames(Q) <- c("A", "B", "C") print(Q) PlotTransitionNetwork(Q)