Commit 8457a6d4 authored by Jean-Francois Rey's avatar Jean-Francois Rey
Browse files

Merge OO to master

Jean-Loup work
parent c96419a0
......@@ -11,3 +11,13 @@
^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
......@@ -12,5 +12,10 @@ config\.log
config\.status
landsepiDev*
.Rproj.user
simul_landsepi_*
nbproject/
src/doxygen-config
\.vscode/
stages:
- build_test
- packages
- build_img
- deploy
r-build_test:
stage: build_test
......@@ -27,6 +29,7 @@ r-devel-build_test:
artifacts:
paths:
- "$(ls -rt landsepiDev_*.tar.gz |tail -1)"
allow_failure: true
r-Mac-build_test:
stage: build_test
......@@ -102,3 +105,40 @@ release-Mac:
dependencies:
- 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
only:
- OO
deploy:
image: debian
stage: deploy
environment:
name: shinyproxy
url: https://shiny.biosp.inra.fr/
only:
- OO
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,8 +2,8 @@ Package: landsepiDev
Type: Package
Encoding: UTF-8
Title: Landscape Epidemiology and Evolution
Version: 0.0.8
Date: 2018-11-27
Version: 0.1.0
Date: 2019-10-16
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"))
......@@ -38,12 +38,16 @@ Imports:
sp (>= 1.0-17),
stats (>= 3.0.2),
Matrix,
MASS,
mvtnorm,
rgeos,
maptools,
fields,
splancs,
sf
sf,
RSQLite,
foreach,
parallel,
doParallel
Collate:
'invlogit.R'
'logit.R'
......@@ -52,13 +56,18 @@ Collate:
'periodic_cov.R'
'multiN.R'
'AgriLand.R'
'HLIRdynamics.R'
'catch-routine-registration.R'
'demo_landsepi.R'
'durability.R'
'landsepi.R'
'output.R'
'plotevolQR.R'
'runShiny.R'
'simul_landsepi.R'
LinkingTo: Rcpp, testthat
RoxygenNote: 6.1.1
Suggests:
testthat
testthat,
shiny,
shinyjs,
DT
# Generated by roxygen2: do not edit by hand
export(AgriLand)
export(HLIRdynamics)
export(AgriLand_old)
export(demo_landsepi)
export(epid_output)
export(evol_output)
export(invlogit)
export(logit)
export(model_landsepi)
export(multiN)
export(periodic_cov)
export(plotevolQR)
export(plotSimul)
export(plot_freqPatho)
export(plotland)
export(runShinyApp)
export(simul_landsepi)
import(MASS)
export(switch_patho_to_aggr)
export(video)
import(Rcpp)
import(doParallel)
import(fields)
import(graphics)
import(maptools)
import(methods)
import(parallel)
import(rgdal)
import(rgeos)
import(sp)
import(splancs)
import(stats)
importFrom(Matrix,nearPD)
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(sf,st_as_sf)
importFrom(sf,st_read)
importFrom(sf,st_write)
......
This diff is collapsed.
This diff is collapsed.
......@@ -3,59 +3,65 @@
#' @title Model Landscape Epidemiology & Evolution
#' @name model_landsepi
#' @description Stochastic, spatially-explicit, demo-genetic model simulating the spread and evolution of a pathogen in a heterogeneous landscape.
#' @param timeP list of simulation parameters (number of years, number of time-steps per year)
#' @description Stochastic, spatially-explicit, demo-genetic model simulating the spread and evolution of a pathogen
#' in a heterogeneous landscape.
#' @param time_param list of simulation parameters (number of years, number of time-steps per year)
#' @param landscape landscape generated through AgriLand
#' @param dispersal list of dispersal parameters (vectorised dispersal matrix of the pathogen, vectorised dispersal matrix of the host)
#' @param dispersal list of dispersal parameters (vectorised dispersal matrix of the pathogen, vectorised dispersal
#' matrix of the host)
#' @param inits list initial conditions (initial probability of infection by the pathogen)
#' @param val_seed seed (for random number generation)
#' @param hostP list of host parameters (number of cultivars, initial planting density, maximal carrying capacity, growth rate, reproduction rate, death rate, resistance formula,
#' parameters of the sigmoid invasion function: kappa, sigma and s)
#' @param pathoP list of pathogen parameters (probability to survive the off-season, probability to reproduce via sex rather than via cloning,
#' infection rate, reproduction rate, average latent period duration, variance of the latent period, average infectious period duration
#' , variance of the infectious period duration, parameters of the sigmoid contamination function: kappa, sigma, s)
#' @param evolP list of evolution parameters (cost of infectivity, cost of aggressiveness, mutation rate, efficiency of major
#' resistance genes, efficiency of quantitative resistance, trade-off strength, number of increments of quantitative
#' resistance erosion, average time to expression of quantitative resistance, Variance of the time to expression of quantitative resistance,
#' adaptation formula)
#' @param seed seed (for random number generation)
#' @param cultivars_param list of host parameters (number of cultivars, initial planting density, maximal carrying
#' capacity, growth rate, reproduction rate, death rate, resistance formula, parameters of the sigmoid invasion
#' function: kappa, sigma and s)
#' @param basic_patho_param list of pathogen parameters (probability to survive the
#' off-season, probability to reproduce via sex rather than via cloning, infection rate, reproduction rate, average
#' latent period duration, variance of the latent period, average infectious period duration, variance of the
#' infectious period duration, parameters of the sigmoid contamination function: kappa, sigma, s)
#' @param genes_param list of evolution parameters (cost of infectivity, cost of aggressiveness, mutation rate,
#' efficiency of major resistance genes, efficiency of quantitative resistance, trade-off strength, number of
#' increments of quantitative resistance erosion, average time to expression of quantitative resistance, Variance of
#' the time to expression of quantitative resistance, adaptation formula)
#' @details \itemize{
#' \item The model is stochastic, spatially explicit (the basic spatial unit is an individual field), based on a SEIR
#' (‘susceptible-exposed-infectious-removed’) structure with a discrete time step. It simulates the spread and evolution
#' of a pathogen in an agricultural landscape, across cropping seasons split by host harvests which impose potential bottlenecks
#' to the pathogen.
#' \item A wide array of deployment strategies can be simulated: mosaics, mixtures, rotations and pyramiding of multiple
#' major resistance genes which affect pathogen infectivity, and up to four quantitative resistance traits.
#' These traits target different aggressiveness components of the pathogen, i.e. the infection rate, the duration of the latent
#' period and the infectious period, and the propagule production rate. Quantitative resistance may be expressed from the time of planting,
#' or later in the cropping season (Adult Plant Resistance or Mature Plant Resistance).
#' \item The genotype of cultivated plant cultivars is specified using
#' the "resistance formulas", i.e. a vector of size 8. the four first elements indicate whether the cultivar carries major resistance
#' genes #1, #2, #3 and #4, respectively. The following four elements indicate whether the cultivar carried a quantitative resistance
#' trait against the infection rate, the latent period duration, the sporulation rate, or the sporulation duration of the pathogen, respectively.
#' For example, the formula c(1,0,0,0,0,1,0,0) indicates the presence of major gene #1 and a quantitative resistance
#' which increases the duration of the latent period of the pathogen.
#' \item Initially, the pathogen is not adapted to any source of
#' resistance, and is only present on susceptible hosts. However, through mutation, it can evolve and may acquire infectivity
#' genes (which leads to breakdown of major resistance genes) or increase aggressiveness (which leads to the erosion of the
#' relevant quantitative resistance traits). These genes may also be reassorted via sexual reproduction.
#' \item Evolution of a pathogen toward infectivity or increased aggressiveness on
#' a resistant host is often penalised by a fitness cost on susceptible hosts. Consequently, in the present model, pathogens
#' carrying infectivity genes may have reduced infection rate (cost of infectivity) on susceptible hosts relative
#' to pathogens that do not carry these genes. Similarly, a gain in pathogen aggressiveness on quantitatively resistant hosts
#' is penalised by a decreased aggressiveness on susceptible hosts, leading to a trade-off.
#' }
#' @return A set of binary files is generated for every year of simulation and every compartment: \itemize{
#' \item H: healthy hosts,
#' \item Hjuv: juvenile healthy hosts,
#' \item L: latently infected hosts,
#' \item I: infectious hosts,
#' \item R: removed hosts,
#' \item S: propagules.
#' }
#' Each file indicates for every time-step the number of individuals in each field, and when appropriate for each cultivar and pathotype)
#' @references Rimbaud L., Papaïx J., Rey J.-F., Barrett L. G. and Thrall P. H. (2018). Assessing the durability and efficiency of landscape-based strategies to deploy plant resistance to pathogens. \emph{PLoS Computational Biology} 14(4):e1006067.
#' \item The model is stochastic, spatially explicit (the basic spatial unit is an individual field), based on a SEIR
#' (‘susceptible-exposed-infectious-removed’) structure with a discrete time step. It simulates the spread and
#' evolution of a pathogen in an agricultural landscape, across cropping seasons split by host harvests which impose
#' potential bottlenecks to the pathogen.
#' \item A wide array of deployment strategies can be simulated: mosaics, mixtures, rotations and pyramiding of
#' multiple major resistance genes which affect pathogen infectivity, and up to four quantitative resistance traits.
#' These traits target different aggressiveness components of the pathogen, i.e. the infection rate, the duration of
#' the latent period and the infectious period, and the propagule production rate. Quantitative resistance may be
#' expressed from the time of planting, or later in the cropping season (Adult Plant Resistance or Mature Plant
#' Resistance).
#' \item The genotype of cultivated plant cultivars is specified using the "resistance formulas", i.e. a
#' vector of size 8. the four first elements indicate whether the cultivar carries major resistance genes #1, #2, #3
#' and #4, respectively. The following four elements indicate whether the cultivar carried a quantitative resistance
#' trait against the infection rate, the latent period duration, the propagule production rate, or the infectious
#' period duration of the pathogen, respectively. For example, the formula c(1,0,0,0,0,1,0,0) indicates the presence
#' of major gene #1 and a quantitative resistance which increases the duration of the latent period of the pathogen.
#' \item Initially, the pathogen is not adapted to any source of resistance, and is only present on susceptible hosts.
#' However, through mutation, it can evolve and may acquire infectivity genes (which leads to breakdown of major
#' resistance genes) or increase aggressiveness (which leads to the erosion of the relevant quantitative resistance
#' traits). These genes may also be reassorted via sexual reproduction.
#' \item Evolution of a pathogen toward
#' infectivity or increased aggressiveness on a resistant host is often penalised by a fitness cost on susceptible
#' hosts. Consequently, in the present model, pathogens carrying infectivity genes may have reduced infection rate
#' (cost of infectivity) on susceptible hosts relative to pathogens that do not carry these genes. Similarly, a gain
#' in pathogen aggressiveness on quantitatively resistant hosts is penalised by a decreased aggressiveness on
#' susceptible hosts, leading to a trade-off.}
#' @return A set of binary files is generated for every year of simulation and every compartment: \itemize{
#' \item H: healthy hosts,
#' \item Hjuv: juvenile healthy hosts,
#' \item L: latently infected hosts,
#' \item I: infectious hosts,
#' \item R: removed hosts,
#' \item P: propagules.}
#' Each file indicates for every time-step the number of individuals in each field, and when appropriate for
#' each cultivar and pathotype)@references Rimbaud L., Papaïx J., Rey J.-F., Barrett L. G. and Thrall P. H. (2018).
#' Assessing the durability andefficiency of landscape-based strategies to deploy plant resistance to pathogens.
#' \emph{PLoS Computational Biology} 14(4):e1006067.
#' @export
model_landsepi <- function(timeP, landscape, dispersal, inits, val_seed, hostP, pathoP, evolP) {
invisible(.Call(`_landsepiDev_model_landsepi`, timeP, landscape, dispersal, inits, val_seed, hostP, pathoP, evolP))
model_landsepi <- function(time_param, landscape, dispersal, inits, seed, cultivars_param, basic_patho_param, genes_param) {
invisible(.Call(`_landsepiDev_model_landsepi`, time_param, landscape, dispersal, inits, seed, cultivars_param, basic_patho_param, genes_param))
}
......@@ -7,7 +7,7 @@
# 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
......@@ -23,14 +23,71 @@
#' @name demo_landsepi
#' @description Run a demonstration of the package.
#' @param seed an integer used as seed value (for random number generator)
#' @details Run a 30-year simulated example of mosaic deployment strategy of two resistant cultivars in balanced proportions and
#' high level of spatial aggregation. The generated model outputs are text files, graphics and a video.
#' @include RcppExports.R AgriLand.R graphLand.R multiN.R periodic_cov.R
#' @param strat a character string specifying an example of deployment strategy ("MO"=mosaic, "MI"=mixture, "RO"=rotations, "PY"=pyramiding).
#' @param Nyears number of years to simulate
#' @details Run a simulated example of deployment strategy of one susceptible cultivar and two resistance sources deployed according to a strategy
#' given by parameter strat. Landscape is generated with high level of spatial aggregation.
#' The generated model outputs are text files, graphics and a video.
#' @include RcppExports.R AgriLand.R graphLand.R multiN.R periodic_cov.R
#' @importFrom utils data
#' @export
demo_landsepi <- function(seed=12345){
demo_landsepi <-
function(seed = 12345,
strat = "MO",
Nyears = 30) {
# set seed for RNG
#if( getRversion >= "3.6.0" ) RNGkind(sample.kind = "Rounding")
set.seed(seed, kind = "Mersenne-Twister", normal.kind = "Inversion")
## Creation of repository for results
pathRES_init <- getwd()
timeSimul <-
paste(strsplit(as.character(Sys.time()), " ")[[1]], collapse = "_")
nameDir <- paste("simul_landsepi_", timeSimul, sep = "")
nameDir <- gsub(":", "-", nameDir)
dir.create(nameDir)
setwd(nameDir)
pathRES <- getwd()
simul_landsepi(seed, nYears=30, idLan=1, propSR=2/3, isolSR=3, propRR=1/2, isolRR=3, strat="MO", Nhost=3
, resistance1=c(1,0,0,0,0,0,0,0), resistance2=c(0,1,0,0,0,0,0,0), taumut=1e-7
, graphic=TRUE, video=TRUE)
}
landscape_boundaries <- get("landscapeTEST1")
dispP <- get("dispP_1")
rotation_sequence <- list(c(0, 1))
prop <- list(c(1 / 2, 1 / 2))
rotation_period <- 0
if (strat == "MO") {
rotation_sequence <- list(c(0, 1, 2))
prop <- list(c(1 / 3, 1 / 3, 1 / 3))
}
if (strat == "RO") {
rotation_sequence <- list(c(0, 1), c(0, 2))
rotation_period <- 2
}
## Generate the landscape (landscape.gpkg)
landscape <- AgriLand(
landscape = landscape_boundaries,
Nyears = Nyears,
rotation_period = rotation_period,
rotation_sequence = rotation_sequence,
rotation_realloc = FALSE,
prop = prop,
aggreg = list(3),
graphic = TRUE
)
## Run the simulation
simul_landsepi(
seed = seed,
Nyears = Nyears,
landscape = landscape,
dbPath = system.file(paste("demo_", strat, "_data.sqlite", sep = ''), package = "landsepiDev"),
dispP = dispP,
graphic = TRUE,
video = TRUE
)
## Set back the path to the initial repository
setwd(pathRES_init)
}
# Part of the landsepi R package.
# Copyright (C) 2017 Loup Rimbaud <loup.rimbaud@inra.fr>
# Julien Papaix <julien.papaix@inra.fr>
# Jean-François Rey <jean-francois.rey@inra.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.
#
## TODO: function durability
durability <- function () {}
\ No newline at end of file
......@@ -7,7 +7,7 @@
# 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
......@@ -23,7 +23,7 @@
#' @title Plotting the landscape
#' @name plotland
#' @description Plot a landscape with colors or hatched lines to represent different types of fields
#' @param landscape a spatialpolygon object containing field coordinates
#' @param landscape a spatialpolygon object containing field coordinates
#' @param COL vector containing the color of each field
#' @param DENS vector containing the density of hatched lines for each field
#' @param ANGLE vector containing the angle of hatched lines for each field
......@@ -41,31 +41,38 @@
#' \dontrun{
#' ## Draw a landscape with various colours
#' landscapeTEST1
#' plotland(landscapeTEST1, COL=1:length(landscapeTEST1),
#' DENS=rep(0,length(landscapeTEST1)), ANGLE=rep(30,length(landscapeTEST1)))
#' plotland(landscapeTEST1,
#' COL = 1:length(landscapeTEST1),
#' DENS = rep(0, length(landscapeTEST1)), ANGLE = rep(30, length(landscapeTEST1))
#' )
#' }
#' @include RcppExports.R logit.R invlogit.R
# @S3method plot land
#' @export
plotland <- function(landscape, COL=rep(0,length(landscape)), DENS=rep(0,length(landscape)), ANGLE=rep(30,length(landscape))
, COL.LEG=unique(COL), DENS.LEG=unique(DENS), ANGLE.LEG=unique(ANGLE)
, TITLE="", SUBTITLE="", LEGEND1=rep("", length(COL.LEG)), LEGEND2=rep("", length(COL.LEG)), TITLE.LEG2="", XMAX=2000, YMAX=2000) {
par(cex=2, xpd=NA, bg="white", mar=c(5,4,4,2))
nPoly <- length(landscape)
plot(0,0, xlim=c(0,XMAX), ylim=c(0,YMAX), xaxt="n", yaxt="n", xlab="", ylab="", bty="n", type="n", main=TITLE) # Empty graph
mtext(SUBTITLE[1], side=3, line=0, padj=-.5, las=1, cex=1.4)
if (length(SUBTITLE)>1)
mtext(SUBTITLE[2], side=3, line=0, padj=1.5, las=1, cex=1.4)
for (i in 1:nPoly) {
polymap(landscape@polygons[[i]]@Polygons[[1]]@coords, add=TRUE, col=COL[i], border="black", lwd=2.5)
polymap(landscape@polygons[[i]]@Polygons[[1]]@coords, add=TRUE, col="black", density=DENS[i], angle=ANGLE[i], border=NA)
}
if (LEGEND1[1]!=""){
if (TITLE.LEG2=="")
legend(XMAX/2.66, -YMAX/40, legend=LEGEND1, fill=COL.LEG, bty="n")
else {
legend(XMAX/2.66, -YMAX/40, legend=LEGEND1, col="black", density=2*DENS.LEG, angle=ANGLE.LEG, bty="n")
legend(-XMAX/5, YMAX, legend=LEGEND2, fill=COL.LEG, bty="n", title=TITLE.LEG2)
}
}
plotland <- function(landscape, COL = rep(0, length(landscape)), DENS = rep(0, length(landscape)),
ANGLE = rep(30, length(landscape)), COL.LEG = unique(COL), DENS.LEG = unique(DENS),
ANGLE.LEG = unique(ANGLE), TITLE = "", SUBTITLE = "", LEGEND1 = rep("", length(COL.LEG)),
LEGEND2 = rep("", length(COL.LEG)), TITLE.LEG2 = "", XMAX = 2000, YMAX = 2000) {
par(cex = 2, xpd = NA, bg = "white", mar = c(5, 4, 4, 2))
nPoly <- length(landscape)
plot(0, 0, xlim = c(0, XMAX), ylim = c(0, YMAX), xaxt = "n", yaxt = "n", xlab = "", ylab = "", bty = "n", type = "n",
main = TITLE) # Empty graph
mtext(SUBTITLE[1], side = 3, line = 0, padj = -.5, las = 1, cex = 1.4)
if (length(SUBTITLE) > 1) {
mtext(SUBTITLE[2], side = 3, line = 0, padj = 1.5, las = 1, cex = 1.4)
}
for (i in 1:nPoly) {
polymap(landscape@polygons[[i]]@Polygons[[1]]@coords, add = TRUE, col = COL[i], border = "black", lwd = 2.5)
polymap(landscape@polygons[[i]]@Polygons[[1]]@coords, add = TRUE, col = "black", density = DENS[i],
angle = ANGLE[i], border = NA)
}
if (LEGEND1[1] != "") {
if (TITLE.LEG2 == "") {
legend(XMAX / 2.66, -YMAX / 40, legend = LEGEND1, fill = COL.LEG, bty = "n")
} else {
legend(XMAX / 2.66, -YMAX / 40, legend = LEGEND1, col = "black", density = 2 * DENS.LEG, angle = ANGLE.LEG,
bty = "n")
legend(-XMAX / 5, YMAX, legend = LEGEND2, fill = COL.LEG, bty = "n", title = TITLE.LEG2)
}
}
}
......@@ -7,7 +7,7 @@
# 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
......@@ -21,11 +21,13 @@
#' @title Inverse logit function
#' @name invlogit
#' @description Given a numeric object return the invlogit of the values. Missing values (NAs) are allowed.
#' @description Given a numeric object return the invlogit of the values. Missing values (NAs) are allowed.
#' @param x a numeric object
#' @details The invlogit is defined by exp(x) / (1+exp(x)). Values in x of -Inf or Inf return invlogits of 0 or 1 respectively. Any NAs in the input will also be NAs in the output.
#' @details The invlogit is defined by exp(x) / (1+exp(x)). Values in x of -Inf or Inf return invlogits of 0 or 1 respectively. Any NAs in the input will also be NAs in the output.
#' @return An object of the same type as x containing the invlogits of the input values.
#' @examples
#' invlogit(10)
#' @export
invlogit <- function(x) exp(x) / (1+exp(x))
invlogit <- function(x) {
exp(x) / (1 + exp(x))
}
......@@ -7,7 +7,7 @@
# 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
......@@ -22,79 +22,79 @@
#' @title Landscape Epidemiology and Evolution
#' @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)
#' a dispersal kernel for the dissemination of the pathogen, and a SEIR (Susceptible-Exposed-Infectious-Removed)
#' architecture to simulate plant response to disease.
#' @aliases landsepi-package landsepi
#'
#'
#' @author Loup Rimbaud \email{loup.rimbaud@@inra.fr}
#' @author Julien Papaix \email{julien.papaix@@inra.fr}
#' @author Jean-Francois Rey \email{jean-francois.rey@@inra.fr}
#'
#'
#' Maintainer: Jean-Francois Rey \email{jean-francois.rey@@inra.fr}
#' @docType package
#' @name landsepi-package
#' @details \tabular{ll}{
#' Package: \tab landsepi\cr
#' Type: \tab Package\cr
#' Version: \tab 0.0.8\cr
#' Date: \tab 2018-11-27\cr
#' Version: \tab 0.1.0\cr
#' Date: \tab 2018-10-16\cr
#' License: \tab GPL (>=2)\cr
#' }
#'
#' The landsepi package implements a spatially explicit stochastic model able to assess the epidemiological and evolutionary outcomes of four major strategies
#' to deploy plant resistance to pathogens. These strategies include the combination of several resistance sources across time (crop rotations) or space.
#' The spatial scale of deployment can vary from multiple resistance sources occurring in a single cultivar (pyramiding),
#' in different cultivars within the same field (cultivar mixtures) or in different fields (mosaics). The simulated sources of resistance can
#' consist of qualitative resistance (i.e. major genes) or quantitative resistance traits (including Adult Plant Resistant genes) against several components of pathogen aggressiveness:
#' infection rate, latent period duration, propagule production rate, and infectious period duration. This model provides a useful tool to assess
#' the performance of a wide range of deployment options, and helps investigate the effect of landscape, epidemiological and evolutionary parameters
#' on the performance of a given strategy.
#'
#' The simulation model is based on a SEIR (Susceptible-Exposed-Infectious-Removed) architecture to describe host response to disease. The lansdcape is
#' represented by a set of polygons where the pathogen can disperse. Initially, the pathogen is not adapted to any source of resistance, and is only
#' present on susceptible hosts. However, through mutation, it can evolve and may acquire infectivity genes (which leads to breakdown of major resistance genes)
#' or increase aggressiveness (which leads to the erosion of the relevant quantitative resistance traits). Furthermore, loci may be re-assorted via sexual reproduction.
#' However, evolution of a pathogen toward infectivity or increased aggressiveness on a resistant host may be penalised
#' by a fitness cost on susceptible hosts. Consequently, pathogens carrying infectivity genes may have reduced infection rate (cost of infectivity) on susceptible
#' hosts relative to pathogens that do not carry these genes. Similarly, a gain in pathogen aggressiveness on quantitatively resistant hosts is penalised by a
#' The spatial scale of deployment can vary from multiple resistance sources occurring in a single cultivar (pyramiding),
#' in different cultivars within the same field (cultivar mixtures) or in different fields (mosaics). The simulated sources of resistance can
#' consist of qualitative resistance (i.e. major genes) or quantitative resistance traits (including Adult Plant Resistant genes) against several components of pathogen aggressiveness:
#' infection rate, latent period duration, propagule production rate, and infectious period duration. This model provides a useful tool to assess
#' the performance of a wide range of deployment options, and helps investigate the effect of landscape, epidemiological and evolutionary parameters
#' on the performance of a given strategy.
#'
#' The simulation model is based on a SEIR (Susceptible-Exposed-Infectious-Removed) architecture to describe host response to disease. The lansdcape is
#' represented by a set of polygons where the pathogen can disperse. Initially, the pathogen is not adapted to any source of resistance, and is only
#' present on susceptible hosts. However, through mutation, it can evolve and may acquire infectivity genes (which leads to breakdown of major resistance genes)
#' or increase aggressiveness (which leads to the erosion of the relevant quantitative resistance traits). Furthermore, loci may be re-assorted via sexual reproduction.
#' However, evolution of a pathogen toward infectivity or increased aggressiveness on a resistant host may be penalised
#' by a fitness cost on susceptible hosts. Consequently, pathogens carrying infectivity genes may have reduced infection rate (cost of infectivity) on susceptible
#' hosts relative to pathogens that do not carry these genes. Similarly, a gain in pathogen aggressiveness on quantitatively resistant hosts is penalised by a
#' decreased aggressiveness on susceptible hosts, leading to a trade-off.
#'
#'
#' The evolutionary outcome of a deployment strategy is assessed by measuring the time until the pathogen reaches the three steps to adapt to plant resistance: \itemize{
#' \item (d1) first appearance of adapted mutants,
#' \item (d2) initial migration to resistant hosts and infection, and
#' \item (d1) first appearance of adapted mutants,
#' \item (d2) initial migration to resistant hosts and infection, and
#' \item (d3) broader establishment in the resistant host population (i.e. the point at which extinction becomes unlikely). }
#' Epidemiological outcomes are evaluated using: \itemize{
#' \item (e1) the Green Leaf Area (GLA) as a proxy for yield, and
#' \item (e1) the Green Leaf Area (GLA) as a proxy for yield, and
#' \item (e2) the area under the disease progress curve (AUDPC) to measure disease severity.}
#'
#' The package includes five examples of landscape structures and a default parameterisation to represent plant pathogens as typified by rusts of cereal crops
#' (genus \emph{Puccinia}, e.g. stripe rust, stem rust and leaf rust of wheat and barley). The main function of the package is \code{simul_landsepi()}.
#'
#' The package includes five examples of landscape structures and a default parameterisation to represent plant pathogens as typified by rusts of cereal crops
#' (genus \emph{Puccinia}, e.g. stripe rust, stem rust and leaf rust of wheat and barley). The main function of the package is \code{simul_landsepi()}.
#' It can be parameterised to simulate various resistance deployment strategies using the provided landscapes and parameters for cereal rusts.
#'
#'
#' A set of graphics and a video showing epidemic maps can also be generated.
#'
#'
#' \strong{Future versions:}
#'
#'
#' Future versions of the package will include in particular:\itemize{
#' \item A more flexible parameterisation of pathogen life-history traits, in order to simulate other plant pathogens.
#' \item A more flexible parameterisation of deployment strategies, in order to simulate complex strategies combining several options (e.g. mosaic