Open jiayuanxie opened 1 year ago
Hello JY Xie,
Thank you for reporting :pray:
Could you try changing your BIOMOD_FormatingData command by this please ?
Sp.biomod.data = BIOMOD_FormatingData(resp.name = Resp.name,
resp.var = Resp.vector,
expl.var = Sdm.env,
resp.xy = Resp.coor,
na.rm = TRUE,
dir.name = "D:/Rtry/SDM/")
It seems biomod2
get a bit lost through file names.
Maya
Hello JY Xie,
Thank you for reporting 🙏
Could you try changing your BIOMOD_FormatingData command by this please ?
Sp.biomod.data = BIOMOD_FormatingData(resp.name = Resp.name, resp.var = Resp.vector, expl.var = Sdm.env, resp.xy = Resp.coor, na.rm = TRUE, dir.name = "D:/Rtry/SDM/")
It seems
biomod2
get a bit lost through file names.Maya
Maya,
Thank you for your prompt reply!
According to your advising, I just have tried the method, but it seem to not work with the same error above, do you have any other suggestion? Indeed, I have tried on two computer, so it should not be responsible for computer or file name.
JY XIE
#######################Format sdm data for biomod2 Sp.biomod.data = BIOMOD_FormatingData(resp.name = Resp.name, resp.var = Resp.vector, expl.var = Sdm.env, resp.xy = Resp.coor, na.rm = T, dir.name = "D:/Rtry/SDM/")
#######################Defining Models Options using default options sdm.opt.default = BIOMOD_ModelingOptions( MAXENT = list( path_to_maxent.jar = "D:/Rtry/SDM/maxent.jar"))
####################Constrcut sdm models by setting parameters Bio.mod.all = BIOMOD_Modeling( bm.format = Sp.biomod.data, models = "MAXENT", models.pa = Sp.biomod.data@data.species, bm.options = sdm.opt.default, CV.strategy = 'random',
CV.nb.rep = 1,
#80% of data train the model
CV.perc = 0.8,
#models be calibrated and validated over the whole dataset
CV.do.full.models = F,
#Below arg is whether control the weight?
weights=NULL,
#absences will be weighted equally to the presences
prevalence = 0.5,
#Set model evaluations methods
metric.eval = mode.eva,
#Number of permutation to estimate variable importance
var.import = 1,
nb.cpu =1,
do.progress =T)
Thank you for trying :pray:
Could you try and check into your files browser if the files mentioned really exist or not ?
the files "D:/Rtry/SDM/maxent.jar" & "D:/Rtry/SDM/" both exist,
In addition, It's interesting, my error was: Getting predictions...Error in file(file, "rt") : cannot open the connection In addition: Warning messages: 1: executing %dopar% sequentially: no parallel backend registered 2: In file(file, "rt") : cannot open file 'D:/Rtry/SDM//Bandicota.bengalensis.mach.1/models/1696861384/Bandicota.bengalensis.mach.1_allData_RUN1_MAXENT_outputs/Bandicota.bengalensis.mach.1_allData_RUN1_Pred_swd.csv': No such file or directory
but there exist a file named "Pred_swd.csv" in the path(my species name is "Bandicota.bengalensis.mach.1"): D:\Rtry\SDM\Bandicota.bengalensis.mach.1\models\1696860853\Bandicota.bengalensis.mach.1_allData_RUN1_MAXENT_outputs\Predictions\Pred_swd.csv. I guess the file bring the bug to me. it make me fell confused, the file is generated by my codes, why they can't found it?
Huuum it is not the same path in the error message :
D:/Rtry/SDM//Bandicota.bengalensis.mach.1/models/1696861384/Bandicota.bengalensis.mach.1_allData_RUN1_MAXENT_outputs/Bandicota.bengalensis.mach.1_allData_RUN1_Pred_swd.csv
and in your folder :
D:\Rtry\SDM\Bandicota.bengalensis.mach.1\models\1696860853\Bandicota.bengalensis.mach.1_allData_RUN1_MAXENT_outputs\Predictions\Pred_swd.csv
The numbers do not match. You can give a modeling.id
parameter value to the BIOMOD_Modeling function to have more explicit path.
Try starting again from a blank repository.
Thanks for your reminding! Yeah, it's not the same path in the error message due to I have tried many times, So created many similar folders, but their hierarchical structures and error are same!
Try starting again from a blank repository seem have no impact on my error, so , it's really a headache problem!
Hello, the maintenance team of Biomod2:
I'm a ecological doctor. recently, I was working with biomod2 to finish my project, but meet some troubles which beyond my ability to solve. So can you help me?
Error and context When I run Maxent in biomod2, I meet the error, although I have tried many solutions which other people have solved their similar problems, but they didn't work with my code. I have tried to change the file path of maxent.jar to without any spaces or change the system environmental variables(followed: http://modata.ceoe.udel.edu/dev/dhaulsee/class_rcode/r_pkgmanuals/MAXENT4R_directions.pdf), but they don't help me for my trouble.
Code used to get the error #######################Format sdm data for biomod2 Sp.biomod.data = BIOMOD_FormatingData(resp.name = Resp.name, resp.var = Resp.vector, expl.var = Sdm.env, resp.xy = Resp.coor, na.rm = T, dir.name = paste("D:/Rtry/SDM",Resp.name,sep = "/"))
#######################Defining Models Options using default options sdm.opt.default = BIOMOD_ModelingOptions( MAXENT = list( path_to_maxent.jar = "C://Users//Public//maxent.jar"))
####################Constrcut sdm models by setting parameters Bio.mod.all = BIOMOD_Modeling( bm.format = Sp.biomod.data, models = "MAXENT", models.pa = Sp.biomod.data@data.species, bm.options = sdm.opt.default, CV.strategy = 'random',
Number of Evaluation run
show errors
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Build Single Models -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Checking Models arguments... Warning in .BIOMOD_Modeling.check.args(bm.format = bm.format, modeling.id = modeling.id, : models.pa has been disabled because no PA datasets have been given
Creating suitable Workdir...
Checking Cross-Validation arguments...
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Bandicota.bengalensis.reg.1 Modeling Summary -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8 environmental variables ( PCA_1 PCA_2 PCA_3 PCA_4 PCA_5 PCA_6 PCA_7 PCA_8 ) Number of evaluation repetitions : 1 Models selected : MAXENT
Total number of model runs: 1
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=--=-=-=- Bandicota.bengalensis.reg.1_allData_RUN1_MAXENT
Model=MAXENT
Getting predictor contributions...Error in file(fname, "r") : cannot open the connection In addition: Warning messages: 1: In system(command = maxent.command, wait = TRUE, intern = TRUE) : running command 'java -mx512m -cp "C:\Users\Public/maxent.jar" density.Project "" "D:/Rtry/SDM/Bandicota.bengalensis.reg.1/Bandicota.bengalensis.reg.1/models/1696750966/Bandicota.bengalensis.reg.1_allData_RUN1_MAXENT_outputs/Predictions/Pred_swdBis_5125.csv" "D:/Rtry/SDM/Bandicota.bengalensis.reg.1/Bandicota.bengalensis.reg.1/models/1696750966/Bandicota.bengalensis.reg.1_allData_RUN1_MAXENT_outputs/projMaxent.asc" doclamp=false visible=false autorun nowarnings notooltips' had status 1 2: In file(fname, "r") : cannot open file 'D:/Rtry/SDM/Bandicota.bengalensis.reg.1/Bandicota.bengalensis.reg.1/models/1696750966/Bandicota.bengalensis.reg.1_allData_RUN1_MAXENT_outputs/projMaxent.asc': No such file or directory Error in { : task 1 failed - "Unable to make model prediction"
show(Bio.mod.all)
Inaddition, my computer system is windows 10; R version is R-4.3.1; Java version is "21" 2023-09-19 LTS; Biomod2 package version is 4.2-4
To now, I really have tried many methods to solve my problem, but them didn't work, If you can help me , I will be great grateful!!!
Thanks , from JY Xie