Skip to content

Commit

Permalink
Merge pull request #73 from goldingn/master
Browse files Browse the repository at this point in the history
inline with modules, and tied to a specific version, ready to be tagged
  • Loading branch information
goldingn committed Aug 14, 2015
2 parents 1b77474 + d2a9bea commit 50f39bd
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 16 deletions.
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ Package: zoon
Type: Package
Title: Reproducible, accessible & shareable species distribution modelling
in R.
Version: 0.3
Date: 2014-08-04
Author: Tim Lucas, Nick Golding, Greg McInerny, Emiel van Loon
Maintainer: Tim Lucas <[email protected]>
Version: 0.3.1
Author: Tim Lucas, Nick Golding, Tom August, Greg McInerny, Emiel van Loon
Maintainer: Tom August <[email protected]>
Description: A package for reproducible species distribution modelling. The
package reads user submitted modules from an online repository, runs full
SDM workflows and returns output that is fully reproducible.
Expand All @@ -18,7 +17,8 @@ Imports:
httpuv,
dismo
Depends:
raster
raster,
R (>= 3.2.0)
Suggests:
knitr,
testthat
Expand Down
29 changes: 29 additions & 0 deletions R/DataDocumentation.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,32 @@ NULL

NULL



#' @name CWBZim
#' @title Presence/absence of the coffee white stem borer in Zimbabwe 2003
#' @description This is an example presence/absence dataset for the
#' coffee white stem borer \emph{Monochamus leuconotus} P. taken from an
#' open access dataset on the Dryad data repository.
#' The data are made available by those authors under a Creative Commons CC0
#' These data are used in the module CWBZimbabwe which can be used for running
#' toy presence/absence species distribution models.
#' @docType data
#' @format data.frame with five columns, longitude, latitude, value (1 for
#' presence), type (presence) and a column of 1s indicating this is
#' training data not external validation data.
#' @source Original publication:
#' Kutywayo D, Chemura A, Kusena W, Chidoko P, Mahoya C (2013) The impact of
#' climate change on the potential distribution of agricultural pests: the case
#' of the coffee white stem borer (\emph{Monochamus leuconotus} P.) in
#' Zimbabwe. PLoS ONE 8(8): e73432.
#' Dryad data package:
#' Kutywayo D, Chemura A, Kusena W, Chidoko P, Mahoya C (2013) Data from:
#' The impact of climate change on the potential distribution of agricultural
#' pests: the case of the coffee white stem borer (\emph{Monochamus
#' leuconotus} P.) in Zimbabwe. Dryad Digital Repository.
#' \url{http://dx.doi.org/10.1371/journal.pone.0073432}
#'
#' @author Nick Golding August 2015

NULL
12 changes: 11 additions & 1 deletion R/SearchFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,17 @@ make_url <- function(owner, repo, sha) {
gh_list_files <- function(owner, repo, ...) {
token <- github_auth(appname = "zoonproject", key = "945195231bd7edd336c9", secret = 'd43d121439b081db59e5f0852e25712294128e2f')

sha <- FindNewestCommit(owner, rep, token)
# if this is a dev version, find the most recent version of modules
if (.sha == 'master') {

sha <- FindNewestCommit(owner, rep, token)

} else {

# otherwise use the target sha for modules
sha <- .sha

}

req <- GET(make_url(owner, repo, sha), config = list(token = token))
out <- content(req)
Expand Down
9 changes: 9 additions & 0 deletions R/zoon.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
# A PROTOTYPE FOR REPRODUCIBLE, ACCESSIBLE & SHAREABLE SCIENTIFIC OUTPUTS IN R




# name a specific sha for an state of the modules repo, for tagged
# versions of zoon, or 'master' for non-tagged versions
.sha <- 'b1544fbadaa21c41b4b51922ae73e44923b890ed'
#.sha <- 'master'



#'Zoon: A package for comparing multple SDM models, good model diagnostics
#' and better reproducibility
#'@name zoon
Expand Down
6 changes: 4 additions & 2 deletions R/zoonHelpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ LoadModule <- function(module){
module <- gsub('"', '', module)

# Create url that matches zoon repo
# .sha will vary based on whether this is pegged to a specific version of
# modules
zoonURL <-
paste0('https://raw.githubusercontent.com/zoonproject/modules/master/R/',
module, '.R')
sprintf('https://raw.githubusercontent.com/zoonproject/modules/%s/R/%s.R',
.sha, module)

# If module is a path, load module
if (file.exists(module)){
Expand Down
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,35 @@ You'll need to be using R version 3.2.0 or higher.
On Windows:

```r
# install the raster package first
install.packages('raster')

# install the Windows binary of the latest release
install.packages('https://github.com/zoonproject/zoon/releases/download/0.3/zoon_0.3.zip',
install.packages('https://github.com/zoonproject/zoon/releases/download/0.3.1/zoon_0.3.1.zip',
repos = NULL, method = 'libcurl')

# install dependencies
install.packages(pkgDepends('zoon')$Depends)

# install imports
install.packages(unlist(strsplit(gsub(',', '', installed.packages(fields = c('imports'))['zoon','Imports']), '\n'))[-1])

# load zoon
library(zoon)
```

and on OSX or Linux:

```r
# install the raster package first
install.packages('raster')

# install the Windows binary of the latest release
install.packages('https://github.com/zoonproject/zoon/releases/download/0.3/zoon_0.3.tar.gz',
install.packages('https://github.com/zoonproject/zoon/releases/download/0.3.1/zoon_0.3.1.tar.gz',
repos = NULL, method = 'libcurl')

# install dependencies
install.packages(pkgDepends('zoon')$Depends)

# install imports
install.packages(unlist(strsplit(gsub(',', '', installed.packages(fields = c('imports'))['zoon','Imports']), '\n'))[-1])

# load zoon
library(zoon)
```


Expand Down
Binary file added data/CWBZim.RData
Binary file not shown.
34 changes: 34 additions & 0 deletions man/CWBZim.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/DataDocumentation.R
\docType{data}
\name{CWBZim}
\alias{CWBZim}
\title{Presence/absence of the coffee white stem borer in Zimbabwe 2003}
\format{data.frame with five columns, longitude, latitude, value (1 for
presence), type (presence) and a column of 1s indicating this is
training data not external validation data.}
\source{
Original publication:
Kutywayo D, Chemura A, Kusena W, Chidoko P, Mahoya C (2013) The impact of
climate change on the potential distribution of agricultural pests: the case
of the coffee white stem borer (\emph{Monochamus leuconotus} P.) in
Zimbabwe. PLoS ONE 8(8): e73432.
Dryad data package:
Kutywayo D, Chemura A, Kusena W, Chidoko P, Mahoya C (2013) Data from:
The impact of climate change on the potential distribution of agricultural
pests: the case of the coffee white stem borer (\emph{Monochamus
leuconotus} P.) in Zimbabwe. Dryad Digital Repository.
\url{http://dx.doi.org/10.1371/journal.pone.0073432}
}
\description{
This is an example presence/absence dataset for the
coffee white stem borer \emph{Monochamus leuconotus} P. taken from an
open access dataset on the Dryad data repository.
The data are made available by those authors under a Creative Commons CC0
These data are used in the module CWBZimbabwe which can be used for running
toy presence/absence species distribution models.
}
\author{
Nick Golding August 2015
}

0 comments on commit 50f39bd

Please sign in to comment.