% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/eems.run.R
\name{eems.from.files}
\alias{eems.from.files}
\title{Run an EEMS analysis}
\usage{
eems.from.files(
  seed = unclass(Sys.time()),
  datapath,
  mcmcpath,
  prevpath = "",
  gridpath = "",
  nDemes,
  nIndiv,
  nSites,
  diploid = TRUE,
  distance = "euclidean",
  numMCMCIter,
  numBurnIter,
  numThinIter,
  mSeedsProposalS2 = 0.01,
  qSeedsProposalS2 = 0.1,
  mEffctProposalS2 = 0.1,
  qEffctProposalS2 = 0.001,
  mrateMuProposalS2 = 0.01,
  qVoronoiPr = 0.25,
  qrateShape = 0.001,
  mrateShape = 0.001,
  sigmaShape = 0.001,
  qrateScale = 1,
  mrateScale = 1,
  sigmaScale = 1,
  negBiProb = 0.67,
  negBiSize = 10
)
}
\arguments{
\item{seed}{The random seed. Defaults to the current system time in seconds.}

\item{datapath}{Full path to a set of three files: datapath.coord, datapath.diffs and datapath.outer.}

\item{mcmcpath}{Full path to a filename prefix in an output directory with write permission.}

\item{prevpath}{Full path to previous output directory, i.e., the mcmcpath in a previous EEMS run. Optional.}

\item{gridpath}{Full path to a set of two files: gridpath.demes and gridpath.edges. Optional.}

\item{nDemes}{Number of demes, roughly. EEMS constructs a regular triangular grid with circa nDemes vertices.}

\item{nIndiv}{Number of samples. Should match the size of the dissimilarity matrix in datapath.diffs.}

\item{nSites}{Number of SNPs used to compute the observed dissimilarity matrix in datapath.diffs.}

\item{diploid}{Logical value that indicates whether the species is diploid (TRUE) or haploid (FALSE). Defaults to TRUE.}

\item{distance}{Distance metric. Either \code{euclidean} or \code{greatcirc}, that is, great circle distance.
Defaults to 'euclidean'.}

\item{numMCMCIter}{Number of Markov Chain Monte Carlo iterations.}

\item{numBurnIter}{Number of burn-in iterations to be discarded before sampling from posterior.}

\item{numThinIter}{Number of thinning iterations to be discarded between sampling from posterior.}

\item{mSeedsProposalS2}{Variance of normal proposals to update the seeds of the migration tiles. Defaults to 0.01.}

\item{qSeedsProposalS2}{Variance of normal proposals to update the seeds of the diversity tiles. Defaults to 0.1.}

\item{mEffctProposalS2}{Variance of normal proposals to update the log10 rates of the migration tiles. Defaults to 0.1.}

\item{qEffctProposalS2}{Variance of normal proposals to update the log10 rates of the diversity tiles. Defaults to 0.001.}

\item{mrateMuProposalS2}{Variance of normal proposals to update the overall mean migration rate, on the log10 scale.
Defaults to 0.01.}

\item{qVoronoiPr}{With probability qVoronoiPr, update diversity Voronoi;
with probability 1-qVoronoiPr, update migration Voronoi. Defaults to 0.25.}

\item{qrateShape}{Shape hyperparameter for the diversity rates variance, qrateS2 ~ invgamma(qrateShape, qrateScale).
Defaults to 0.001}

\item{mrateShape}{Shape hyperparameter for the migration rates variance, mrateS2 ~ invgamma(mrateShape, mrateScale).
Defaults to 0.001.}

\item{sigmaShape}{Shape hyperparameter for the scaling factor sigma^2 ~ invgamma(sigmaShape, sigmaScale).
Defaults to 0.001.}

\item{qrateScale}{Scale hyperparameter for the diversity rates variance, qrateS2 ~ invgamma(qrateShape, qrateScale).
Defaults to 1.0.}

\item{mrateScale}{Scale hyperparameter for the migration rates variance, mrateS2 ~ invgamma(mrateShape, mrateScale).
Defaults to 1.0.}

\item{sigmaScale}{Scale hyperparameter for the scaling factor sigma^2 ~ invgamma(sigmaShape, sigmaScale).
Defaults to 1.0.}

\item{negBiProb}{Success probability for the number of Voronoi tiles ~ negbinom(negBiSize, negBiProb). Defaults to 0.67.}

\item{negBiSize}{Size for the number of Voronoi tiles ~ negbinom(negBiSize, negBiProb). Defaults to 10.}
}
\value{
None
}
\description{
This function runs an EEMS analysis with given parameters, which include file paths for
retrieving the input files (datapath.coord, datapath.diffs and datapath.outer) and
writing the output files.
It is an exact replicate of the original EEMS command-line function.
}
\examples{
# We use example input from Petkova et al. (2016), found in the '/extdata' directory
data_path <- system.file("extdata", package = "reems")
input <- file.path(data_path, "barrier-schemeX-nIndiv300-nSites3000")
# The example puts the output in a temporary directory.
mcmcdir <- file.path(tempdir(), "eems_out")
dir.create(mcmcdir, showWarnings = FALSE)


# Run an example EEMS analysis with a small number of iterations to ensure quick termination. 

eems.from.files(
  datapath = input,
  mcmcpath = mcmcdir,
  nDemes = 200,
  nIndiv = 300,
  nSites = 3000,
  diploid = FALSE,
  numMCMCIter = 200,
  numBurnIter = 100,
  numThinIter = 99,
)
# Delete the output directory to tidy up. 
unlink(mcmcdir, recursive = TRUE, force = TRUE)
}
\references{
Petkova, D., Novembre, J. & Stephens, M.
Visualizing spatial population structure with estimated effective migration surfaces.
Nat Genet 48, 94–100 (2016). https://doi.org/10.1038/ng.3464
}
\seealso{
\code{\link{eems.plots}, \link{eems}}
}
