Skip to content

C. Getting Started

szuwalski edited this page Jun 13, 2018 · 3 revisions

Installation

GeMS can both be loaded as a package in R, or forked so that the user can modify the code to their own needs. Using GeMS as a package is the most straight-forward way to begin using GeMS. To install the GeMS package, the devtools package is required.

install.packages("devtools")
devtools::install_github("szuwalski/GeMS")
# Load package
library(GeMS)

Running an example

Once the package is loaded, one of the examples included in the package can be run by executing the following code.

# Set directory where control files are
dir.MSE <- system.file("extdata/Cod_1_Production",package="GeMS") #Located in the extdata/ folder of the GeMS package directory--this example applies a production model to an age-structured population

# Names of control files to be tested 
OMNames<-c("Cod_LowProd_CTL", "Cod_Base_CTL", "Cod_HighProd_CTL")

When the user performs a tailor-made MSE, rather than this pre-packaged example, dir.MSE will be a folder created and specified by the user and will contain the user-modified control files.

An MSE can be initiated based on the information in the control files by a call to run_GeMS().

# Beginning the MSE
run_GeMS(OMNames,dir.MSE)

Plots can then be found at file.path(dir.MSE, "plots"). If the MSE is relatively large, parallel processing can decrease the run times. Parallel processing can be implemented in GeMS by changing two arguments in run_GeMS(): runparallel and cores.

##-----------------
## Parallel example
## (requires the foreach and doParallel packages)
##-----------------
run_GeMS(OMNames,dir.MSE,
         runparallel = T, cores = 3)

Forking the code to your personal account and working within that repo is another method for working with GeMS and allows the user to contribute to the software. Working through R Studio makes the process of version control and code contribution simple and reproducible. Next, we provide more in depth examples of how to implement GeMS.