Reputation: 1
I am encountering an error while using the biomod2 package in R to analyze a dataset consisting of 1000 species and over 10 thousand records. The error message I received is as follows:
"18 nodes produced errors; first error: attempt to set an attribute on NULL"
Along with this error, I also received a warning message stating:
"In searchCommandline(parallel, cpus = cpus, type = type, socketHosts = socketHosts, : Unknown option on commandline: --file"
I am unsure about the cause of this error and how to resolve it. Interestingly, the analysis works with a smaller dataset containing about 20 species, but it fails when applied to the entire dataset.
'{**## build species modelling wrapper ----**
biomod2_wrapper <- function(sp){
cat("\n> species : ", sp)
## get occurrences points
sp_dat <- data[data$species == sp, ]
**## formating the data**
sp_format <-
BIOMOD_FormatingData(
resp.var = rep(1, nrow(sp_dat)),
expl.var = stk_current,
resp.xy = sp_dat[, c("longitude", "latitude")],
resp.name = sp,
PA.strategy = "random",
PA.nb.rep = 2,
PA.nb.absences = 1000
)
**## print formatting summary**
sp_format
**## save image of input data summary**
if(!exists(sp)) dir.create(sp)
pdf(paste(sp, "/", sp ,"_data_formated.pdf", sep=""))
try(plot(sp_format))
dev.off()
**## define models options**
sp_opt <- BIOMOD_ModelingOptions()
**## model species**
sp_model <- BIOMOD_Modeling(
sp_format,
models = c('GBM', 'RF'),
models.options = sp_opt,
NbRunEval = 2,
DataSplit = 70,
Yweights = NULL,
VarImport = 3,
models.eval.meth = c('ROC','TSS'),
SaveObj = TRUE,
rescal.all.models = FALSE,
do.full.models = FALSE,
modeling.id = "demo2"
)
var_imp <- get_variables_importance(sp_model)
write.csv(var_imp, paste0(sp, "/", sp , "_evaluations.csv"))
model.eva <- get_evaluations(sp_model) #get model evaluations of calibrate data
pdf(paste0(sp, "/", sp , "_models_scores.pdf"))
try(gg1 <- models_scores_graph(sp_model, metrics = c("TSS", "ROC"), by = 'models', plot = FALSE))
try(gg2 <- models_scores_graph(sp_model, metrics = c("TSS", "ROC"), by = 'data_set', plot = FALSE))
try(gg3 <- models_scores_graph(sp_model, metrics = c("TSS", "ROC"), by = 'cv_run', plot = FALSE))
try(grid.arrange(gg1, gg2, gg3))
dev.off()
**## build ensemble models**
sp_ens_model <-
BIOMOD_EnsembleModeling(
modeling.output = sp_model,
em.by = 'all',
eval.metric = 'TSS',
eval.metric.quality.threshold = 0.4,
models.eval.meth = c('TSS','ROC'),
prob.mean = FALSE,
prob.mean.weight = TRUE,
VarImport = 0
)
write.csv(get_evaluations(sp_model),file=paste0(sp,"/", sp ,"EM_evaluationscores.csv"),row.names=T)
proj_scen <- c("LGM", "MID", "current")
for(scen in proj_scen){
cat("\n> projections of ", scen)
**## single model projections**
sp_proj <-
BIOMOD_Projection(
modeling.output = sp_model,
new.env = get(paste0("stk_", scen)),
#new.env = proj.ext,
proj.name = scen,
selected.models = 'all',
binary.meth = "TSS",
filtered.meth = NULL,
compress = TRUE,
build.clamping.mask = FALSE,
do.stack = FALSE,
output.format = ".img"
)
**## ensemble model projections**
sp_ens_proj <-
BIOMOD_EnsembleForecasting(
EM.output = sp_ens_model,
projection.output = sp_proj,
binary.meth = "TSS",
compress = TRUE,
do.stack = FALSE,
output.format = ".img"
)
}
return(paste0(sp," modelling completed !"))
}
**## launch the species modelling wrapper over the species list**
if(require(snowfall)){
sfInit(parallel = TRUE, cpus = 5)
sfExportAll()
sfLibrary(biomod2)
sf_out <- sfLapply(spp_to_model, biomod2_wrapper)
sfStop()
} else { ## sequential computation
for (sp in spp_to_model){
biomod2_wrapper(sp)
}
}}
'''R'
Upvotes: 0
Views: 168