Commit 27d7b4e1 authored by Jean-Francois Rey's avatar Jean-Francois Rey
Browse files

Merge commit 'f5ad0829'

From Dev
parents e6912bf3 f5ad0829
Pipeline #1843 passed with stages
in 48 minutes and 34 seconds
......@@ -8,3 +8,18 @@
^.*\.Rproj$
^\.Rproj\.user$
^landsepi_.*\.tar\.gz$
^src/*\.o$
^src/*\.so$
^src/Makevars$
^man/GDAL_API
^tests/strategies
^inst/shiny-landsepi/www/.*\.tiff$
^inst/shiny-landsepi/www/.*\.png$
^inst/shiny-landsepi/www/.*\.txt$
^inst/shiny-landsepi/www/.*\.gpkg$
^inst/shiny-landsepi/www/.*\.mp4$
^inst/shiny-landsepi/www/maps
^local
^windows
^doc$
^Meta$
*.Rproj*
.Rhistory
.RData
.Ruserdata
src/*.o
src/*.so
src/*.dll
src/Makevars
src/exemple/GDAL_API_exemple
src/exemple/*.o
config\.log
config\.status
landsepiDev*
.Rproj.user
simul_landsepi_*
nbproject/
src/doxygen-config
\.vscode/
doc
Meta
stages:
- build
- test
stages:
- build_test
- packages
- build_img
- deploy
r-build:
stage: build
r-build_test:
stage: build_test
tags:
- "r-base-biosp"
script:
- "Rscript -e \"pkgbuild::compile_dll()\""
- "Rscript -e \"roxygen2::roxygenize('.', roclets=c('rd', 'collate', 'namespace'))\""
- "R CMD build . --resave-data"
artifacts:
paths:
- "$(ls -rt landsepi_*.tar.gz |tail -1)"
r-test:
stage: test
tags:
- "r-base-biosp"
script:
- "R CMD build . --resave-data --compact-vignettes=both"
- "R CMD check --as-cran $(ls -rt landsepi_* |tail -1)"
artifacts:
paths:
- "$(ls -rt landsepi_*.tar.gz |tail -1)"
dependencies:
- r-build
r-devel-build:
stage: build
r-devel-build_test:
stage: build_test
tags:
- "r-devel-biosp"
script:
- "Rscript -e \"pkgbuild::compile_dll()\""
- "Rscript -e \"roxygen2::roxygenize('.', roclets=c('rd', 'collate', 'namespace'))\""
- "R CMD build . --resave-data"
artifacts:
paths:
- "$(ls -rt landsepi_*.tar.gz |tail -1)"
r-devel-test:
stage: test
tags:
- "r-devel-biosp"
script:
- "R CMD build . --resave-data --compact-vignettes=both"
- "R CMD check --as-cran $(ls -rt landsepi_* |tail -1)"
dependencies:
- r-devel-build
r-Mac-build:
stage: build
tags:
- "Mac"
- "R"
script:
- "Rscript -e \"roxygen2::roxygenize('.', roclets=c('rd', 'collate', 'namespace'))\""
- "R CMD build . --resave-data"
artifacts:
paths:
- "$(ls -rt landsepi_*.tar.gz |tail -1)"
allow_failure: true
r-Mac-test:
stage: test
r-Mac-build_test:
stage: build_test
tags:
- "Mac"
- "R"
- "R4"
script:
- 'TMPDIR="/tmp" && Rscript -e "pkgbuild::compile_dll()"'
- "Rscript -e \"roxygen2::roxygenize('.', roclets=c('rd', 'collate', 'namespace'))\""
- "R CMD build . --resave-data --compact-vignettes=both"
- "R CMD check --as-cran $(ls -rt landsepi_* |tail -1)"
dependencies:
- r-Mac-build
artifacts:
paths:
- "$(ls -rt landsepi_*.tar.gz |tail -1)"
r-windows-build:
stage: build
r-windows-build_test:
stage: build_test
tags:
- "win10"
- "R"
- "binaries"
script:
- "Rscript -e \"roxygen2::roxygenize('.',roclets=c('rd','collate','namespace'))\""
- "R CMD build . --resave-data"
- "Rscript -e \"pkgbuild::compile_dll()\""
- "Rscript -e \"roxygen2::roxygenize('.', roclets=c('rd', 'collate', 'namespace'))\""
- "R CMD build . --resave-data --compact-vignettes=both"
- "R CMD check --as-cran $(ls -rt landsepi_* |tail -1)"
artifacts:
paths:
- "$(ls -rt landsepi_*.tar.gz |tail -1)"
r-windows-test:
stage: test
release-r:
stage: packages
tags:
- "win10"
- "R"
- "binaries"
- "r-base-biosp"
script:
- "R CMD check --as-cran $(ls -rt landsepi_* |tail -1)"
dependencies:
- r-windows-build
- "echo \"Nothing to do\""
artifacts:
paths:
- "$(ls -rt landsepi_*.tar.gz |tail -1)"
- "$(ls -rt landsepi_* |tail -1)"
rules:
- if: $CI_COMMIT_TAG != null
dependencies:
- r-build_test
release-win:
stage: packages
......@@ -109,37 +85,75 @@ release-win:
artifacts:
paths:
- "$(ls -rt landsepi_*.zip |tail -1)"
only:
- tags
rules:
- if: $CI_COMMIT_TAG != null
dependencies:
- r-windows-test
- r-windows-build_test
release-package:
release-winR4:
stage: packages
tags:
- "r-base-biosp"
- "win10"
- "R4"
script:
- "R CMD build . --resave-data"
- "R CMD INSTALL --build --force-biarch $(ls -rt landsepi_*.tar.gz |tail -1)"
artifacts:
paths:
- "$(ls -rt landsepi_* |tail -1)"
only:
- tags
- "$(ls -rt landsepi_*.zip |tail -1)"
rules:
- if: $CI_COMMIT_TAG != null
dependencies:
- r-test
- r-windows-build_test
release-Mac:
stage: packages
tags:
- "Mac"
- "R"
- "R4"
script:
- "R CMD INSTALL --build $(ls -rt landsepi_*.tar.gz |tail -1)"
artifacts:
paths:
- "$(ls -rt landsepi_*.tgz | tail -1)"
only:
- tags
rules:
- if: $CI_COMMIT_TAG != null
dependencies:
- r-Mac-test
- r-Mac-build_test
buildDocker:
tags:
- "dind"
- "docker"
variables:
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
services:
- docker:19.03.0-dind
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
stage: build_img
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE:latest -f inst/shiny-landsepi/Dockerfile .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE:latest
after_script:
- docker logout $CI_REGISTRY
rules:
- if: $CI_COMMIT_BRANCH == "master"
deploy:
image: debian
stage: deploy
environment:
name: shinyproxy
url: https://shiny.biosp.inrae.fr/
rules:
- if: $CI_COMMIT_BRANCH == "master"
before_script:
- apt-get update && apt-get install -y sshpass openssh-client
- export SSHPASS=$DEPLOY_PWD
script:
- sshpass -e ssh -o StrictHostKeyChecking=no $DEPLOY_USER@$DEPLOY_IP "./launch.sh $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD $CI_REGISTRY_IMAGE latest"
......@@ -2,20 +2,24 @@ Package: landsepi
Type: Package
Encoding: UTF-8
Title: Landscape Epidemiology and Evolution
Version: 0.0.8
Date: 2019-10-04
Authors@R: c(person("Loup", "Rimbaud", role = "aut", email = "loup.rimbaud@inra.fr"),
person("Julien", "Papaix", role = "aut", email = "julien.papaix@inra.fr"),
person("Jean-Francois", "Rey", role = "cre", email = "jean-francois.rey@inra.fr"))
Version: 1.0.0
Date: 2020-07-01
Authors@R: c(person("Loup", "Rimbaud", role = "aut", email = "loup.rimbaud@inrae.fr"),
person("Julien", "Papaix", role = "aut", email = "julien.papaix@inrae.fr"),
person("Jean-Francois", "Rey", role = "cre", email = "jean-francois.rey@inrae.fr"),
person("Jean-Loup", "Gaussen", role = "ctb", email = "jean-loup-thomas.gaussen@inrae.fr"))
Author: Loup Rimbaud [aut],
Julien Papaix [aut],
Jean-Francois Rey [cre]
Maintainer: Jean-Francois Rey <jean-francois.rey@inra.fr>
Description: A spatio-temporal stochastic model to assess resistance deployment strategies
against plant pathogens. The model is based on stochastic geometry for describing the
landscape and the resistant hosts, a dispersal kernel for the dissemination of the
pathogen, and a SEIR (Susceptible-Exposed-Infectious-Removed) architecture to simulate
plant response to disease.
Jean-Francois Rey [cre],
Jean-Loup Gaussen [ctb]
Maintainer: Jean-Francois Rey <jean-francois.rey@inrae.fr>
Description: A stochastic, spatially-explicit, demo-genetic model simulating the spread and evolution
of a plant pathogen in a heterogeneous landscape to assess resistance deployment strategies.
It is based on a spatial geometry for describing the landscape and allocation of different cultivars,
a dispersal kernel for the dissemination of the pathogen, and a SEIR
('Susceptible-Exposed-Infectious-Removed’) structure with a discrete time step.
It provides a useful tool to assess the performance of a wide range of deployment options with
respect to their epidemiological, evolutionary and economic outcomes.
Loup Rimbaud, Julien Papaïx, Jean-François Rey, Luke G Barrett,
Peter H Thrall (2018) <doi:10.1371/journal.pcbi.1006067>.
URL: https://gitlab.paca.inra.fr/CSIRO-INRA/landsepi
......@@ -25,37 +29,50 @@ LazyData: true
BuildVignettes: true
NeedsCompilation: yes
Biarch: true
SystemRequirements: C++11, gsl, gdal >= 1.11.0
SystemRequirements: C++11, gsl
Depends:
methods,
utils,
grDevices (>= 3.0.0),
graphics (>= 3.0.0),
R (>= 3.3.0),
Rcpp (>= 0.9.0),
rgdal (>= 1.2-16)
Imports:
sp (>= 1.0-17),
Imports:
Rcpp (>= 0.9.0),
stats (>= 3.0.2),
Matrix,
MASS,
rgeos,
maptools,
mvtnorm,
fields,
splancs,
sf
sf,
DBI,
RSQLite,
foreach,
parallel,
doParallel
Collate:
'invlogit.R'
'logit.R'
'Math-Functions.R'
'RcppExports.R'
'graphLand.R'
'periodic_cov.R'
'multiN.R'
'graphics.R'
'AgriLand.R'
'HLIRdynamics.R'
'Class-LandsepiParams.R'
'GPKGTools.R'
'tools.R'
'Methods-LandsepiParams.R'
'catch-routine-registration.R'
'demo_landsepi.R'
'landsepi.R'
'plotevolQR.R'
'output.R'
'runShiny.R'
'simul_landsepi.R'
LinkingTo: Rcpp
RoxygenNote: 6.1.1
LinkingTo: Rcpp, testthat
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.0
Suggests:
testthat,
shiny,
shinyjs,
DT,
knitr,
rmarkdown
VignetteBuilder: knitr
# Generated by roxygen2: do not edit by hand
export(AgriLand)
export(HLIRdynamics)
export(allocateCroptypeCultivars)
export(allocateCultivarGenes)
export(allocateLandscapeCroptypes)
export(checkSimulParams)
export(createSimulParams)
export(demo_landsepi)
export(epid_output)
export(evol_output)
export(getGPKGArea)
export(getGPKGRotation)
export(invlogit)
export(is.in.01)
export(is.positive)
export(is.strict.positive)
export(is.wholenumber)
export(loadCroptypes)
export(loadCultivar)
export(loadDispersalHost)
export(loadDispersalPathogen)
export(loadGene)
export(loadLandscape)
export(loadOutputs)
export(loadPathogen)
export(loadSimulParams)
export(logit)
export(model_landsepi)
export(multiN)
export(periodic_cov)
export(plotevolQR)
export(plot_allocation)
export(plot_freqPatho)
export(plotland)
export(runShinyApp)
export(runSimul)
export(saveDeploymentStrategy)
export(setCroptypes)
export(setCultivars)
export(setDispersalHost)
export(setDispersalPathogen)
export(setGenes)
export(setInoculum)
export(setLandscape)
export(setOutputs)
export(setPathogen)
export(setSeed)
export(setSeedValue)
export(setTime)
export(simul_landsepi)
import(MASS)
export(switch_patho_to_aggr)
export(video)
exportClasses(LandsepiParams)
exportMethods(print)
exportMethods(show)
exportMethods(summary)
import(DBI)
import(RSQLite)
import(Rcpp)
import(fields)
import(graphics)
import(maptools)
import(methods)
import(rgdal)
import(rgeos)
import(sf)
import(sp)
import(splancs)
import(stats)
importFrom(Matrix,nearPD)
importFrom(doParallel,registerDoParallel)
importFrom(foreach,"%dopar%")
importFrom(foreach,foreach)
importFrom(grDevices,colorRampPalette)
importFrom(grDevices,dev.off)
importFrom(grDevices,graphics.off)
importFrom(grDevices,gray)
importFrom(grDevices,png)
importFrom(grDevices,tiff)
importFrom(mvtnorm,rmvnorm)
importFrom(parallel,detectCores)
importFrom(sf,st_as_sf)
importFrom(sf,st_read)
importFrom(sf,st_write)
importFrom(splancs,polymap)
importFrom(utils,data)
importFrom(utils,installed.packages)
importFrom(utils,write.table)
useDynLib(landsepi)
useDynLib(landsepi, .registration = TRUE)
This diff is collapsed.
# Part of the landsepi R package.
# Copyright (C) 2017 Loup Rimbaud <loup.rimbaud@inrae.fr>
# Julien Papaix <julien.papaix@inrae.fr>
# Jean-François Rey <jean-francois.rey@inrae.fr>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,i
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#' @title Class LandsepiParams
#' @name LandsepiParams
#' @description Landsepi simulation parameters
#' @details An object of class LandsepiParams that can be created by calling \code{\link{createSimulParams}}
#' @aliases LandsepiParams-class
#'
#' @slot Landscape a landscape as sf object.See \code{\link{loadLandscape}}, \code{\link{loadLandscape}}
#' @slot Croptypes a dataframe with three columns named 'croptypeID' for croptype index,
#' 'cultivarID' for cultivar index and 'proportion' for the proportion of the cultivar within the croptype.
#' See \code{\link{loadCroptypes}}, \code{\link{setCroptypes}} and See \code{\link{allocateCroptypeCultivars}}
#' @slot Cultivars a dataframe of parameters associated with each host genotype (i.e. cultivars, lines)
#' when cultivated in pure crops.See \code{\link{loadCultivar}} and \code{\link{setCultivars}}
#' @slot CultivarsGenes a list containing, for each host genotype, the indices of carried resistance genes.
#' See \code{\link{allocateCultivarGenes}}
#' @slot Genes a data.frame of parameters associated with each resistance gene and with the evolution of
#' each corresponding pathogenicity gene. See \code{\link{loadGene}} and \code{\link{setGenes}}
#' @slot Pathogen a list of pathogen aggressiveness parameters on a susceptible host
#' for a pathogen genotype not adapted to resistance. See \code{\link{loadPathogen}} and \code{\link{setPathogen}}
#' @slot PI0 initial probability for the first host (whose index is 0) to be infectious (i.e. state I)
#' at the beginning of the simulation. Must be between 0 and 1. See \code{\link{setInoculum}}
#' @slot DispHost a vectorized matrix giving the probability of host dispersal
#' from any field of the landscape to any other field. See \code{\link{loadDispersalHost}} and \code{\link{setDispersalHost}}
#' @slot DispPatho a vectorized matrix giving the probability of pathogen dispersal
#' from any field of the landscape to any other field. See \code{\link{loadDispersalPathogen}} and \code{\link{setDispersalPathogen}}
#' @slot OutputDir the directory for simulation outputs
#' @slot OutputGPKG the name of the output GPKG file containing parameters of the deployment strategy
#' @slot Outputs a list of outputs parameters. See \code{\link{setOutputs}}
#' @slot TimeParam a list of time parameters. See \code{\link{setTime}}
#' @slot Seed an integer used as seed value (for random number generator). See \code{\link{setTime}}
#' @import sf
#' @exportClass LandsepiParams
setClass(
Class = "LandsepiParams",
slots = list(
Landscape = "sf",
Croptypes = "data.frame",
Cultivars = "data.frame",
CultivarsGenes = "data.frame",
Genes = "data.frame",
Pathogen = "list",
PI0 = "numeric",
DispHost = "vector",
DispPatho = "vector",
OutputDir = "character",
OutputGPKG = "character",
Outputs = "list",
TimeParam = "list", # Nyear Nstep
Seed = "numeric"
)
)
setValidity("LandsepiParams", function(object) {
if (is.null(object@OutputDir) || length(object@OutputDir) == 0) { # check is valid dir .dir.file
"Need an output directory"
} else {
TRUE
}
})
# Part of the landsepi R package.
# Copyright (C) 2017 Loup Rimbaud <loup.rimbaud@inrae.fr>
# Julien Papaix <julien.papaix@inrae.fr>
# Jean-François Rey <jean-francois.rey@inrae.fr>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,i
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
### GPKG manipulation ###
#' @title createLandscapeGPKG
#' @description Creates a GPKG file from a sf object
#' @details Generates a GPKG file with two layouts.
#' One layout called "croptypeID" containing the croptypes ID for every year.
#' One another layout called "area" containing the area of every polygon.
#' @param landscape a sf object
#' @param outputfile GPKG output file name
#' @return the outputfile name (full path)
createLandscapeGPKG <- function(landscape, outputfile) {
# create and save landscape in layer croptypeID (year_XX croptype ID)
st_write(
landscape,
outputfile,
"croptypeID",
layer_options = "OVERWRITE=yes",
driver = "GPKG",
quiet = TRUE
)
# Get polygons area
area <- data.frame(area = st_area(landscape))
# save polygons area in a layer area
st_write(
st_sf(st_geometry(landscape), "area" = area),
outputfile,
"area",
layer_options = "OVERWRITE=yes",
driver = "GPKG",
quiet = TRUE
)
return(outputfile)
}
#' getGPKGArea
#' @description Gets "area" layer as a vector of a GPKG file
#' @param gpkgfile a GPKG file
#' @return a vector of the area of each polygons
#' @export
getGPKGArea <- function(gpkgfile) {
area <- st_read(
gpkgfile,
"area"
)
st_geometry(area) <- NULL
areadf <- as.data.frame(area)
return(as.vector(areadf[, 1]))
}
#' getGPKGRotation
#' @description Gets Croptypes ID rotation years as a matrix
#' @param gpkgfile a GPKG file
#' @return a matrix as rows for polygons and cols for years
#' @export
getGPKGRotation <- function(gpkgfile) {
croptypeID <- st_read(
gpkgfile,
"CroptypeID"
)
st_geometry(croptypeID) <- NULL
cdf <- as.data.frame(croptypeID)
ncol <- length(grep("^year_", colnames(cdf)) %in% colnames(cdf))
# nrow <- nrow(cdf)
croptype_matrix <- as.matrix(cdf[, grep("^year_", colnames(cdf))], ncol = ncol)
return(croptype_matrix)
}