BSP: Generate Bayesian skyline plots

View source: R/BSP.R

BSPR Documentation

Generate Bayesian skyline plots

Description

BSP generates Bayesian skyline plots for each analysed locus (when relevant) and the sum over all loci. Plots are returned as ggplot objects and, when save2disk==TRUE, pdf files.

BSP will also return the data used to generate the BSPs as a data.table object and, when save2disk==TRUE, a csv file. These data are a 'clean up' version of these contained in the skyline file along with the upper and lower limits. The column "Time" is the rescaled "Age" (from migrate output) when gen and mu are provided. If you want to obtain the effective population size (recall that Migrate-n returns theta=xmuNe for population size, where x is the number of ploid - e.g. for mtDNA, 4 for nuclear loci, etc. - and mu is the mutation rate, if this is the parameter that you are considering) you could obtain this by calculating Ne=theta/(x * mu).

Usage

BSP(
  dir.in = NULL,
  skylinefile = NULL,
  dir.out = NULL,
  all.loci = TRUE,
  overall = TRUE,
  params = 1,
  gen = 1,
  mu = 1,
  mu_unit = "generation",
  save2disk = TRUE
)

Arguments

dir.in

The local folder containing skylinefile files (default: NULL)

skylinefile

The name of the skylinefile (default: NULL)

dir.out

The local path to store the results. If NULL (default) then dir.out=dir.in

all.loci

Whether the parameter should be plotted for each locus

overall

Whether the parameter should be plotted for the sum over all loci (when nloci>1)

params

A vector of parameter numbers to be plotted

gen

The generation time in unit of time (e.g. years)

mu

Mutation rate expressed either 'per generation' basis or in the same unit as gen (e.g. years)

mu_unit

The unit used for the mutation rate. Options are either "generation" or "time"

save2disk

Whether to save results to disk (default: TRUE)

Value

A list where the first element is a data.table with skyline data and the others are the BSPs.


carlopacioni/mtraceR documentation built on Nov. 3, 2023, 4:30 a.m.