run.bedassle: Run a BEDASSLE analysis.

View source: R/run.bedassle.R

run.bedassleR Documentation

Run a BEDASSLE analysis.

Description

run.bedassle runs a BEDASSLE analysis

Usage

run.bedassle(
  genDist,
  geoDist = NULL,
  envDist = NULL,
  nLoci,
  prefix,
  n.chains = 4,
  n.iter = 2000,
  make.figs = TRUE,
  save.stanfit = TRUE,
  ...
)

Arguments

genDist

A matrix of pairwise pi measured between all pairs of samples.

geoDist

A matrix of pairwise geographic distances measured between all pairs of samples. A value of NULL runs a model without geographic distance as a predictor of genetic differentiation.

envDist

A matrix of pairwise environmental distances measured between all pairs of samples. If there are multiple environmental distance measures, this argument should be a list of distance matrices. A value of NULL runs a model without geographic distance as a predictor of genetic differentiation.

nLoci

The number of loci used in the calculation of the pairwise pi matrix specified in the genDist argument.

prefix

A character vector giving the prefix to be attached to all output files. An underscore is automatically added between the prefix and the file names.

n.chains

An integer indicating the number of MCMC chains to be run in the analysis. Default is 4.

n.iter

An integer giving the number of iterations each MCMC chain is run. Default is 2e3. If the number of iterations is greater than 500, the MCMC is thinned so that the number of retained iterations is 500 (before burn-in).

make.figs

A logical value indicating whether to automatically make figures once the analysis is complete. Default is TRUE.

save.stanfit

A logical value indicating whether to automatically save the full stanfit output once the analysis is complete. Default is TRUE.

...

Further options to be passed to rstan::sampling (e.g., adapt_delta).

Details

This function runs an analysis that estimates the relative contributions of geographic and environmental/ecological distances to patterns of genetic differentiation between samples.

This function acts as a wrapper around a STAN model block determined by the user-specified model (e.g., just geographic distance, or geographic distance plus 2 environmental/ecological distance variables). User-specified data are checked for appropriate format and consistent dimensions, then formatted into a data.block, which is then passed to the STAN model block. The model output is written to three tab-delimited text files described above. The parameter values are rounded to 4 decimal places The full stanfit model output is also saved if save.stanfit=TRUE. If make.figs=TRUE, running run.bedassle will also generate figures depicting different aspects of model output; these are detailed in the function make.all.bedassle.plots in this package.

Value

This function writes all output to three tab-delimited text files for each chain run (specified with n.chains). The output files associated with each chain have "chain_X" for the Xth chain appended to the file name, and begin with the prefix specified with the prefix argument. The three output files associated with each chain are described below:

  • posterior contains the posterior probability and parameter estimates over the sampled posterior distribution of the MCMC. Each entry described below has its own named column in the output text file. Columns are separated by tabs.

    • lpd log posterior density over the retained MCMC iterations.

    • alpha0 posterior draws for alpha0 parameter.

    • alphaD posterior draws for alphaD parameter.

    • alphaE posterior draws for alphaE parameter(s). Named "alphaE_E" for the Eth environmental distance matrix specified.

    • alpha2 posterior draws for alpha2 parameter.

    • nuggets posterior draws for nugget parameters. Named "nugget_N" for the Nth sample in the dataset.

  • MAP contains point estimates of the parameters listed in the posterior file described above. Values are indexed at the MCMC iteration with the greatest posterior probability.

  • parCov contains the covariance matrix parameterized by the MAP parameter point estimates.


gbradburd/bedassle documentation built on May 20, 2022, 1 p.m.