#' @description Generate a landscape composed of fields where a susceptible (SC) and one (RC) or two (RC1 and RC2) resistant cultivars

#' are allocated with controlled proportions and spatio-temporal aggregation

#' @param landscape a spatialpolygon object containing field coordinates

#' @param filename output layer name

#' @param propSR proportion of fields where resistance is deployed: (RC)/(SC+RC) or (RC1+RC2)/(SC+RC1+RC2)

#' @param isolSR spatial aggregation of fields where resistance is deployed (1=highly fragmented, 2=balanced, 3=highly aggregated)

#' @param propRR when applicable (mixtures and mosaics only), relative proportion of the second resistant cultivar: (RC2)/(RC1+RC2)

#' @param isolRR when applicable, spatial (for mosaics) or temporal (for rotations) aggregation of fields cultivated with the second resistant cultivar (1=highly fragmented, 2=balanced, 3=highly aggregated)

#' @param Cmax0 carrying capacity of the susceptible cultivar

#' @param Cmax1 carrying capacity of the resistant cultivars

#' @param seed seed value (for random number generator)

#' @param graphOn if a graph of the landscape must be generated

#' are allocated with controlled proportions and spatio-temporal aggregation.

#' @param landscape a spatialpolygon object containing field coordinates.

#' @param filename a character string specifying the output layer name.

#' @param propSR proportion of fields where resistance is deployed: (RC)/(SC+RC) or (RC1+RC2)/(SC+RC1+RC2). Must be between 0 and 1.

#' @param isolSR an integer giving the spatial aggregation of fields where resistance is deployed (1=highly fragmented, 2=balanced, 3=highly aggregated).

#' @param propRR when applicable (mixtures and mosaics only), relative proportion of the second resistant cultivar: (RC2)/(RC1+RC2). Must be between 0 and 1.

#' @param isolRR when applicable, an integer giving the spatial (for mosaics) or temporal (for rotations) aggregation of fields

#' cultivated with the second resistant cultivar (1=highly fragmented, 2=balanced, 3=highly aggregated).

#' @param strat a character string specifying the deployment strategy ("MO"=mosaic, "MI"=mixture, "RO"=rotations, "PY"=pyramiding).

#' @param Nhote an integer giving the number of cultivars (1, 2 or 3).

#' @param nYears an integer giving the number of simulated years.

#' @param Cmax0 carrying capacity of the susceptible cultivar in number of hosts per meter square.

#' @param Cmax1 carrying capacity of the resistant cultivars in number of hosts per meter square.

#' @param seed an integer giving the seed value (for random number generator).

#' @param graphOn a logical indicating if a graph of the landscape must be generated (1) or not (0).

#' @details An algorithm based on latent Gaussian fields is used to allocate two different crop cultivars across the simulated landscapes

#' (e.g. a susceptible and a resistant cultivar, denoted as SC and RC, respectively). This algorithm allows the control of the proportions

#' of each cultivar in terms of surface coverage, and their level of spatial aggregation. A random vector of values is drawn from a

...

...

@@ -56,6 +57,7 @@

#' \item Pyramiding: all candidate fields are cultivated with RC12, a resistant cultivar carrying both resistance sources.

#' }

#' }

#' @return a shapefile containing the landscape structure (i.e. coordinates of field boundaries) and composition (i.e. cultivars).

#' @description Generate epidemiological and evolutionary outputs from model simulations.

#' @param pathRES path of the repository where outputs will be generated

#' @param graphOn if graphics of the outputs must be generated

#' @param times list of simulation parameters (number of years, number of time-steps per year)

#' @param landscape agricultural landscape generated through AgriLand

#' @param hostP list of host parameters (number of cultivars, growth rate of the susceptible cultivar, reproduction rate of the susceptible cultivar,

#' @param pathRES a character string indicating the path of the repository where outputs will be generated.

#' @param graphOn a logical indicating if graphics of the outputs must be generated (1) or not (0).

#' @param times a list of simulation parameters (number of years, number of time-steps per year).

#' @param landscape a shapefile containing the agricultural landscape (can be generated through function AgriLand).

