Skip to content

Commit

Permalink
Merge pull request #327 from biomodhub/devel_current
Browse files Browse the repository at this point in the history
v4.2-5 - 2023 Modeling options and Tuning
  • Loading branch information
MayaGueguen committed Sep 12, 2023
2 parents 5794211 + 40429db commit c96ed83
Show file tree
Hide file tree
Showing 206 changed files with 6,742 additions and 9,016 deletions.
23 changes: 11 additions & 12 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: biomod2
Type: Package
Title: Ensemble Platform for Species Distribution Modeling
Version: 4.2-4-10
Date: 2023-06-15
Version: 4.2-5
Date: 2023-09-12
Authors@R: c(person("Wilfried", "Thuiller", role = c("aut")
, email = "[email protected]"),
person("Damien", "Georges", role = c("aut")),
Expand Down Expand Up @@ -44,22 +44,22 @@ Imports:
abind,
foreach,
ggplot2,
nnet,
gbm (>= 2.1.3),
xgboost,
mda,
randomForest,
maxnet,
rpart,
MASS,
pROC (>= 1.15.0),
PresenceAbsence,
earth,
dplyr
Suggests:
Hmisc,
gam,
mgcv,
earth,
maxnet,
mda,
nnet,
randomForest,
xgboost,
car,
caret,
dismo,
Expand All @@ -79,6 +79,7 @@ VignetteBuilder: knitr
Collate:
'biomod2-package.R'
'biomod2_globalVariables.R'
'biomod2_classes_0.R'
'biomod2_classes_1.R'
'biomod2_classes_2.R'
'biomod2_classes_3.R'
Expand All @@ -91,17 +92,14 @@ Collate:
'BIOMOD_FormatingData.R'
'BIOMOD_LoadModels.R'
'BIOMOD_Modeling.R'
'BIOMOD_ModelingOptions.R'
'BIOMOD_PresenceOnly.R'
'BIOMOD_Projection.R'
'BIOMOD_RangeSize.R'
'BIOMOD_Tuning.R'
'DEPRECATED.R'
'bm_BinaryTransformation.R'
'bm_CrossValidation.R'
'bm_CVnnet.R'
'bm_FindOptimStat.R'
'bm_MakeFormula.R'
'bm_ModelingOptions.R'
'bm_PlotEvalBoxplot.R'
'bm_PlotEvalMean.R'
'bm_PlotRangeSize.R'
Expand All @@ -112,6 +110,7 @@ Collate:
'bm_SRE.R'
'bm_SampleBinaryVector.R'
'bm_SampleFactorLevels.R'
'bm_Tuning.R'
'bm_VariablesImportance.R'
'zzz.R'
LazyData: true
38 changes: 10 additions & 28 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
# Generated by roxygen2: do not edit by hand

export(.transform.outputs.array)
export(.transform.outputs.list)
export(.transform_model.as.col)
export(BIOMOD_ConvertOldRun)
export(BIOMOD_CrossValidation)
export(BIOMOD_EnsembleForecasting)
export(BIOMOD_EnsembleModeling)
export(BIOMOD_FormatingData)
export(BIOMOD_LoadModels)
export(BIOMOD_Modeling)
export(BIOMOD_ModelingOptions)
export(BIOMOD_PresenceOnly)
export(BIOMOD_Projection)
export(BIOMOD_RangeSize)
export(BIOMOD_Tuning)
export(BIOMOD_cv)
export(BIOMOD_presenceonly)
export(BIOMOD_tuning)
export(BinaryTransformation)
export(CustomIndexMaker)
export(FilteringTransformation)
export(Find.Optim.Stat)
export(Print_Default_ModelingOptions)
export(ProbDensFunc)
export(bm_BinaryTransformation)
export(bm_CVnnet)
export(bm_CalculateStat)
export(bm_CrossValidation)
export(bm_CrossValidation_block)
Expand All @@ -34,9 +24,9 @@ export(bm_CrossValidation_kfold)
export(bm_CrossValidation_random)
export(bm_CrossValidation_strat)
export(bm_CrossValidation_user.defined)
export(bm_DefaultModelingOptions)
export(bm_FindOptimStat)
export(bm_MakeFormula)
export(bm_ModelingOptions)
export(bm_PlotEvalBoxplot)
export(bm_PlotEvalMean)
export(bm_PlotRangeSize)
Expand All @@ -52,18 +42,17 @@ export(bm_RunModelsLoop)
export(bm_SRE)
export(bm_SampleBinaryVector)
export(bm_SampleFactorLevels)
export(bm_Tuning)
export(bm_VariablesImportance)
export(calculate.stat)
export(getStatOptimValue)
export(get_optim_value)
export(load_stored_object)
export(makeFormula)
export(models_scores_graph)
export(response.plot)
export(response.plot2)
export(sample.factor.levels)
export(sre)
export(update_objects)
export(variables_importance)
export(zzz_bm)
exportClasses(ANN_biomod2_model)
Expand All @@ -72,6 +61,8 @@ exportClasses(BIOMOD.formated.data)
exportClasses(BIOMOD.formated.data.PA)
exportClasses(BIOMOD.models.options)
exportClasses(BIOMOD.models.out)
exportClasses(BIOMOD.options.dataset)
exportClasses(BIOMOD.options.default)
exportClasses(BIOMOD.projection.out)
exportClasses(BIOMOD.stored.data)
exportClasses(CTA_biomod2_model)
Expand All @@ -95,6 +86,8 @@ exportClasses(biomod2_ensemble_model)
exportClasses(biomod2_model)
exportMethods(BIOMOD.formated.data)
exportMethods(BIOMOD.formated.data.PA)
exportMethods(BIOMOD.options.dataset)
exportMethods(BIOMOD.options.default)
exportMethods(BIOMOD_RangeSize)
exportMethods(bm_BinaryTransformation)
exportMethods(bm_CrossValidation_block)
Expand Down Expand Up @@ -126,20 +119,16 @@ exportMethods(plot)
exportMethods(predict)
exportMethods(show)
exportMethods(summary)
importFrom(MASS,stepAIC)
importFrom(PresenceAbsence,optimal.thresholds)
importFrom(PresenceAbsence,presence.absence.accuracy)
importFrom(abind,abind)
importFrom(abind,asub)
importFrom(dplyr,"%>%")
importFrom(dplyr,mutate_at)
importFrom(dplyr,select_at)
importFrom(earth,earth)
importFrom(foreach,"%:%")
importFrom(foreach,"%do%")
importFrom(foreach,"%dopar%")
importFrom(foreach,foreach)
importFrom(gbm,gbm)
importFrom(gbm,gbm.perf)
importFrom(gbm,predict.gbm)
importFrom(ggplot2,aes)
Expand Down Expand Up @@ -187,36 +176,29 @@ importFrom(graphics,plot.new)
importFrom(graphics,points)
importFrom(graphics,polygon)
importFrom(graphics,text)
importFrom(maxnet,maxnet)
importFrom(mda,fda)
importFrom(mda,mars)
importFrom(methods,as)
importFrom(methods,callNextMethod)
importFrom(methods,formalArgs)
importFrom(methods,new)
importFrom(methods,validObject)
importFrom(nnet,nnet)
importFrom(pROC,auc)
importFrom(pROC,coords)
importFrom(pROC,roc)
importFrom(randomForest,randomForest)
importFrom(reshape,melt.array)
importFrom(reshape2,melt)
importFrom(rpart,prune)
importFrom(rpart,rpart)
importFrom(sp,read.asciigrid)
importFrom(stats,aggregate)
importFrom(stats,as.formula)
importFrom(stats,binomial)
importFrom(stats,complete.cases)
importFrom(stats,cor)
importFrom(stats,formula)
importFrom(stats,glm)
importFrom(stats,median)
importFrom(stats,na.exclude)
importFrom(stats,na.omit)
importFrom(stats,qt)
importFrom(stats,quantile)
importFrom(stats,reshape)
importFrom(stats,rnorm)
importFrom(stats,runif)
importFrom(stats,sd)
importFrom(terra,`add<-`)
importFrom(terra,app)
Expand Down Expand Up @@ -256,11 +238,11 @@ importFrom(terra,xyFromCell)
importFrom(utils,capture.output)
importFrom(utils,combn)
importFrom(utils,head)
importFrom(utils,lsf.str)
importFrom(utils,packageVersion)
importFrom(utils,read.csv)
importFrom(utils,setTxtProgressBar)
importFrom(utils,tail)
importFrom(utils,txtProgressBar)
importFrom(utils,write.table)
importFrom(xgboost,xgboost)
importMethodsFrom(methods,show)
32 changes: 11 additions & 21 deletions R/BIOMOD_EnsembleForecasting.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
##' @keywords models projection
##'
##'
##' @seealso \code{\link{BIOMOD_FormatingData}}, \code{\link{BIOMOD_ModelingOptions}},
##' @seealso \code{\link{BIOMOD_FormatingData}}, \code{\link{bm_ModelingOptions}},
##' \code{\link{BIOMOD_Modeling}}, \code{\link{BIOMOD_EnsembleModeling}},
##' \code{\link{BIOMOD_RangeSize}}
##' @family Main functions
Expand Down Expand Up @@ -153,17 +153,14 @@
##' resp.xy = myRespXY,
##' resp.name = myRespName)
##'
##' # Create default modeling options
##' myBiomodOptions <- BIOMOD_ModelingOptions()
##'
##' # Model single models
##' myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData,
##' modeling.id = 'AllModels',
##' models = c('RF', 'GLM'),
##' bm.options = myBiomodOptions,
##' CV.strategy = 'random',
##' CV.nb.rep = 2,
##' CV.perc = 0.8,
##' OPT.strategy = 'bigboss',
##' metric.eval = c('TSS','ROC'),
##' var.import = 3,
##' seed.val = 42)
Expand Down Expand Up @@ -316,18 +313,13 @@ BIOMOD_EnsembleForecasting <- function(bm.em,
formal_pred <- as.data.frame(formal_pred[, models.needed])
}


## 4. MAKING PROJECTIONS ------------------------------------------------------------------------
proj.em <- foreach(em.name = models.chosen) %dopar%
{
cat("\n\t> Projecting", em.name, "...")
if(do.stack){
filename <- NULL
} else {
# filename <- file.path(namePath, "individual_projections",
# paste0(nameProj, "_", mod.name,
# ifelse(output.format == ".RData"
# , ".tif", output.format)))
filename <- file.path(indiv_proj_dir, paste0(em.name, output.format))
}

Expand Down Expand Up @@ -385,7 +377,7 @@ BIOMOD_EnsembleForecasting <- function(bm.em,
save(list = nameProjSp, file = saved.files, compress = compress)
} else {
writeRaster(x = rast(get(nameProjSp)), filename = saved.files,
overwrite = TRUE, NAflag = -9999)#, datatype = ifelse(on_0_1000, "INT2S", "FLT4S")
overwrite = TRUE, NAflag = -9999, datatype = ifelse(any(grepl("EMcv", models.chosen)), "FLT4S", "INT2S"))
}
}
proj_out@proj.out@link <- saved.files
Expand Down Expand Up @@ -432,8 +424,8 @@ BIOMOD_EnsembleForecasting <- function(bm.em,
writeRaster(x = bm_BinaryTransformation(rast(file.tmp), thres.tmp[i]),
filename = file.tmp.binary,
overwrite = TRUE,
# datatype = "INT2S",
NAflag = -9999)
NAflag = -9999,
datatype = "INT2S")
}

