This function assists in creating a directory system with different sub-folders to assist in the organisation of the modelling process outputs.
Usage
sdm_directory(
main_dir,
projections = NULL,
calibration_area = TRUE,
algorithm = NULL,
ensemble = NULL,
threshold = FALSE,
return_vector = TRUE
)Arguments
- main_dir
character. Directory path containing main folder for saving model inputs and outputs. There is no default: the path must be provided by the user (e.g., in examples use a sub-folder of
tempdir()). The folder is created if it does not exist.- projections
vector. Vector of folder names for future scenarios/different regions/time periods to save model projections output.
- calibration_area
logical. If TRUE, function creates a folder in 1_Inputs for storing calibration area. Default TRUE
- algorithm
vector. Vector of model names that will be used. Usage algorithm = c(gam, tune_max, tune_net, esm_glm). If "all" is used the function creates folders with all algorithms available in flexsdm . i.e. 'gam', 'gau', 'gbm', 'glm', 'max', 'net', 'raf', and 'svm'. Default NULL
- ensemble
vector. Vector of methods used to ensemble different models. Usage ensemble = c("mean", "meanthr"). Default NULL
- threshold
logical. If TRUE sub-folders "/1_con", "/2_bin" will be created within each algorithm and/or ensemble folder. Used for storing continuous and binarized models separately. Default FALSE
- return_vector
logical. If TRUE function returns a vector with the path to all folders. Default TRUE
Details
The sdm_directory function assists in saving workflow outputs by creating folders (directories) based on user specifications, such as choice of algorithms, ensemble methods, and model projections to new geographic regions or periods. The function first creates two folders within the user-specified project folder, one for model inputs (1_Inputs) and one for model outputs (2_Outputs). Within 1_Inputs, there are three sub-folders for users to store model inputs: 1_Occurrences, 2_Predictors, and 3_Calibration_area. If a user chooses to include projections in their modeling framework, the 2_Projections subfolder is created within the 2_Predictors folder to store the environmental data for the projection scenarios provided to the "projections" argument. Additionally, sdm_directory offers users enhanced flexibility in saving their modeling outputs, giving them offers users the option to save results from any modeling and ensemble technique presented in flexsdm
Examples
# Folders are created in a temporary directory; in a real analysis use
# the path of your own project folder
my_project <- file.path(tempdir(), "my_project_name")
# my_project <- file.path(getwd(), "flexsdm_results") # create folders in the working directory
dirs_1 <- sdm_directory(
main_dir = my_project,
projections = NULL,
calibration_area = TRUE,
algorithm = c("gam", "tune_max"),
ensemble = c("mean", "meanthr"),
threshold = FALSE,
return_vector = TRUE
)
#> Directories were created in:
#> /var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name
dirs_1
#> [1] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name"
#> [2] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/1_Inputs"
#> [3] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/1_Inputs/1_Occurrences"
#> [4] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/1_Inputs/2_Predictors"
#> [5] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/1_Inputs/2_Predictors/1_Current"
#> [6] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/1_Inputs/3_Calibration_area"
#> [7] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/2_Outputs"
#> [8] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/2_Outputs/0_Model_performance"
#> [9] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/2_Outputs/1_Current"
#> [10] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/2_Outputs/1_Current/Algorithm"
#> [11] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/2_Outputs/1_Current/Algorithm/gam"
#> [12] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/2_Outputs/1_Current/Algorithm/tune_max"
#> [13] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/2_Outputs/1_Current/Ensemble"
#> [14] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/2_Outputs/1_Current/Ensemble/mean"
#> [15] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/2_Outputs/1_Current/Ensemble/meanthr"
unlink(my_project, recursive = TRUE) # remove the folders created in this example
# With folders for model projections and for thresholded outputs
dirs_2 <- sdm_directory(
main_dir = my_project,
projections = c("cnrm_rpc8.5_2050", "cnrm_rpc4.5_2050"),
calibration_area = TRUE,
algorithm = "all",
ensemble = c("mean", "meanthr"),
threshold = TRUE
)
#> Directories were created in:
#> /var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name
head(dirs_2)
#> [1] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name"
#> [2] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/1_Inputs"
#> [3] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/1_Inputs/1_Occurrences"
#> [4] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/1_Inputs/2_Predictors"
#> [5] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/1_Inputs/2_Predictors/1_Current"
#> [6] "/var/folders/0q/hy7d1sjn455f1kdjtvcpjg7h0000gn/T//RtmpmTJzCf/my_project_name/1_Inputs/2_Predictors/2_Projection"
unlink(my_project, recursive = TRUE)