#' @param hostP a list of host parameters (number of cultivars, growth rate of the susceptible cultivar, reproduction rate of the susceptible cultivar,

#' growth rate of resistant cultivars, reproduction rate of resistant cultivars, death rate, number of possible resistance sources (8)

#' , resistance formula, parameters of the sigmoid invasion function: kappa, sigma and s)

#' @param epiP list of pathogen parameters (probability to survive the off-season, infection rate

#' , resistance formula, parameters of the sigmoid invasion function: kappa, sigma and s).

#' @param epiP a list of pathogen parameters (probability to survive the off-season, 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

#' , variance of the infectious period duration, parameters of the sigmoid contamination function: kappa, sigma, s).

#' @param evolP a 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, adaptation formula)

#' @param th_break threshold (number of infections) above which mutant pathogen are unlikely to go extinct, used to

#' characterise resistance breakdown

#' @param nMapPY number of epidemic maps per year to generate

#' resistance erosion, adaptation formula).

#' @param th_break an integer giving the threshold (number of infections) above which mutant pathogen are unlikely to go extinct, used to

#' characterise resistance breakdown.

#' @param nMapPY an integer specifying the number of epidemic maps per year to generate.

# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

#' @title Package testing (for development)

#' @title Simulation with provided data

#' @name test_landsepi

#' @description RScript for testing.

#' @param seed an integer used as seed value (for random number generator)

#' @param idLan index of landscape (1 to 5)

#' @param propSR proportion of fields where resistance is deployed: (RC)/(SC+RC) or (RC1+RC2)/(SC+RC1+RC2)

#' @param isolSR spatial aggregation of fields where resistance is deployed (1=highly fragmented, 2=balanced, 3=highly aggregated)

#' @param propRR when applicable (mixtures and mosaics only), relative proportion of the second resistant cultivar: (RC2)/(RC1+RC2)

#' @param isolRR when applicable, spatial (for mosaics) or temporal (for rotations) aggregation of fields cultivated with the second resistant cultivar (1=highly fragmented, 2=balanced, 3=highly aggregated)

#' @param resistance1 resistance formula of the 2nd cultivar (binary formula for 8 traits)

#' @param resistance2 resistance formula of the 3rd cultivar (binary formula for 8 traits)

#' @param costInfect cost of infectivity

#' @param costAggr cost of aggressiveness

#' @param taumut mutation probability

#' @param MGeff efficiency of major-gene resistance

#' @param QReff efficiency of quantitative resistance

#' @param beta trade-off strength

#' @param nAggr number of increments to completely adapt to quantitative resistance

#' @param graphOn if graphics must be generated

#' @return A set of text files containing all outputs of the simulations (see details).

#' @description Simulation of the deployment of plant resistance, using landscape structures provided with the package

#' and a parameterisation of the model to represent pathogens as typified by rusts of cereals (e.g. stripe rust, stem rust

#' , and leaf rust of wheat and barley). All parameters are optional. See details for explanations.

#' @param seed an integer used as seed value (for random number generator).

#' @param idLan an integer giving the index of landscape structure (1 to 5).

#' @param propSR proportion of fields where resistance is deployed: (RC)/(SC+RC) or (RC1+RC2)/(SC+RC1+RC2). Must be between 0 and 1.

#' @param isolSR an integer giving the spatial aggregation of fields where resistance is deployed (1=highly fragmented, 2=balanced, 3=highly aggregated).

#' @param propRR when applicable (mixtures and mosaics only), relative proportion of the second resistant cultivar: (RC2)/(RC1+RC2). Must be between 0 and 1.

#' @param isolRR when applicable, an integer specifying the spatial (for mosaics: 1=highly fragmented, 2=balanced, 3=highly aggregated) or

#' temporal (for rotations: 1=every year, 2=every two years, 3=every three years) aggregation of fields cultivated with the second resistant cultivar.

#' @param strat a character string specifying the deployment strategy ("MO"=mosaic, "MI"=mixture, "RO"=rotations, "PY"=pyramiding).

#' @param nHost an integer giving the number of cultivars (1, 2 or 3).

#' @param nYears an integer giving the number of simulated years.

