FBD_reshape {EvoPhylo}R Documentation

Convert an FBD posterior parameter table from wide to long format

Description

Converts FBD posterior parameter table, such as those imported using combine_log, from wide to long format.

Usage

FBD_reshape(posterior, variables = NULL, log.type = c("MrBayes", "BEAST2"))

Arguments

posterior

Single posterior parameter sample dataset with skyline FBD parameters produced with combine_log.

variables

Names of FBD rate variables in the log. If NULL (default), will attempt to auto-detect the names and log type.

log.type

Name of the software which produced the log (currently supported: MrBayes or BEAST2). Has to be set if variables is not NULL.

Details

The posterior parameters log files produced by Bayesian evolutionary analyses using skyline birth-death tree models, including the skyline FBD model, result into two or more estimates for each FBD parameter, one for each time bin. This function will convert a table of parameters with skyline FBD parameters from wide to long format, with one row per generation per time bin and a new column "Time_bin" containing the respective time bins as a factor. The long format is necessary for downstream analyses using FBD_summary, FBD_dens_plot, FBD_normality_plot, FBD_tests1, or FBD_tests2, as similarly done by clock_reshape for clock rate tables.

The format of the log files can either be specified using the variables and log.type or auto-detected by the function. The "posterior" data frame can be obtained by reading in a log file directly (e.g. using the read.table function) or by combining several output log files from Mr. Bayes using combine_log.

Value

A data frame of posterior parameter estimates containing a single "Time_bin" column and one column for each FBD parameter value.

See Also

vignette("fbd-params") for the use of this function as part of an analysis pipeline.

combine_log, reshape

Examples

# See vignette("fbd-params") for how to use this
# function as part of an analysis pipeline

data("posterior3p")

head(posterior3p)

## Reshape FBD table to long format
posterior3p_long <- FBD_reshape(posterior3p)

head(posterior3p_long)

[Package EvoPhylo version 0.3.2 Index]