if (eval.meth %in% metric.filter) {
Expand All @@ -444,8 +436,8 @@ BIOMOD_EnsembleForecasting <- function(bm.em,
writeRaster(x = bm_BinaryTransformation(rast(file.tmp), thres.tmp[i], do.filtering = TRUE),
filename = file.tmp.filtered,
overwrite = TRUE,
# datatype = ifelse(on_0_1000, "INT2S", "FLT4S"),
NAflag = -9999)
NAflag = -9999,
datatype = "INT2S")
}
}
}
Expand All @@ -460,8 +452,6 @@ BIOMOD_EnsembleForecasting <- function(bm.em,

if (eval.meth %in% metric.binary) {
nameBin <- paste0(nameProjSp, "_", eval.meth, "bin")


assign(x = nameBin, value = bm_BinaryTransformation(proj.trans, thres.tmp))

file.tmp.binary <- file.path(namePath, paste0(nameBin, output.format))
Expand All @@ -477,8 +467,8 @@ BIOMOD_EnsembleForecasting <- function(bm.em,
writeRaster(x = get(nameBin),
filename = file.tmp.binary,
overwrite = TRUE,
# datatype = "INT2S",
NAflag = -9999)
NAflag = -9999,
datatype = "INT2S")
}
}

Expand All @@ -500,8 +490,8 @@ BIOMOD_EnsembleForecasting <- function(bm.em,
writeRaster(x = get(nameFilt),
filename = file.tmp.filtered,
overwrite = TRUE ,
# datatype = ifelse(on_0_1000, "INT2S", "FLT4S"),
NAflag = -9999)
NAflag = -9999,
datatype = "INT2S")
}
}
}
Expand Down
Loading

0 comments on commit c96ed83

Please sign in to comment.