#' @param pI0 initial probability of infection of the susceptible cultivar. Must be between 0 and 1.

#' @param resistance1 a logical vector of size 8 giving the resistance formula of the 2nd cultivar (see details)

#' @param resistance2 when applicable, a logical vector of size 8 giving the resistance formula of the 3rd cultivar (see details)

#' @param costInfect cost of infectivity paid by infective pathogens (i.e. adapted to plant cultivars carrying a major gene) on susceptible hosts. Must be between 0 and 1.

#' @param costAggr cost of aggressiveness paid by fully adapted pathogens (relative to plant cultivars carrying a quantitative resistance trait) on fully susceptible hosts. Must be between 0 and 1.

#' @param taumut mutation probability: probability for a propagule to change its infectivity or its aggressiveness on a resistant cultivar

#' carrying a major gene or a quantitative resistance trait. Must be above 0. If equal to 0, then the pathogen cannot evolve.

#' @param MGeff efficiency of major-gene resistance on the infection rate of non-adapted pathogens. Must be between 0 and 1.

#' @param QReff efficiency of quantitative resistance on the target aggressiveness trait (infection rate, latent period duration,

#' sporulation rate, or sporulation duration) of non-adapted pathogens. Must be between 0 and 1.

#' @param beta trade-off strength for pathogen adaptation to quantitative resistance (<1 for weak, =1 for linear, >1 for strong). Must be above 0.

#' @param nAggr an integer specifying the number of increments to completely adapt to quantitative resistance. Must be greater or equal 2.

#' @param graphOn a logical indicating if graphics must be generated (1) or not (0).

#' @details \describe{

#'

#' \item{Landscape structure}{The landscape structure is the physical structure of the area, defined as the spatial arrangement of fields.}

#'

#' \item{Deployment strategies}{Deployment strategies include the deployment of a susceptible cultivar (SC)

#' and one (RC) or two (RC1 and RC2) resistant cultivars carrying up to four major resistance genes or up to four

#' \item{\emph{Durability of qualitative resistance:}}{

#' For a given major gene, several computations are

#' performed: \itemize{

#' \item (d1) time to first appearance of a pathogen mutant;

#' \item (d2) time to first true infection of a resistant host by such mutants; and

#' \item (d3) time when the number of infections of resistant hosts by these mutants reaches a threshold above which mutant pathogens are unlikely to go extinct.

#' }

#' }

#' \item{\emph{Erosion of quantitative resistance:}}{

#' pathogen adaptation to quantitative resistance is gradual, so the three measures described above are computed for every step

#' towards complete erosion of resistance (i.e. nAgw-1 levels).}

#' \item{\emph{Durability of a deployment strategy:}}{ a simulation run is divided into three periods: \enumerate{

#' \item the initial short-term period when all resistance sources are at their highest potential;

#' \item a transitory period during which a given deployment strategy is only partially effective; and

#' \item a longer-term period when all the resistances have been overcome or completely eroded.

#' }

#' To assess the end of the short-term period, the time to establishment (durability measure (d3)) is computed for every major gene, and every quantitative trait

#' at the first level of erosion (agw(p)=2). The minimal value of these measures, denoted by D1, delimitates short-term and transitory periods.

#' Similarly, the time to establishment is computed for every major gene, and for every quantitative trait at the highest level of erosion (agw(p)=nAgw).

#' The maximal value of these measures, termed D2, delimits transitory and long-term periods.

#' }

#' }

#' }

#' \item{\strong{Epidemiological outputs.}}{

#' The epidemiological impact of pathogen spread is evaluated by two different measures: \enumerate{

#' \item Green Leaf Area (GLA): The GLA represents the average number of productive hosts per time step and per surface unit.

#' \item Area Under Disease Progress Curve (AUDPC): The AUDPC is the average proportion of diseased hosts relative to the carrying capacity and represents disease severity.

#' }

#' \describe{

#' \item{\emph{Global epidemiological control:}}{

#' The GLA and AUDPC of every cultivar as well as the whole landscape are averaged across the whole simulation run,

#' to measure the global epidemiological performance of a deployment strategy.}

read file "DESCRIPTION" for configuration requirements and required library (linux and R)

