loading maxent into biomod2

988 views
Skip to first unread message

Hisham Ali

unread,
Jul 6, 2018, 5:44:11 AM7/6/18
to Maxent
Hi all, 

I am really stuck trying to run maxent in biomod2. I have tried a couple things which I outlined below. Would really appreciate help,Please see an outline of script below.


many thanks,

Hisham 



I added maxent to working directory: 

I ran this script and got the error below it: 


myBiomodOption <- BIOMOD_ModelingOptions() 



myBiomodModelOut2 <- BIOMOD_Modeling(
+ myBiomodData,                              #formatted biomod data
+ models = c('MAXENT'),#algorithms used 
+ models.options = myBiomodOption,           #algorithms' parameters
+ NbRunEval=1,                              #No. of evaluation runs
+ DataSplit=75,                              # % used to train, rest for test
+ Prevalence=0.5,                            #                          
+ VarImport=3,                               # 
+ models.eval.meth = c('ROC'),         #evaluation metics
+ SaveObj = TRUE,                            #keep results/output on hard drive
+ rescal.all.models = TRUE,                  #
+ do.full.models = FALSE,                    #
+ modeling.id = paste(myRespName,"FirstModeling",sep="")
+    )



Error: Unable to access jarfile /Users/hishamali/Documents/MPhil

 Getting predictions...Error in file(file, "rt") : cannot open the connection
In addition: Warning messages:
1: In system(command = maxent.cmd, wait = TRUE, intern = TRUE, ignore.stdout = FALSE,  :
  running command 'java -mx512m -jar /Users/hishamali/Documents/MPhil data/HPC files/maxent.jar environmentallayers="PA/models/PAFirstModeling/m_13581801/Back_swd.csv" samplesfile="PA/models/PAFirstModeling/m_13581801/Sp_swd.csv" projectionlayers="PA/models/PAFirstModeling/m_13581801/Predictions/Pred_swd.csv" outputdirectory="PA/models/PAFirstModeling/PA_AllData_RUN1_MAXENT.Phillips_outputs" outputformat=logistic  redoifexists visible=FALSE linear=TRUE quadratic=TRUE product=TRUE threshold=TRUE hinge=TRUE lq2lqptthreshold=80 l2lqthreshold=10 hingethreshold=15 beta_threshold=-1 beta_categorical=-1 beta_lqp=-1 beta_hinge=-1 betamultiplier=1 defaultprevalence=0.5 autorun nowarnings notooltips noaddsamplestobackground' had status 1
2: In file(file, "rt") :
  cannot open file 'PA/models/PAFirstModeling/PA_AllData_RUN1_MAXENT.Phillips_outputs/PA_AllData_RUN1_Pred_swd.csv': No such file or directory

Removing Maxent Temp Data..
*** inherits(g.pred,'try-error')
   ! Note :  PA_AllData_RUN1_MAXENT.Phillips failed!
Error in (function (cl, name, valueClass)  : 
  assignment of an object of class “NULL” is not valid for @‘val’ in an object of class “BIOMOD.stored.array”; is(value, "array") is not TRUE




I tried this line, which successfully loaded Maxent I think into R:



mxtPh<- BIOMOD_ModelingOptions (MAXENT = list(. path_to_maxent.jar = "/Users/hishamali/Documents/MPhil data/HPC files"))


which gave:


$path_to_maxent.jar
[1] "/Users/hishamali/Documents/MPhil data/HPC files"



This time, running the same model gave a different error:



Checking Models arguments...
Error in .Models.check.args(data, models, models.options, NbRunEval, DataSplit,  : 
  models.options argument must be a 'BIOMOD.Model.Options.object' (obtained by running ... ) 




The output of calling mxtPh and myBiomodOption are below.



head(  mxtPh)

1 function (GLM = NULL, GBM = NULL, GAM = NULL, CTA = NULL, ANN = NULL,       
2     SRE = NULL, FDA = NULL, MARS = NULL, RF = NULL, MAXENT.Phillips = NULL, 
3     MAXENT.Tsuruoka = NULL)                                                 
4 {                                                                           
5     opt <- new("BIOMOD.Model.Options")                                      
6     if (!is.null(GLM)) {  




myBiomodOption

GLM = list( type = 'quadratic',
            interaction.level = 0,
            myFormula = NULL,
            test = 'AIC',
            family = binomial(link = 'logit'),
            mustart = 0.5,
            control = glm.control(epsilon = 1e-08, maxit = 50, trace = FALSE
) ),

...................

MAXENT.Phillips = list( path_to_maxent.jar = '/Users/hishamali/Documents/MPhil data/HPC files',
               memory_allocated = 512,
               background_data_dir = 'default',
               maximumbackground = 'default',
               maximumiterations = 200,
               visible = FALSE,
               linear = TRUE,
               quadratic = TRUE,
               product = TRUE,
               threshold = TRUE,
               hinge = TRUE,
               lq2lqptthreshold = 80,
               l2lqthreshold = 10,
               hingethreshold = 15,
               beta_threshold = -1,
               beta_categorical = -1,
               beta_lqp = -1,
               beta_hinge = -1,
               betamultiplier = 1,
               defaultprevalence = 0.5),






Reply all
Reply to author
Forward
0 new messages