Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New arguments to MaxEnt module #170

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ r_binary_packages:
# Install zoon from Github
r_github_packages:
- zoonproject/zoon
- goldingn/GRaF

# Install devtools to allow travis to work.
r_packages:
Expand Down
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Depends:
glmnet,
rJava,
mgcv,
GRaF,
sperrorest,
SDMTools,
randomForest,
Expand All @@ -53,4 +52,4 @@ Suggests:
roxygen2
VignetteBuilder: knitr
LazyData: TRUE
RoxygenNote: 6.0.1
RoxygenNote: 6.1.0
35 changes: 26 additions & 9 deletions R/MaxEnt.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#'
#' @description Model module to fit MaxEnt model via the dismo package
#'
#'@details In order to fit a MaxEnt model, you must first download the
#' @details In order to fit a MaxEnt model, you must first download the
#' MaxEnt executable file \code{maxent.jar} and save it in the correct location.
#' The zoon function \code{GetMaxEnt} can orchestrate this for you.
#' Running MaxEnt also requires an up-to-date version of java
#' (which you may already have installed).
#'
#'@param .df \strong{Internal parameter, do not use in the workflow function}.
#' @param .df \strong{Internal parameter, do not use in the workflow function}.
#' \code{.df} is data frame that combines the occurrence data and covariate
#' data. \code{.df} is passed automatically in workflow from the process
#' module(s) to the model module(s) and should not be passed by the user.
Expand All @@ -21,20 +21,36 @@
#' (which may or may not be up-to-date) in this forum:
#' \url{https://groups.google.com/d/msg/maxent/yRBlvZ1_9rQ/Fj8Two0lmHIJ}.
#'
#' @param path Filepath to choose where to save MaxEnt's html output file. Defaults
#' to getwd().
#'
#' @param factors Character string of the name of variables to be treated as factors.
#'
#' @seealso \code{\link{dismo::maxent}}
#'
#' @author ZOON Developers, \email{zoonproject@@gmail.com}
#' @section Version: 1.0
#' @author ZOON Developers, David Wilkinson \email{zoonproject@@gmail.com}
#' @section Version: 1.1
#' @section Date submitted: 2015-11-13
#' @section Date modified: 2018-04-24
#' @section Data type: presence/background
#'
#' @name MaxEnt
#' @family model
MaxEnt <- function(.df, args = ''){

MaxEnt <- function(.df,
args = '',
path = getwd(),
factors = NULL){

zoon::GetPackage('dismo')
zoon::GetPackage('rJava')

if(!is.null(factors)){

.df[ , factors] <- as.factor(.df[ , factors])

}

covs <- as.data.frame(.df[, attr(.df, 'covCols')])
names(covs) <- attr(.df, 'covCols')

Expand All @@ -49,7 +65,8 @@ MaxEnt <- function(.df, args = ''){

m <- maxent(x = covs,
p = .df$value,
args = args)
args = args,
path = path)

# create a ZoonModel object and return it
ZoonModel(model = m,
Expand All @@ -62,9 +79,9 @@ MaxEnt <- function(.df, args = ''){
na_idx <- attr(newdata_clean, 'na.action')
if (is.null(na_idx)) idx <- 1:nrow(newdata)
else idx <- -na_idx
p[idx] <- dismo::predict(model,
newdata_clean,
type = 'response')
p[idx] <- dismo::predict(model,
newdata_clean,
type = 'response')
return (p)
},
packages = 'dismo')
Expand Down
1 change: 1 addition & 0 deletions man/AIC.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/AUC.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/AddRandomUniformPredictors.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/AirNCEP.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/AnophelesPlumbeus.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/Appify.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/Background.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/BackgroundAndCrossvalid.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/Bioclim.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/Bioclim_future.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/BiomodModel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/Bootstrap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/CWBZimbabwe.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/CarolinaWrenPA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/CarolinaWrenPO.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/CarolinaWrenRasters.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/CarolinaWrenValidation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/Clean.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/CoefficientPlot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/CovHistograms.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/Crossvalidate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/DataSummary.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/Deviance.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/Domain.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/GBM.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/GenerateCovariateReport.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/InteractiveCovariateMap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/InteractiveMap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/InteractiveOccurrenceMap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/JitterOccurrence.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions man/LocalOccurrenceData.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/LocalOccurrenceDataFrame.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/LocalRaster.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/LogisticRegression.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/LonLatToCovariates.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/Lorem_ipsum_UK.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/MESSMask.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/MachineLearn.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading