biomodhub / biomod2

BIOMOD is a computer platform for ensemble forecasting of species distributions, enabling the treatment of a range of methodological uncertainties in models and the examination of species-environment relationships.
85 stars 22 forks source link

Error in BIOMOD_4.2-4 - task 1 failed - "task 1 failed - "argument is of length zero"" #514

Open DinoBiancolini opened 2 weeks ago

DinoBiancolini commented 2 weeks ago

Hello there,

I am trying to model the distribution of a species, Bombina variegata, in Northen Italy, but I get a strange error from the BIOMOD_EnsembleModeling function:

Error in { : task 1 failed - "task 1 failed - "argument is of length zero""

I use the same script and raster data for other 50 species, without getting this error. I suspect there is something wrong with species data, but I can not find the problem.

Thanks in advance, Dino

Code used to get the error

spFILEcal <- read.csv("Bombina variegata.csv") spFILEcal <- spFILEcal[, c(2, 1)] spFILEcal$Occ <- 1 colnames(spFILEcal) <- c("decimalLon", "decimalLat", selected_species)

myRespName <- selected_species myResp <- as.numeric(spFILEcal[, myRespName]) myRespCoord <- spFILEcal[c("decimalLat", "decimalLon")]

myBiomodata <- BIOMOD_FormatingData( resp.var = myResp, expl.var = ExplVar_cropped, resp.xy = myRespCoord, resp.name = myRespName, PA.nb.rep = 3, PA.nb.absences = nrow(myRespCoord), PA.strategy = 'random', filter.raster = TRUE, na.rm = TRUE )

plot(myBiomodata) immagine

summary(myBiomodata) dataset run PA Presences True_Absences Pseudo_Absences Undefined 1 initial NA 80 0 0 228 2 calibration NA PA1 80 0 228 NA 3 calibration NA PA2 80 0 228 NA 4 calibration NA PA3 80 0 228 NA 5 calibration NA PA1 80 0 228 NA 6 calibration NA PA2 80 0 228 NA 7 calibration NA PA3 80 0 228 NA 8 calibration NA PA1 80 0 228 NA 9 calibration NA PA2 80 0 228 NA 10 calibration NA PA3 80 0 228 NA

myBiomodOption <- BIOMOD_ModelingOptions()

myBiomodModelOut <- BIOMOD_Modeling( myBiomodata, models = c("GBM", "GAM", "CTA", "MARS", "RF"), bm.options = myBiomodOption, CV.strategy = "random", CV.nb.rep = 3, CV.perc = 0.7, metric.eval = c('ROC'), CV.do.full.models = FALSE, nb.cpu = 8, modeling.id = selected_species )

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= BIOMOD.models.out -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Modeling folder : .

Species modeled : Bombina.variegata

Modeling id : Bombina variegata

Considered variables : pr1mm5d pravemax pravemax5d tmax30 tmaxavemin tmaxavemin5d

Computed Models : Bombina.variegata_PA1_RUN1_GBM Bombina.variegata_PA1_RUN1_GAM Bombina.variegata_PA1_RUN1_CTA Bombina.variegata_PA1_RUN1_MARS Bombina.variegata_PA1_RUN1_RF Bombina.variegata_PA1_RUN2_GBM Bombina.variegata_PA1_RUN2_GAM Bombina.variegata_PA1_RUN2_CTA Bombina.variegata_PA1_RUN2_MARS Bombina.variegata_PA1_RUN2_RF Bombina.variegata_PA1_RUN3_GBM Bombina.variegata_PA1_RUN3_GAM Bombina.variegata_PA1_RUN3_CTA Bombina.variegata_PA1_RUN3_MARS Bombina.variegata_PA1_RUN3_RF Bombina.variegata_PA2_RUN1_GBM Bombina.variegata_PA2_RUN1_GAM Bombina.variegata_PA2_RUN1_CTA Bombina.variegata_PA2_RUN1_MARS Bombina.variegata_PA2_RUN1_RF Bombina.variegata_PA2_RUN2_GBM Bombina.variegata_PA2_RUN2_GAM Bombina.variegata_PA2_RUN2_CTA Bombina.variegata_PA2_RUN2_MARS Bombina.variegata_PA2_RUN2_RF Bombina.variegata_PA2_RUN3_GBM Bombina.variegata_PA2_RUN3_GAM Bombina.variegata_PA2_RUN3_CTA Bombina.variegata_PA2_RUN3_MARS Bombina.variegata_PA2_RUN3_RF Bombina.variegata_PA3_RUN1_GBM Bombina.variegata_PA3_RUN1_GAM Bombina.variegata_PA3_RUN1_CTA Bombina.variegata_PA3_RUN1_MARS Bombina.variegata_PA3_RUN1_RF Bombina.variegata_PA3_RUN2_GBM Bombina.variegata_PA3_RUN2_GAM Bombina.variegata_PA3_RUN2_CTA Bombina.variegata_PA3_RUN2_MARS Bombina.variegata_PA3_RUN2_RF Bombina.variegata_PA3_RUN3_GBM Bombina.variegata_PA3_RUN3_GAM Bombina.variegata_PA3_RUN3_CTA Bombina.variegata_PA3_RUN3_MARS Bombina.variegata_PA3_RUN3_RF

Failed Models : none

myBiomodEM <- BIOMOD_EnsembleModeling( bm.mod = myBiomodModelOut, models.chosen = 'all', em.by = 'all', em.algo = c('EMwmean'), metric.select = c('ROC'), metric.select.thresh = c(0.7), metric.eval = c('ROC', "TSS"), var.import = 3 )

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Build Ensemble Models -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

! all models available will be included in ensemble.modeling ! Ensemble Models will be filtered and/or weighted using validation dataset (if possible). Please use metric.select.dataset for alternative options.

Evaluation & Weighting methods summary : ROC over 0.7

mergedData_mergedRun_mergedAlgo ensemble modeling ! Additional projection required for ensemble models merging several pseudo-absence dataset... -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Do Single Models Projection -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Done -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Do Single Models Projection -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Done -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Do Single Models Projection -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Done -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Error in { : task 1 failed - "task 1 failed - "argument is of length zero""

Environment Information R version 4.3.1 (2023-06-16) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS 15.0

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Rome tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] sf_1.0-14 usdm_2.1-7 stringr_1.5.1 dismo_1.3-14
[5] dplyr_1.1.4 gridExtra_2.3 ggplot2_3.4.4 virtualspecies_1.6
[9] terra_1.7-55 PresenceAbsence_1.1.11 raster_3.6-26 sp_2.1-4
[13] ecospat_3.5.1 biomod2_4.2-4

loaded via a namespace (and not attached): [1] rstudioapi_0.15.0 jsonlite_1.8.7 magrittr_2.0.3 farver_2.1.1 rmarkdown_2.25
[6] fs_1.6.3 vctrs_0.6.4 memoise_2.0.1 base64enc_0.1-3 htmltools_0.5.6.1
[11] usethis_2.2.2 plotrix_3.8-2 xgboost_1.7.5.1 Formula_1.2-5 pROC_1.18.5
[16] pracma_2.4.2 KernSmooth_2.23-22 htmlwidgets_1.6.2 plyr_1.8.9 poibin_1.5
[21] cachem_1.0.8 commonmark_1.9.0 mime_0.12 lifecycle_1.0.4 iterators_1.0.14
[26] pkgconfig_2.0.3 Matrix_1.6-1.1 R6_2.5.1 fastmap_1.1.1 plotmo_3.6.2
[31] shiny_1.7.5.1 digest_0.6.33 colorspace_2.1-0 reshape_0.8.9 ps_1.7.5
[36] pkgload_1.3.3 Hmisc_5.1-1 vegan_2.6-4 randomForest_4.7-1.1 fansi_1.0.5
[41] gbm_2.1.8.1 abind_1.4-5 mgcv_1.9-0 compiler_4.3.1 proxy_0.4-27
[46] remotes_2.5.0 doParallel_1.0.17 withr_2.5.2 htmlTable_2.4.1 backports_1.4.1
[51] DBI_1.1.3 pkgbuild_1.4.2 MASS_7.3-60 sessioninfo_1.2.2 classInt_0.4-10
[56] gtools_3.9.4 permute_0.9-7 units_0.8-5 tools_4.3.1 foreign_0.8-85
[61] ape_5.7-1 httpuv_1.6.11 TeachingDemos_2.12 nnet_7.3-19 glue_1.6.2
[66] callr_3.7.3 nlme_3.1-163 promises_1.2.1 gridtext_0.1.5 grid_4.3.1
[71] checkmate_2.2.0 cluster_2.1.4 reshape2_1.4.4 ade4_1.7-22 generics_0.1.3
[76] maxnet_0.1.4 gtable_0.3.4 class_7.3-22 tidyr_1.3.0 nabor_0.5.0
[81] data.table_1.14.8 xml2_1.3.5 utf8_1.2.4 markdown_1.10 foreach_1.5.2
[86] pillar_1.9.0 later_1.3.1 splines_4.3.1 ggtext_0.1.2 lattice_0.21-9
[91] survival_3.5-7 ks_1.14.1 tidyselect_1.2.0 miniUI_0.1.1.1 knitr_1.44
[96] xfun_0.40 devtools_2.4.5 stringi_1.8.2 evaluate_0.22 codetools_0.2-19
[101] spatialEco_2.0-2 tibble_3.2.1 tidyterra_0.4.0 cli_3.6.1 rpart_4.1.21
[106] xtable_1.8-4 munsell_0.5.0 processx_3.8.2 Rcpp_1.0.11 parallel_4.3.1
[111] ellipsis_0.3.2 mda_0.5-4 prettyunits_1.2.0 mclust_6.0.0 profvis_0.3.8
[116] urlchecker_1.0.1 mvtnorm_1.2-3 scales_1.3.0 e1071_1.7-13 earth_5.3.2
[121] purrr_1.0.2 crayon_1.5.2 rlang_1.1.2

HeleneBlt commented 2 weeks ago

Hi Dino,

This comes from an old error : we corrected it in the last version. You can download the GitHub version 4.2-6-1 with : devtools::install_github("biomodhub/biomod2", dependencies = TRUE)

Actually, the error comes from the presence of "bin" in the species names 🙈 So if you change it, it should disappear without changing the version. 🙂

Hélène

DinoBiancolini commented 2 weeks ago

Hi Hélène, thank you very much for your quick response! That's very odd. I've changed the name and it worked. Best, Dino