#To spatially rarefaction of data distance and splitting data into training and testing# #Additional information and a step by step guide for installing and loading packages, and using that function of this package can be found in its GitHub repository (https://github.com/marlonecobos/ellipsenm)# library(ellipsenm) # Thinning (spatially rarefaction of data distance = 5 km) ppoints<-"stephadiscus_todos.csv" occ_t <- thin_data(ppoints, longitude = "longitude", latitude = "latitude", thin_distance = 5) # Splitting data into training and testing ## a list with all, train, and test records will be returned occ_calibration <- ellipsenm::split_data(occ_t, method = "random", longitude = "longitude", latitude = "latitude", train_proportion = 0.70) #To obtaina ENMs models# #Cobos ME, Peterson AT, Barve N, Osorio-Olvera L. 2019. kuenm: an R package for detailed development of ecological niche models using Maxent.PeerJ 7:e6281 https://doi.org/10.7717/peerj.6281# #Additional information and a step by step guide for installing and loading packages, and using the main functions of this package can be found in its GitHub repository (https://github.com/marlonecobos/kuenm)# library(kuenm) # Variables with information to be used as arguments. Change "YOUR/DIRECTORY" by your actual directory. #Calibration of models# occ_joint <- "stephadiscus_joint.csv" occ_tra <- "stephadiscus_train.csv" M_var_dir <- "M_variables" batch_cal <- "Candidate_models" out_dir <- "Candidate_Models" reg_mult <- c(0.1,0.5,1,2) f_clas <- c("all") # alternativamente "all" args <- NULL # e.g., "maximumbackground=20000" for increasing the number of pixels in the bacground or # note that some arguments are fixed in the function and should not be changed maxent_path <- "YOUR/DIRECTORY/" # path de maxent wait <- FALSE run <- TRUE kuenm_cal(occ.joint = occ_joint, occ.tra = occ_tra, M.var.dir = M_var_dir, batch = batch_cal, out.dir = out_dir, reg.mult = reg_mult, f.clas = f_clas, args = args, maxent.path = maxent_path, wait = wait, run = run) #Evaluation and selection of best models# occ_test <- "stephadiscus_test.csv" out_eval <- "Calibration_results" threshold <- 5 rand_percent <- 50 iterations <- 100 kept <- TRUE selection <- "OR_AICc" paral_proc <- FALSE cal_eval <- kuenm_ceval(path = out_dir, occ.joint = occ_joint, occ.tra = occ_tra, occ.test = occ_test, batch = batch_cal, out.eval = out_eval, threshold = threshold, rand.percent = rand_percent, iterations = iterations, kept = kept, selection = selection, parallel.proc = paral_proc) #Final model creation# batch_fin <- "Final_models" mod_dir <- "Final_Models" rep_n <- 5 rep_type <- "Bootstrap" jackknife <- FALSE out_format <- "logistic" project <- TRUE G_var_dir <- "G_variables" ext_type <- "no_ext" # para extrapolacion "all" write_mess <- FALSE write_clamp <- FALSE wait1 <- FALSE run1 <- TRUE args <- NULL kuenm_mod(occ.joint = occ_joint, M.var.dir = M_var_dir, out.eval = out_eval, batch = batch_fin, rep.n = rep_n, rep.type = rep_type, jackknife = jackknife, out.dir = mod_dir, out.format = out_format, project = project, G.var.dir =G_var_dir, ext.type = ext_type, write.mess = write_mess, write.clamp = write_clamp, maxent.path = maxent_path, args = args, wait = wait1, run = run1) #Extrapolation risk analysis# sets_var <- "set_01" # a vector of various sets can be used out_mop <- "MOP_results" percent <- 10 paral <- FALSE # make this true to perform MOP calculations in parallel, recommended # only if a powerfull computer is used (see function's help) # Two of the variables used here as arguments were already created for previous functions #To identify extrapolation risk areas# kuenm_mmop(G.var.dir = G_var_dir, M.var.dir = M_var_dir, sets.var = sets_var, out.mop = out_mop, percent = percent, parallel = paral) #To obtain binary presence-absence maps# #Additional information and a step by step guide for installing and loading packages, and using that function of this package can be found in its GitHub repository (https://github.com/narayanibarve/ENMGadgets)# library (ENMGadgets) ModelThreshold(InSuitFile="Stephadiscus_avg.asc", OccurrenceFile="stephadiscus_train.csv", PercentThreshold=0.01, OutSuitFile="stephadiscus_bin_001.asc")