| conStruct {conStruct} | R Documentation |
Run a conStruct analysis.
Description
conStruct runs a conStruct analysis of genetic data.
Usage
conStruct(
spatial = TRUE,
K,
freqs,
geoDist = NULL,
coords,
prefix = "",
n.chains = 1,
n.iter = 1000,
make.figs = TRUE,
save.files = TRUE,
...
)
Arguments
spatial |
A logical indicating whether to perform a spatial analysis.
Default is |
K |
An |
freqs |
A |
geoDist |
A full |
coords |
A |
prefix |
A character |
n.chains |
An integer indicating the number of MCMC chains to be run in the analysis. Default is 1. |
n.iter |
An |
make.figs |
A |
save.files |
A |
... |
Further options to be passed to rstan::sampling (e.g., adapt_delta). |
Details
This function initiates an analysis that uses geographic and genetic relationships between samples to estimate sample membership (admixture proportions) across a user-specified number of layers.
This function acts as a wrapper around a STAN model block determined
by the user-specified model (e.g., a spatial model with 3 layers,
or a nonspatial model with 5 layers).
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.
Along with the conStruct.results output described above,
several objects are saved during the course of a conStruct call
(if save.files=TRUE).
These are the data.block, which contains all data passed to the STAN model block,
model.fit, which is unprocessed results of the STAN run in stanfit format,
and the conStruct.results, which are saved in the course of the function call
in addition to being returned.
If make.figs=TRUE, running conStruct will also generate many output figures,
which are detailed in the function make.all.the.plots in this package.
Value
This function returns a list with one entry for each chain run
(specified with n.chains). The entry for each chain is named
"chain_X" for the Xth chain. The components of the entries for each
are detailed below:
-
posteriorgives parameter estimates over the posterior distribution of the MCMC.-
n.iternumber of MCMC iterations retained for analysis (half of then.iterargument specified in the function call). -
lpdvector of log posterior density over the retained MCMC iterations. -
nuggetsmatrix of estimated nugget parameters with one row per MCMC iteration and one column per sample. -
par.covarray of estimated parametric covariance matrices, for which the first dimension is the number of MCMC iterations. -
gammavector of estimated gamma parameter. -
layer.paramslist summarizing estimates of layer-specific parameters. There is one entry for each layer specified, and the entry for the kth layer is named "Layer_k".-
alpha0vector of estimated alpha0 parameter in the kth layer. -
alphaDvector of estimated alphaD parameter in the kth layer. -
alpha2vector of estimated alpha2 parameter in the kth layer. -
muvector of estimated mu parameter in the kth layer. -
layer.covvector of estimated layer-specific covariance parameter in the kth layer.
-
-
admix.proportionsarray of estimated admixture proportions. The first dimension is the number of MCMC iterations, the second is the number of samples, and the third is the number of layers.
-
-
MAPgives point estimates of the parameters listed in theposteriorlist described above. Values are indexed at the MCMC iteration with the greatest posterior probability.-
index.iterthe iteration of the MCMC with the highest posterior probability, which is used to index all parameters included in theMAPlist -
lpdthe greatest value of the posterior probability -
nuggetspoint estimate of nugget parameters -
par.covpoint estimate of parametric covariance -
gammapoint estimate of gamma parameter -
layer.paramspoint estimates of all layer-specific parameters -
admix.proportionspoint estimates of admixture proportions.
-
Examples
# load example dataset
data(conStruct.data)
# run example spatial analysis with K=1
#
# for this example, make.figs and save.files
# are set to FALSE, but most users will want them
# set to TRUE
my.run <- conStruct(spatial = TRUE,
K = 1,
freqs = conStruct.data$allele.frequencies,
geoDist = conStruct.data$geoDist,
coords = conStruct.data$coords,
prefix = "test",
n.chains = 1,
n.iter = 1e3,
make.figs = FALSE,
save.files = FALSE)