## Descriptions

---

output:

pdf_document:default

html_document:default

---

# R package landsepi

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 architecture to simulate plant response to disease.

## Authors

* CSIRO [[https://www.csiro.au]]

* INRA [[https://www.inra.fr]]

...

...

@@ -19,14 +19,13 @@ read file "DESCRIPTION" for configuration requirements and required library (lin

* Jean-Francois Rey [[jean-francois.rey@inra.fr]]

## License

The package landsepi is under GNU GPL V2.

See LICENSE file.

## R package

### Dependencies

## Installation

### Configuration and dependencies

Read file "DESCRIPTION" for details on configuration requirements (with linux and R)

The package for compiling needs g++, gsl dev library and gdal dev library >= 2.0.0 .

R CMD INSTALL landsepi_*.*.*.tar.gz --with-keep.source --configure-args="--enable-debug=yes"

```

### Tests

## Package users: Running simulations

No unit test add yet.

You can play the demo:

### Documentation and demonstration

A complete description of the package and its functions is provided in the R documentation.

Open R:

```r

library(landsepi)

??landsepi## select <landsepi::landsepi-package> for a complete description of the package

```

Run a demonstration (a 30-year simulation of a mosaic deployment strategy of two resistant cultivars in balanced proportions and high level of spatial aggregation):

```r

demo_landsepi()

```

### Simulations with data included in the package

The package includes 5 landscape structures and a parameterisation to represent plant pathogens as typified by rusts of cereal crops (e.g. stripe rust, stem rust and leaf rust of wheat and barley). These data can be used to simulate the deployment of plant resistance in an agricultural lansdcape in the context of biotrophic foliar pathogens of cereal crops. The R documentation provides details on all parameters.

```r

## complete description of the parameters

?test_landsepi

## Default parameterisation

test_landsepi()## 5-year simulation of a mosaic deployment strategy of two resistant cultivars in balanced proportions and high level of spatial aggregation

```

#### Strategies combining qualitative and quantitative resistance

Examples of combinations in a 50-year period using landscape #1:

It is possible to use any landscape stored in a shapefile, and parameterise to model to any other pathosystem. For this, users need to use the following functions:

(1) AgriLand: to allocate the different cultivars in the fields of the landscape within a specific spatiotemporal deployment of resistance;

(2) modelLandsEPI: to run the demo-genetic simulation model;

(3) HLIRdynamics: to generate epidemiological and evolutionary outputs.

See R documentation to see how to use these functions.

```r

?AgriLand## Allocation of cultivars in the landscape

\item{landscape}{a spatialpolygon object containing field coordinates}

\item{landscape}{a spatialpolygon object containing field coordinates.}

\item{filename}{output layer name}

\item{filename}{a character string specifying the output layer name.}

\item{propSR}{proportion of fields where resistance is deployed: (RC)/(SC+RC) or (RC1+RC2)/(SC+RC1+RC2)}

\item{propSR}{proportion of fields where resistance is deployed: (RC)/(SC+RC) or (RC1+RC2)/(SC+RC1+RC2). Must be between 0 and 1.}

\item{isolSR}{spatial aggregation of fields where resistance is deployed (1=highly fragmented, 2=balanced, 3=highly aggregated)}

\item{isolSR}{an integer giving the spatial aggregation of fields where resistance is deployed (1=highly fragmented, 2=balanced, 3=highly aggregated).}

\item{propRR}{when applicable (mixtures and mosaics only), relative proportion of the second resistant cultivar: (RC2)/(RC1+RC2)}

\item{propRR}{when applicable (mixtures and mosaics only), relative proportion of the second resistant cultivar: (RC2)/(RC1+RC2). Must be between 0 and 1.}

\item{isolRR}{when applicable, spatial (for mosaics) or temporal (for rotations) aggregation of fields cultivated with the second resistant cultivar (1=highly fragmented, 2=balanced, 3=highly aggregated)}

\item{isolRR}{when applicable, an integer giving the spatial (for mosaics) or temporal (for rotations) aggregation of fields

cultivated with the second resistant cultivar (1=highly fragmented, 2=balanced, 3=highly aggregated).}