Title: | Landscape Epidemiology and Evolution |
---|---|
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>. |
Authors: | Loup Rimbaud [aut] , Marta Zaffaroni [aut] , Jean-François Rey [aut, cre] , Julien Papaix [aut], Jean-Loup Gaussen [ctb], Manon Couty [ctb] |
Maintainer: | Jean-François Rey <[email protected]> |
License: | GPL (>= 2) | file LICENSE |
Version: | 1.5.1 |
Built: | 2024-11-23 06:52:36 UTC |
Source: | CRAN |
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.
Package: | landsepi |
Type: | Package |
Version: | 1.5.1 |
Date: | 2024-09-23 |
License: | GPL (>=2) |
The landsepi package implements a spatially explicit stochastic model able to assess the epidemiological, evolutionary and economic outcomes of strategies to deploy plant resistance to pathogens. It also helps investigate the effect of landscape organisation, the considered pathosystem and the epidemio-evolutionary context on the performance of a given strategy.
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’, renamed HLIR for 'healthy-latent-infectious-removed' to avoid confusions with 'susceptible host') structure with a discrete time step. It simulates the spread and evolution (via mutation, recombination through sexual reproduction, selection and drift) of a pathogen in a heterogeneous cropping landscape, across cropping seasons split by host harvests which impose potential bottlenecks to the pathogen.
The lansdcape is represented by a set of polygons where the pathogen can disperse (the basic spatial unit is an individual polygon; an agricultural field may be composed of a single or several polygons). landsepi includes built-in simulated landscapes (and associated dispersal matrices for rust pathogens, see below), but is it possible to use your own landscape (in shapefile format) and dispersal matrix.
A wide array of resistance deployment strategies can be simulated in landsepi: fields of the
landscape are cultivated with different croptypes that can rotate through time; each croptype is
composed of either a pure cultivar or a mixture; and each cultivar may carry one or several resistance
genes. Thus, all combinations of rotations, mosaics, mixtures and pyramiding strategies are
possible. Resistance genes affect several possible pathogen aggressiveness components:
infection rate, durations of the latent period and the infectious period, and propagule
production rate. Resistance may be complete (i.e. complete inhibition of the targeted aggressiveness component) or partial
(i.e. the targeted aggressiveness component is only softened), and expressed from the beginning of the season, or later
(to simulate Adult Plant Resistance (APR), also called Mature Plant Resistance).
Cultivar allocation can be realised via an algorithm (allocateCroptypeCultivars()
)
but it is possible to use your own cultivar allocation if it is included in the shapefile
containing the landsape.
Additionally, any cultivar may be treated with contact pesticides, which reduce the pathogen infection rate
with an efficiency gradually decreasing with time and host growth.
To each resistance gene in the host (whether it may be a major gene or a QTL for quantitative resistance) is associated a pathogenicity gene in the pathogen. Through mutation of pathogenicity genes, the pathogen can restore its aggressiveness on resistance hosts and thus adapt to resistance (leading to sudden breakdown or gradual erosion of resistance genes). Pathogenicity genes may also be reassorted via sexual reproduction or gene recombination. Increased aggressiveness on a resistant host (i.e. adaptation to the corresponding resistance genes) can be penalised by a fitness cost, either on all hosts, or only on susceptible hosts (in the latter case, pathogen genotypes adapted to a resistance gene have a reduced aggressiveness on hosts that do not carry this gene, and a 'relative advantage' on host that do carry such gene). The relation between pathogen aggressiveness on susceptible and resistant hosts is defined by a trade-off relationship whose shape depends on the strength of the trade-off. Strong trade-off means that the gain in fitness on resistant hosts is smaller than the cost on susceptible hosts.
The package includes five examples of landscape structures and a default parameterisation to represent
plant pathogens as typified by rusts of cereal crops (genus Puccinia,
e.g. stripe rust, stem rust and leaf rust of wheat and barley). A parameterisation to
downy mildew of grapevine (Plasmopara viticola) and black sigatoka of banana
(Pseudocercospora fijiensis) are also available.
The main function of the package is runSimul()
.
It can be parameterised to simulate various resistance deployment strategies using either the provided
landscapes and parameters for cereal rusts, or landscapes and parameters set by the user.
See demo_landsepi()
for a demonstration, and our tutorials (browseVignettes("landsepi")
)
for details on how to use landsepi.
The spatial unit is a polygon, i.e. a piece of land delimited by boundaries and possibly cultivated with a crop. Such crop may be host or non-host, and the polygon is considered a homogeneous mixture of host individuals (i.e. there is no intra-polygon structuration). An agricultural field may be composed of a single or several polygons.
A host ‘individual’ is an infection unit (i.e. it can be infected by one and only one pathogen propagule, there is no co-infection) and may correspond to a given amount of plant tissue (where a local infection may develop, e.g. fungal lesion) or a whole plant (e.g. systemic viral infection). In the first case, plant growth increases the amount of available plant tissue (hence the number of individuals) during the cropping season. Plant growth is deterministic (logistic growth) and only healthy individuals (state H) contribute to plant growth (castrating pathogen).
Host individuals are in one of these four categories: H (healthy), E (exposed and latent, i.e. infected but not infectious nor symptomatic), I (infectious and symptomatic), or R (removed, i.e. epidemiologically inactive).
The decreasing availability of healthy host tissues (as epidemics spread) makes pathogen infection less likely (i.e. density-dependence due to plant architecture).
Hosts are cultivated (i.e. sown/planted and harvested), thus there is no host reproduction, dispersal and natural death.
Environmental and climate conditions are constant, and host individuals of a given genotype are equally susceptible to disease from the first to the last day of every cropping season.
Crop yield depends on the average amount of producing host individuals during the cropping season and does not depend on the time of epidemic peak. Only healthy individuals (state H) contribute to crop yield.
Cultivars may be treated with chemicals which reduce the pathogen infection rate (contact treatment). Treatment efficiency decreases with host growth (i.e. new biomass is not protected by treatments) and time (i.e. pesticide degradation). Cultivars to be treated and dates of chemical applications are fixed prior to simulations but only polygons where disease severity exceeds a given threshold (possibly 0) are treated.
Components of a mixture are independent each other (i.e. there is neither plant-plant interaction nor competition for space, and harvests are segregated). If one component is treated with a chemical, it does not affect other components.
The pathogen is haploid.
Initially, the pathogen is not adapted to any source of resistance, and is only present on susceptible hosts (at state I).
Pathogen dispersal is isotropic (i.e. equally probable in every direction).
Boundaries of the landscape are reflective: propagules stay in the system as if it was closed.
Pathogen reproduction can be purely clonal, purely sexual, or mixed (alternation of clonal and sexual reproduction).
If there is sexual reproduction (or gene recombination), it occurs only between parental infections located in the same polygon and the same host genotype (i.e. cultivar). At that scale, the pathogen population is panmictic (i.e. all pairs of parents have the same probability to occur). The propagule production rate of a parental pair is the sum of the propagule production rates of the parents. For a given parental pair, the genotype of each propagule is issued from random loci segregation of parental qualitative resistance genes. For each quantitative resistance gene, the value of each propagule trait is issued from a normal distribution around the average of the parental traits, following the infinitesimal model (Fisher 1919).
All types of propagules (i.e. clonal and sexual) share the same pathogenicity parameters (e.g. infection rate, latent period duration, etc.) but each of them has their own dispersal and survival abilities (see after).
At the end of each cropping season, pathogens experience a bottleneck representing the off-season and then propagules are produced (either via clonal or sexual reproduction). The probability of survival is the same every year and in every polygon. Clonal propagules are released during the following season only, either altogether at the first day of the season, or progressively (in that case the day of release of each propagule is sampled from a uniform distribution). Sexual propagules are gradually released during several of the following seasons (between-season release). The season of release of each propagule is sampled from an exponential distribution, truncated by a maximum viability limit. Then, the day of release in a given season is sampled from a uniform distribution (within-season release).
Pathogenicity genes mutate independently from each other.
Pathogen adaptation to a given resistance gene consists in restoring the same aggressiveness component as the one targeted by the resistance gene.
If a fitness cost penalises pathogen adaptation to a given resistance gene, this cost is paid on all hosts with possibly a relative advantage on hosts carrying the resistance gene. It consists in a reduction in the same aggressiveness component as the one targeted by the resistance gene.
When there is a delay for activation of a given resistance gene (APR), the age of activation is the same for all hosts carrying this gene and located in the same polygon.
Variances of the durations of the latent and the infectious periods of the pathogen are not affected by plant resistance.
The epidemiological outcome of a deployment strategy is evaluated using:
the area under the disease progress curve (AUDPC) to measure disease severity (i.e. the average number of diseased plant tissue -status I and R- per time step and square meter),
the relative area under the disease progress curve (AUDPCr) to measure the average proportion of diseased tissue (status I and R) relative to the total number of existing host individuals (H+L+I+R).
the Green Leaf Area (GLA) to measure the average amount of healthy plant tissue (status H) per time step and square meter,
the relative Green Leaf Area (GLAr) to measure the average proportion of healthy tissue (status H) relative to the total number of existing host individuals (H+L+I+R).
the yearly contribution of pathogen genotypes to LIR dynamics on every host as well as the whole landscape.
A set of graphics and a video showing epidemic dynamics can also be generated.
The evolutionary outcome is assessed by measuring:
the dynamics of pathogen genotype frequencies,
the evolution of pathogen aggressiveness,
the durability of resistance genes. Durability can be estimated using the time until the pathogen reaches the three steps to adapt to plant resistance: (1) first appearance of adapted mutants, (2) initial migration to resistant hosts and infection, and (3) broader establishment in the resistant host population (i.e. the point at which extinction becomes unlikely).
The economic outcome of a simulation can be evaluated using:
the crop yield: yearly crop production (e.g. grains, fruits, wine) in weight (or volume) units per hectare (depends on the number of productive hosts and associated theoretical yield),
the crop products: yearly products generated from sales, in monetary units per hectare (depends on crop yield and market value),
the crop operational costs: yearly costs associated with crop planting (depends on initial host density and planting cost) and pesticide treatments (depends on the number of applications and the cost of a single application) in monetary units per hectare.
the margin, i.e. products - operational costs, in monetary units per hectare.
Future versions:
Future versions of the package will include in particular:
Sets of pathogen parameters to simulate other pathosystems (e.g. Cucumber mosaic virus on pepper, potato virus Y on pepper).
An updated version of the shiny interface.
Dependencies:
The package for compiling needs:
g++
libgsl2
libgsl-dev
and the following R packages:
Rcpp
sp
stats
Matrix
mvtnorm
fields
splancs
sf
DBI
RSQLite
foreach
parallel
doParallel
deSolve
In addition, to generate videos the package will need ffmpeg.
Loup Rimbaud [email protected]
Marta Zaffaroni [email protected]
Jean-Francois Rey [email protected]
Julien Papaix [email protected]
Jean-Loup Gaussen [email protected]
Manon Couty [email protected]
Maintainer: Jean-Francois Rey [email protected]
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. PLoS Computational Biology 14(4):e1006067.
Rimbaud L., Papaïx J. and Rey J.-F. (2018). landsepi: Landscape Epidemiology and Evolution. R package, url: https://cran.r-project.org/package=landsepi.
Useful links:
Report bugs at https://gitlab.paca.inrae.fr/CSIRO-INRA/landsepi/-/issues
## Not run: library("landsepi") ## Run demonstrations (in 10-year simulations) for different deployment strategies: demo_landsepi(strat = "MO") ## for a mosaic of cultivars demo_landsepi(strat = "MI") ## for a mixture of cultivars demo_landsepi(strat = "RO") ## for a rotation of cultivars demo_landsepi(strat = "PY") ## for a pyramid of resistance genes ## End(Not run)
## Not run: library("landsepi") ## Run demonstrations (in 10-year simulations) for different deployment strategies: demo_landsepi(strat = "MO") ## for a mosaic of cultivars demo_landsepi(strat = "MI") ## for a mixture of cultivars demo_landsepi(strat = "RO") ## for a rotation of cultivars demo_landsepi(strat = "PY") ## for a pyramid of resistance genes ## End(Not run)
Generates a landscape composed of fields where croptypes are allocated with controlled proportions and spatio-temporal aggregation.
AgriLand( landscape, Nyears, rotation_period = 0, rotation_sequence = list(c(0, 1, 2)), rotation_realloc = FALSE, prop = list(c(1/3, 1/3, 1/3)), aggreg = list(1), algo = "periodic", croptype_names = c(), graphic = FALSE, outputDir = "./" )
AgriLand( landscape, Nyears, rotation_period = 0, rotation_sequence = list(c(0, 1, 2)), rotation_realloc = FALSE, prop = list(c(1/3, 1/3, 1/3)), aggreg = list(1), algo = "periodic", croptype_names = c(), graphic = FALSE, outputDir = "./" )
landscape |
a spatialpolygon object containing field coordinates. |
Nyears |
an integer giving the number of simulated cropping seasons. |
rotation_period |
number of years before rotation of the landscape. There is no rotation if rotation_period=0 or rotation_period=Nyears. |
rotation_sequence |
a list, each element of the list contains indices of croptypes that are cultivated during a period given by "rotation_period". There is no change in cultivated croptypes if the list contains only one element (e.g. only one vector c(0,1,2), indicating cultivation of croptypes 0, 1 and 2). |
rotation_realloc |
a logical indicating if a new random allocation of croptypes is performed when the landscape is rotated (FALSE=static allocation, TRUE=dynamic allocation). Note that if rotation_realloc=FALSE, all elements of the list "rotation_sequence" must have the same length, and only the first element of the lists "prop" and "aggreg" will be used. |
prop |
a list of the same size as "rotation_sequence", each element of the list contains a vector of the proportions (in surface) associated with the croptypes in "rotation_sequence". A single vector can be given instead of a list if all elements of "rotation_sequence" are associated with the same proportions. |
aggreg |
a list of the same size as "rotation_sequence", each element of the list is a single double indicating the degree of aggregation of the landscape. This double must greater or equal 0; the greater its value, the higher the degree of spatial aggregation (roughly, aggreg between 0 and 0.1 for fragmented landscapes, between 0.1 and 0.5 for balanced landscapes, between 0.5 and 3 for aggregated landscapes, and above 3 for highly aggregated landscapes). A single double can be given instead of a list if all elements of "rotation_sequence" are associated with the same level of aggregation. |
algo |
the algorithm used for the computation of the variance-covariance matrix of the multivariate normal distribution: "exp" for exponential function, "periodic" for periodic function, "random" for random draw (see details of function multiN). If algo="random", the parameter aggreg is not used. Algorithm "exp" is preferable for big landscapes. |
croptype_names |
a vector of croptype names (for legend in graphic). |
graphic |
a logical indicating if a graphic of the landscape must be generated (TRUE) or not (FALSE). |
outputDir |
a directory to save graphic |
An algorithm based on latent Gaussian fields is used to allocate two different croptypes
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 croptype
in terms of surface coverage, and their level of spatial aggregation.
A random vector of values is drawn from a multivariate normal distribution with expectation 0
and a variance-covariance matrix which depends on the pairwise distances between
the centroids of the fields. Next, the croptypes are allocated to different fields
depending on whether each value drawn from the multivariate normal distribution is above
or below a threshold. The proportion of each cultivar in the landscape is controlled by the value
of this threshold. To allocate more than two croptypes, AgriLand
uses sequentially
this algorithm. For instance, the allocation of three croptypes (e.g. SC, RC1 and RC2)
is performed as follows:
the allocation algorithm is run once to segregate the fields where the susceptible cultivar is grown, and
the two resistant cultivars (RC1 and RC2) are assigned to the remaining candidate fields by re-running the allocation algorithm.
a gpkg (shapefile) containing the landscape structure (i.e. coordinates of field boundaries), the area and composition (i.e. croptypes) in time (i.e. each year) for each field. A png graphic can be generated if graphic=TRUE.
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. PLoS Computational Biology 14(4):e1006067.
multiN, periodic_cov, allocateLandscapeCroptypes
## Not run: data(landscapeTEST) landscape <- get("landscapeTEST1") set.seed(12345) ## Generate a mosaic of three croptypes in balanced proportions ## and high level of spatial aggregation AgriLand(landscape, Nyears = 10, rotation_sequence = c(0, 1, 2), prop = rep(1 / 3, 3), aggreg = rep(10, 3), algo = "periodic", graphic = TRUE, outputDir = getwd() ) ## Generate a dynamic mosaic of two croptypes in unbalanced proportions ## and low level of spatial aggregation, ## the second croptype being replaced every 5 years without changing field allocation AgriLand(landscape, Nyears = 20, rotation_period = 5, rotation_sequence = list(c(0, 1), c(0, 2)), prop = c(1 / 3, 2 / 3), aggreg = c(0.07, 0.07), algo = "periodic", graphic = TRUE, outputDir = getwd() ) ## Generate a dynamic mosaic of four croptypes in balanced proportions ## and medium level of spatial aggregation, ## with field allocation changing every year AgriLand(landscape, Nyears = 5, rotation_period = 1, rotation_realloc = TRUE, rotation_sequence = c(0, 1, 2, 3), prop = rep(1 / 4, 4), aggreg = 0.25, algo = "exp", graphic = TRUE, outputDir = getwd() ) ## End(Not run)
## Not run: data(landscapeTEST) landscape <- get("landscapeTEST1") set.seed(12345) ## Generate a mosaic of three croptypes in balanced proportions ## and high level of spatial aggregation AgriLand(landscape, Nyears = 10, rotation_sequence = c(0, 1, 2), prop = rep(1 / 3, 3), aggreg = rep(10, 3), algo = "periodic", graphic = TRUE, outputDir = getwd() ) ## Generate a dynamic mosaic of two croptypes in unbalanced proportions ## and low level of spatial aggregation, ## the second croptype being replaced every 5 years without changing field allocation AgriLand(landscape, Nyears = 20, rotation_period = 5, rotation_sequence = list(c(0, 1), c(0, 2)), prop = c(1 / 3, 2 / 3), aggreg = c(0.07, 0.07), algo = "periodic", graphic = TRUE, outputDir = getwd() ) ## Generate a dynamic mosaic of four croptypes in balanced proportions ## and medium level of spatial aggregation, ## with field allocation changing every year AgriLand(landscape, Nyears = 5, rotation_period = 1, rotation_realloc = TRUE, rotation_sequence = c(0, 1, 2, 3), prop = rep(1 / 4, 4), aggreg = 0.25, algo = "exp", graphic = TRUE, outputDir = getwd() ) ## End(Not run)
Updates a given croptype by allocating cultivars composing it.
allocateCroptypeCultivars( croptypes, croptypeName, cultivarsInCroptype, prop = NULL )
allocateCroptypeCultivars( croptypes, croptypeName, cultivarsInCroptype, prop = NULL )
croptypes |
a dataframe containing all croptypes, initialised via
|
croptypeName |
the name of the croptype to be allocated |
cultivarsInCroptype |
name of cultivars composing the croptype |
prop |
vector of proportions of each cultivar in the croptype. Default to balanced proportions. |
a croptype data.frame updated for the concerned croptype.
## Not run: simul_params <- createSimulParams() cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Mixture")) croptypes croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Mixture", c("Resistant1", "Resistant2")) croptypes ## End(Not run)
## Not run: simul_params <- createSimulParams() cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Mixture")) croptypes croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Mixture", c("Resistant1", "Resistant2")) croptypes ## End(Not run)
Updates a LandsepiParams object with, for a given cultivar, the list of genes it carries
allocateCultivarGenes( params, cultivarName, listGenesNames = c(""), force.clean = FALSE )
allocateCultivarGenes( params, cultivarName, listGenesNames = c(""), force.clean = FALSE )
params |
a LandsepiParams object. |
cultivarName |
the name of the cultivar to be allocated. |
listGenesNames |
the names of the genes the cultivar carries |
force.clean |
force to clean previous allocated genes to all cultivars |
a LandsepiParams object
## Not run: simul_params <- createSimulParams() gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) simul_params <- allocateCultivarGenes(simul_params, "Resistant", c("MG 1", "MG 2")) simul_params@CultivarsGenes ## End(Not run)
## Not run: simul_params <- createSimulParams() gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) simul_params <- allocateCultivarGenes(simul_params, "Resistant", c("MG 1", "MG 2")) simul_params@CultivarsGenes ## End(Not run)
Updates the landscape of a LandsepiParams object with croptype allocation in every polygon of the landscape and every year of simulation. Allocation is based on an algorithm which controls croptype proportions (in surface) and spatio-temporal aggregation. Note that time, landscape and croptype parameters must be set before allocating landscape croptypes.
allocateLandscapeCroptypes( params, rotation_period, rotation_sequence, rotation_realloc = FALSE, prop, aggreg, algo = "periodic", graphic = TRUE )
allocateLandscapeCroptypes( params, rotation_period, rotation_sequence, rotation_realloc = FALSE, prop, aggreg, algo = "periodic", graphic = TRUE )
params |
a LandsepiParams Object. |
rotation_period |
number of years before rotation of the landscape. There is no rotation if rotation_period=0 or rotation_period=Nyears. |
rotation_sequence |
a list, each element of the list contains indices of croptypes that are cultivated during a period given by "rotation_period". There is no change in cultivated croptypes if the list contains only one element (e.g. only one vector c(0,1,2), indicating cultivation of croptypes 0, 1 and 2). |
rotation_realloc |
a logical indicating if a new random allocation of croptypes is performed when the landscape is rotated (FALSE=static allocation, TRUE=dynamic allocation). Note that if rotation_realloc=FALSE, all elements of the list "rotation_sequence" must have the same length, and only the first element of the lists "prop" and "aggreg" will be used. |
prop |
a list of the same size as "rotation_sequence", each element of the list contains a vector of the proportions (in surface) associated with the croptypes in "rotation_sequence". A single vector can be given instead of a list if all elements of "rotation_sequence" are associated with the same proportions. |
aggreg |
a list of the same size as "rotation_sequence", each element of the list is a single double indicating the degree of aggregation of the landscape. This double must greater or equal 0; the greater its value, the higher the degree of spatial aggregation (roughly, aggreg between 0 and 0.1 for fragmented landscapes, between 0.1 and 0.5 for balanced landscapes, between 0.5 and 3 for aggregated landscapes, and above 3 for highly aggregated landscapes). A single double can be given instead of a list if all elements of "rotation_sequence" are associated with the same level of aggregation. |
algo |
the algorithm used for the computation of the variance-covariance matrix of the multivariate normal distribution: "exp" for exponential function, "periodic" for periodic function, "random" for random draw (see details of function multiN). If algo="random", the parameter aggreg is not used. Algorithm "exp" is preferable for big landscapes. |
graphic |
a logical indicating if graphics must be generated (TRUE) or not (FALSE). |
An algorithm based on latent Gaussian fields is used to allocate two different
croptypes 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 croptype in terms of surface coverage, and their level of spatial aggregation.
A random vector of values is drawn from a multivariate normal distribution with expectation 0
and a variance-covariance matrix which depends on the pairwise distances between
the centroids of the polygons. Next, the croptypes are allocated to different polygons
depending on whether each value drawn from the multivariate normal distribution is above
or below a threshold. The proportion of each cultivar in the landscape is controlled by
the value of this threshold. To allocate more than two croptypes, AgriLand
uses
sequentially this algorithm. For instance, the allocation of three croptypes
(e.g. SC, RC1 and RC2) is performed as follows:
the allocation algorithm is run once to segregate the polygons where the susceptible cultivar is grown, and
the two resistant cultivars (RC1 and RC2) are assigned to the remaining candidate polygons by re-running the allocation algorithm.
a LandsepiParams object with Landscape updated with the layer "croptypeID". It contains croptype allocation in every polygon of the landscape for all years of simulation.
## Not run: ## Initialisation simul_params <- createSimulParams(outputDir = getwd()) ## Time parameters simul_params <- setTime(simul_params, Nyears = 10, nTSpY = 120) ## Landscape simul_params <- setLandscape(simul_params, loadLandscape(1)) ## Cultivars cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) ## Allocate cultivars to croptypes croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop" , "Resistant crop 1" , "Resistant crop 2")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 1", "Resistant1") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 2", "Resistant2") simul_params <- setCroptypes(simul_params, croptypes) ## Allocate croptypes to landscape rotation_sequence <- croptypes$croptypeID ## No rotation -> 1 rotation_sequence element rotation_period <- 0 ## same croptypes every years prop <- c(1 / 3, 1 / 3, 1 / 3) ## croptypes proportions aggreg <- 10 ## aggregated landscape simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = rotation_period, rotation_sequence = rotation_sequence, rotation_realloc = FALSE, prop = prop, aggreg = aggreg) simul_params@Landscape ## End(Not run)
## Not run: ## Initialisation simul_params <- createSimulParams(outputDir = getwd()) ## Time parameters simul_params <- setTime(simul_params, Nyears = 10, nTSpY = 120) ## Landscape simul_params <- setLandscape(simul_params, loadLandscape(1)) ## Cultivars cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) ## Allocate cultivars to croptypes croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop" , "Resistant crop 1" , "Resistant crop 2")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 1", "Resistant1") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 2", "Resistant2") simul_params <- setCroptypes(simul_params, croptypes) ## Allocate croptypes to landscape rotation_sequence <- croptypes$croptypeID ## No rotation -> 1 rotation_sequence element rotation_period <- 0 ## same croptypes every years prop <- c(1 / 3, 1 / 3, 1 / 3) ## croptypes proportions aggreg <- 10 ## aggregated landscape simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = rotation_period, rotation_sequence = rotation_sequence, rotation_realloc = FALSE, prop = prop, aggreg = aggreg) simul_params@Landscape ## End(Not run)
Give the antiderivative of the logistic function from the Verhulst model.
antideriv_verhulst(x, initial_density, max_density, growth_rate)
antideriv_verhulst(x, initial_density, max_density, growth_rate)
x |
timestep up to which antiderivative must be computed |
initial_density |
initial density |
max_density |
maximal density |
growth_rate |
growth rate |
The Verhulst model (used to simulate host growth) is defined by
.
See https://en.wikipedia.org/wiki/Logistic_function for details.
An object of the same type as x containing the antiderivative of the input values.
antideriv_verhulst(119, 0.1, 2, 0.1) / 120
antideriv_verhulst(119, 0.1, 2, 0.1) / 120
checks croptypes validity
checkCroptypes(params)
checkCroptypes(params)
params |
a LandsepiParams object. |
a boolean, TRUE if OK, FALSE otherwise
check cultivars validity
checkCultivars(params)
checkCultivars(params)
params |
a LandsepiParams object. |
a boolean, TRUE if OK, FALSE otherwise
Checks CultivarsGene data.frame validity
checkCultivarsGenes(params)
checkCultivarsGenes(params)
params |
a LandsepiParams object. |
a boolean, TRUE if OK, FALSE otherwise
Checks host dispersal matrix validity.
checkDispersalHost(params)
checkDispersalHost(params)
params |
a LandsepiParams Object. |
a boolean TRUE if OK, FALSE otherwise
Checks pathogen dispersal validity
checkDispersalPathogen(params)
checkDispersalPathogen(params)
params |
a LandsepiParams Object. |
a boolean TRUE if OK, FALSE otherwise
checks Genes data.frame validity
checkGenes(params)
checkGenes(params)
params |
a LandsepiParams object. |
a boolean, TRUE if OK, FALSE otherwise
Checks inoculum validity.
checkInoculum(params)
checkInoculum(params)
params |
a LandsepiParams object. |
a boolean, TRUE if OK, FALSE otherwise
Checks landscape validity
checkLandscape(params)
checkLandscape(params)
params |
a LandsepiParams Object. |
TRUE if Ok, FALSE otherwise
Checks outputs validity.
checkOutputs(params)
checkOutputs(params)
params |
a LandsepiParams object. |
a boolean, TRUE if OK, FALSE otherwise
Checks pathogen validity
checkPathogen(params)
checkPathogen(params)
params |
a LandsepiParams Object. |
a boolean, TRUE if OK, FALSE otherwise
loadInoculum()
.Checks validity of the array.
checkPI0_mat(mat, params)
checkPI0_mat(mat, params)
mat |
a 3D array of dimensions (1:Nhost,1:Npatho,1:Npoly) |
params |
a LandsepiParams object. |
the same array at mat, possibly corrected if incompatibility has been detected
Checks validity of a LandsepiParams object.
checkSimulParams(params)
checkSimulParams(params)
params |
a LandsepiParams Object. |
TRUE if OK for simulation, FALSE otherwise
Checks time parameters validity
checkTime(params)
checkTime(params)
params |
a LandsepiParams Object. |
a boolean TRUE if times are setted.
Checks treatment validity
checkTreatment(params)
checkTreatment(params)
params |
a LandsepiParams Object. |
a boolean, TRUE if OK, FALSE otherwise
Compute AUDPC in a single field cultivated with a susceptible cultivar.
compute_audpc100S( disease = "rust", hostType = "wheat", nTSpY = 120, area = 1e+06, seed = 12345 )
compute_audpc100S( disease = "rust", hostType = "wheat", nTSpY = 120, area = 1e+06, seed = 12345 )
disease |
a disease name, among "rust" (default), "mildew" and "sigatoka" |
hostType |
cultivar type, among: "wheat" (default), "grapevine", "banana", "pepper". |
nTSpY |
number to time steps per cropping season |
area |
area of the field (must be in square meters). |
seed |
an integer used as seed value (for random number generator). |
audpc100S is the average AUDPC computed in a non-spatial simulation.
The AUDPC value (numeric)
## Not run: compute_audpc100S("rust", "wheat", area=1E6) compute_audpc100S("mildew", "grapevine", area=1E6) compute_audpc100S("sigatoka", "banana", area=1E6, nTSpY=182) ## End(Not run)
## Not run: compute_audpc100S("rust", "wheat", area=1E6) compute_audpc100S("mildew", "grapevine", area=1E6) compute_audpc100S("sigatoka", "banana", area=1E6, nTSpY=182) ## End(Not run)
Creates a default object of class LandsepiParams.
createSimulParams(outputDir = "./")
createSimulParams(outputDir = "./")
outputDir |
ouput directory for simulation (default: current directory) |
Create a default object of class LandsepiParams used to store all
simulation parameters. It also creates a subdirectory in outputDir
using the date; this directory will contain all simulation outputs.
a LandsepiParams object initialised with the following context:
random seed
all pathogen parameters fixed at 0
no between-polygon dispersal (neither pathogen nor host)
no pathogen introduction
no resistance gene
no chemical treatment
no output to generate.
## Not run: createSimulParams() ## End(Not run)
## Not run: createSimulParams() ## End(Not run)
A set of configurated cultivars types
Cultivars_list
Cultivars_list
A list of list indexed by type name
cultivarName: cultivar names (cannot accept space),
initial_density: host densities (per square meter) at the beginning of the cropping season as if cultivated in pure crop,
max_density: maximum host densities (per square meter) at the end of the cropping season as if cultivated in pure crop,
growth rate: host growth rates,
reproduction rate: host reproduction rates,
yield_H: theoretical yield (in weight or volume units / ha / cropping season) associated with hosts in sanitary status H as if cultivated in pure crop,
yield_L: theoretical yield (in weight or volume units / ha / cropping season) associated with hosts in sanitary status L as if cultivated in pure crop,
yield_I: theoretical yield (in weight or volume units / ha / cropping season) associated with hosts in sanitary status I as if cultivated in pure crop,
yield_R: theoretical yield (in weight or volume units / ha / cropping season) associated with hosts in sanitary status R as if cultivated in pure crop,
planting_cost = planting costs (in monetary units / ha / cropping season) as if cultivated in pure crop,
market_value = market values of the production (in monetary units / weight or volume unit).
run a simulation demonstration with landsepi
demo_landsepi( seed = 5, strat = "MO", Nyears = 10, nTSpY = 120, videoMP4 = FALSE )
demo_landsepi( seed = 5, strat = "MO", Nyears = 10, nTSpY = 120, videoMP4 = FALSE )
seed |
an interger used as seed for Random Number Generator. |
strat |
a string specifying the deployment strategy: "MO" for mosaic of resistant cultivars, "MI" for intra-fied mixtures, "RO" for cultivar rotations, and "PY" for resistance gene pyramiding in a cultivar. |
Nyears |
number of cropping seasons (years) to simulate. |
nTSpY |
number of time-steps (days) per cropping season. |
videoMP4 |
a logical indicating if a video must be generated (TRUE, default) or not (FALSE). |
In these examples on rust fungi of cereal crops, 2 completely efficient resistance sources (typical of major resistance genes) are deployed in the landscape according to one of the following strategies:
Mosaic: 3 pure crops (S + R1 + R2) with very high spatial aggregation.
Mixture: 1 pure susceptible crop + 1 mixture of two resistant cultivars, with high aggregation.
Rotation: 1 susceptible pure crop + 2 resistant crops in alternation every 2 years , with moderate aggregation.
Pyramiding: 1 susceptible crop + 1 pyramided cultivar in a fragmented landscape (low aggregation).
A set of text files, graphics and a video showing epidemic dynamics.
## Not run: ## Run demonstrations (in 10-year simulations) for different deployment strategies: demo_landsepi(strat = "MO") ## for a mosaic of cultivars demo_landsepi(strat = "MI") ## for a mixture of cultivars demo_landsepi(strat = "RO") ## for a rotation of cultivars demo_landsepi(strat = "PY") ## for a pyramid of resistance genes ## End(Not run)
## Not run: ## Run demonstrations (in 10-year simulations) for different deployment strategies: demo_landsepi(strat = "MO") ## for a mosaic of cultivars demo_landsepi(strat = "MI") ## for a mixture of cultivars demo_landsepi(strat = "RO") ## for a rotation of cultivars demo_landsepi(strat = "PY") ## for a pyramid of resistance genes ## End(Not run)
Five vectorised dispersal matrices of pathogens as typified by rust fungi of cereal crops (genus Puccinia), and associated with landscapes 1 to 5 (composed of 155, 154, 152, 153 and 156 fields, respectively).
dispP_1 dispP_2 dispP_3 dispP_4 dispP_5
dispP_1 dispP_2 dispP_3 dispP_4 dispP_5
The format is: num [1:24025] 8.81e-01 9.53e-04 7.08e-10 1.59e-10 3.29e-06 ...
The pathogen dispersal matrix gives the probability for a pathogen in a field i (row) to migrate to field i' (column) through dispersal. It is computed based on a dispersal kernel and the euclidian distance between each point in fields i and i', using the CaliFloPP algorithm (Bouvier et al. 2009).
The dispersal kernel is an isotropic power-law function of equation:
with a=40 a scale parameter and b=7 related to the weight of the dispersal tail.
The expected mean dispersal distance is given by 2*a/(b-3)=20 m.
Bouvier A, Kiêu K, Adamczyk K, Monod H. Computation of the integrated flow of particles between polygons. Environ. Model Softw. 2009;24(7):843-9. doi: http://dx.doi.org/10.1016/j.envsoft.2008.11.006.
dispP_1 summary(dispP_1) ## maybe str(dispP_1) ; plot(dispP_1) ...
dispP_1 summary(dispP_1) ## maybe str(dispP_1) ; plot(dispP_1) ...
Generates epidemiological and economic outputs from model simulations.
epid_output( types = "all", time_param, Npatho, area, rotation, croptypes, cultivars_param, eco_param, treatment_param, pathogen_param, audpc100S = 0.76, writeTXT = TRUE, graphic = TRUE, path = getwd() )
epid_output( types = "all", time_param, Npatho, area, rotation, croptypes, cultivars_param, eco_param, treatment_param, pathogen_param, audpc100S = 0.76, writeTXT = TRUE, graphic = TRUE, path = getwd() )
types |
a character string (or a vector of character strings if several outputs are to be computed) specifying the type of outputs to generate (see details):
|
time_param |
list of simulation parameters:
|
Npatho |
number of pathogen genotypes. |
area |
a vector containing polygon areas (must be in square meters). |
rotation |
a dataframe containing for each field (rows) and year (columns, named "year_1", "year_2", etc.), the index of the cultivated croptype. Importantly, the matrix must contain 1 more column than the real number of simulated years. |
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. |
cultivars_param |
list of parameters associated with each host genotype (i.e. cultivars):
|
eco_param |
a list of economic parameters for each host genotype as if cultivated in pure crop:
|
treatment_param |
list of parameters related to pesticide treatments:
|
pathogen_param |
a list of i. pathogen aggressiveness parameters on a susceptible host for a pathogen genotype not adapted to resistance and ii. sexual reproduction parameters:
|
audpc100S |
the audpc in a fully susceptible landscape (used as reference value for graphics). |
writeTXT |
a logical indicating if the output is written in a text file (TRUE) or not (FALSE). |
graphic |
a logical indicating if a tiff graphic of the output is generated (only if more than one year is simulated). |
path |
path of text file (if writeTXT = TRUE) and tiff graphic (if graphic = TRUE) to be generated. |
Outputs are computed every year for every cultivar as well as for the whole landscape.
The epidemiological impact of pathogen spread can be evaluated by different measures:
Area Under Disease Progress Curve (AUDPC): average number of diseased host individuals (status I + R) per time step and square meter.
Relative Area Under Disease Progress Curve (AUDPCr): average proportion of diseased host individuals (status I + R) relative to the total number of existing hosts (H+L+I+R).
Green Leaf Area (GLA): average number of healthy host individuals (status H) per time step and per square meter.
Relative Green Leaf Area (GLAr): average proportion of healthy host individuals (status H) relative to the total number of existing hosts (H+L+I+R).
Contribution of pathogen genotypes: for every year and every host (as well as for the whole landscape and the whole simulation duration), fraction of cumulative LIR infections attributed to each pathogen genotype.
The economic outcome of a simulation can be evaluated using:
Crop yield: yearly crop yield (e.g. grains, fruits, wine) in weight (or volume) units per hectare (depends on the number of productive hosts and associated theoretical yield).
Crop products: yearly product generated from sales, in monetary units per hectare (depends on crop yield and market value). Note that when disease = "mildew" a price reduction between 0% and 5% is applied to the market value depending on disease severity.
Operational crop costs: yearly costs associated with crop planting (depends on initial host density and planting cost) and pesticide treatments (depends on the number of applications and the cost of a single application) in monetary units per hectare.
Crop margin, i.e. products - operational costs, in monetary units per hectare.
A list containing, for each required type of output, a matrix summarising the output for each year and cultivar (as well as the whole landscape). Each matrix can be written in a txt file (if writeTXT=TRUE), and illustrated in a graphic (if graphic=TRUE).
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. PLoS Computational Biology 14(4):e1006067.
## Not run: demo_landsepi() ## End(Not run)
## Not run: demo_landsepi() ## End(Not run)
Generates evolutionary outputs from model simulations.
evol_output( types = "all", time_param, Npoly, cultivars_param, genes_param, thres_breakdown = 50000, writeTXT = TRUE, graphic = TRUE, path = getwd() )
evol_output( types = "all", time_param, Npoly, cultivars_param, genes_param, thres_breakdown = 50000, writeTXT = TRUE, graphic = TRUE, path = getwd() )
types |
a character string (or a vector of character strings if several outputs are to be computed) specifying the type of outputs to generate (see details):
|
time_param |
list of simulation parameters:
|
Npoly |
number of fields in the landscape. |
cultivars_param |
list of parameters associated with each host genotype (i.e. cultivars) when cultivated in pure crops:
|
genes_param |
list of parameters associated with each resistance gene and with the evolution of each corresponding pathogenicity gene:
|
thres_breakdown |
an integer (or vector of integers) giving the threshold (i.e. number of infections) above which a pathogen genotype is unlikely to go extinct and resistance is considered broken down, used to characterise the time to invasion of resistant hosts (several values are computed if several thresholds are given in a vector). |
writeTXT |
a logical indicating if the output is written in a text file (TRUE) or not (FALSE). |
graphic |
a logical indicating if graphics must be generated (TRUE) or not (FALSE). |
path |
a character string indicating the path of the repository where simulation output files are located and where .txt files and graphics will be generated. |
For each pathogen genotype (evol_patho) or phenotype (evol_aggr, note that different pathogen genotypes may lead to the same phenotype on a resistant host), several computations are performed based on pathogen genotype frequencies:
appearance: time to first appearance (as propagule);
R_infection: time to first true infection of a resistant host;
R_invasion: time to invasion, when the number of infections of resistant hosts reaches a threshold above which the genotype or phenotype is unlikely to go extinct.
The value Nyears + 1 time step is used if the genotype or phenotype never appeared/infected/invaded. Durability is defined as the time to invasion of completely adapted pathogen individuals.
A list containing, for each required type of output, a matrix summarising the output. Each matrix can be written in a txt file (if writeTXT=TRUE), and illustrated in a graphic (if graphic=TRUE).
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. PLoS Computational Biology 14(4):e1006067.
## Not run: demo_landsepi() ## End(Not run)
## Not run: demo_landsepi() ## End(Not run)
Build the matrix indicating if infection is possible at the beginning of the season for every combination of croptype (rows) and pathogen genotype (columns).
getMatrixCroptypePatho(params)
getMatrixCroptypePatho(params)
params |
a LandsepiParams object. |
For each croptype, there is either possibility of infection by the pathogen genotype (value of 1), either complete protection (value of 0)
an interaction matrix composed of 0 and 1 values.
getMatrixGenePatho, getMatrixCultivarPatho, getMatrixPolyPatho
## Not run: simul_params <- createSimulParams() gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivar4 <- loadCultivar(name = "Pyramid", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3, cultivar4) , stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) simul_params <- allocateCultivarGenes(simul_params, "Resistant1", c("MG 1")) simul_params <- allocateCultivarGenes(simul_params, "Resistant2", c("MG 2")) simul_params <- allocateCultivarGenes(simul_params, "Pyramid", c("MG 1", "MG 2")) croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Resistant crop 1", "Mixture S+R", "Mixture R1+R2", "Pyramid crop")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 1", "Resistant1") croptypes <- allocateCroptypeCultivars(croptypes, "Mixture S+R", c("Susceptible", "Resistant1")) croptypes <- allocateCroptypeCultivars(croptypes, "Mixture R1+R2", c("Resistant1", "Resistant2")) croptypes <- allocateCroptypeCultivars(croptypes, "Pyramid crop", c("Pyramid")) simul_params <- setCroptypes(simul_params, croptypes) getMatrixCroptypePatho(simul_params) ## End(Not run)
## Not run: simul_params <- createSimulParams() gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivar4 <- loadCultivar(name = "Pyramid", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3, cultivar4) , stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) simul_params <- allocateCultivarGenes(simul_params, "Resistant1", c("MG 1")) simul_params <- allocateCultivarGenes(simul_params, "Resistant2", c("MG 2")) simul_params <- allocateCultivarGenes(simul_params, "Pyramid", c("MG 1", "MG 2")) croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Resistant crop 1", "Mixture S+R", "Mixture R1+R2", "Pyramid crop")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 1", "Resistant1") croptypes <- allocateCroptypeCultivars(croptypes, "Mixture S+R", c("Susceptible", "Resistant1")) croptypes <- allocateCroptypeCultivars(croptypes, "Mixture R1+R2", c("Resistant1", "Resistant2")) croptypes <- allocateCroptypeCultivars(croptypes, "Pyramid crop", c("Pyramid")) simul_params <- setCroptypes(simul_params, croptypes) getMatrixCroptypePatho(simul_params) ## End(Not run)
Build the matrix indicating if infection is possible at the beginning of the season for every combination of cultivar (rows) and pathogen genotype (columns).
getMatrixCultivarPatho(params)
getMatrixCultivarPatho(params)
params |
a LandsepiParams object. |
For each cultivar, there is either possibility of infection by the pathogen genotype (value of 1), or complete protection (value of 0).
an interaction matrix composed of 0 and 1 values.
getMatrixGenePatho, getMatrixCroptypePatho, getMatrixPolyPatho
## Not run: simul_params <- createSimulParams() gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "monoResistant1", type = "wheat") cultivar3 <- loadCultivar(name = "monoResistant2", type = "wheat") cultivar4 <- loadCultivar(name = "Pyramid", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3, cultivar4) , stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) simul_params <- allocateCultivarGenes(simul_params, "monoResistant1", c("MG 1")) simul_params <- allocateCultivarGenes(simul_params, "monoResistant2", c("MG 2")) simul_params <- allocateCultivarGenes(simul_params, "Pyramid", c("MG 1", "MG 2")) getMatrixCultivarPatho(simul_params) ## End(Not run)
## Not run: simul_params <- createSimulParams() gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "monoResistant1", type = "wheat") cultivar3 <- loadCultivar(name = "monoResistant2", type = "wheat") cultivar4 <- loadCultivar(name = "Pyramid", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3, cultivar4) , stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) simul_params <- allocateCultivarGenes(simul_params, "monoResistant1", c("MG 1")) simul_params <- allocateCultivarGenes(simul_params, "monoResistant2", c("MG 2")) simul_params <- allocateCultivarGenes(simul_params, "Pyramid", c("MG 1", "MG 2")) getMatrixCultivarPatho(simul_params) ## End(Not run)
Build the matrix indicating if infection is possible at the beginning of the season for every combination of plant resistance gene (rows) and pathogen genotype (columns).
getMatrixGenePatho(params)
getMatrixGenePatho(params)
params |
a LandsepiParams object. |
For hosts carrying each resistance gene, there is either possibility of infection by the pathogen genotype (value of 1), either complete protection (value of 0). Complete protection only occurs if the resistance gene targets the infection rate, has a complete efficiency, and is expressed from the beginning of the cropping season (i.e. this is not an APR).
an interaction matrix composed of 0 and 1 values.
getMatrixCultivarPatho, getMatrixCroptypePatho, getMatrixPolyPatho
## Not run: simul_params <- createSimulParams() gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) getMatrixGenePatho(simul_params) ## End(Not run)
## Not run: simul_params <- createSimulParams() gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) getMatrixGenePatho(simul_params) ## End(Not run)
Build the matrix indicating if infection is possible at the beginning of the season for every combination of polygon (rows) and pathogen genotype (columns).
getMatrixPolyPatho(params)
getMatrixPolyPatho(params)
params |
a LandsepiParams object. |
For each polygon, there is either possibility of infection by the pathogen genotype (value of 1), either complete protection (value of 0)
an interaction matrix composed of 0 and 1 values.
getMatrixGenePatho, getMatrixCultivarPatho, getMatrixCroptypePatho
## Not run: simul_params <- createSimulParams() simul_params <- setTime(simul_params, Nyears = 1, nTSpY = 80) simul_params <- setLandscape(simul_params, loadLandscape(id = 1)) gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivar4 <- loadCultivar(name = "Pyramid", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3, cultivar4) , stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) simul_params <- allocateCultivarGenes(simul_params, "Resistant1", c("MG 1")) simul_params <- allocateCultivarGenes(simul_params, "Resistant2", c("MG 2")) simul_params <- allocateCultivarGenes(simul_params, "Pyramid", c("MG 1", "MG 2")) croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Resistant crop 1", "Mixture S+R", "Mixture R1+R2", "Pyramid crop")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 1", "Resistant1") croptypes <- allocateCroptypeCultivars(croptypes, "Mixture S+R", c("Susceptible", "Resistant1")) croptypes <- allocateCroptypeCultivars(croptypes, "Mixture R1+R2", c("Resistant1", "Resistant2")) croptypes <- allocateCroptypeCultivars(croptypes, "Pyramid crop", c("Pyramid")) simul_params <- setCroptypes(simul_params, croptypes) simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = 0, prop=rep(1/5,5), aggreg=3 , rotation_sequence = croptypes$croptypeID) getMatrixPolyPatho(simul_params) ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setTime(simul_params, Nyears = 1, nTSpY = 80) simul_params <- setLandscape(simul_params, loadLandscape(id = 1)) gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivar4 <- loadCultivar(name = "Pyramid", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3, cultivar4) , stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) simul_params <- allocateCultivarGenes(simul_params, "Resistant1", c("MG 1")) simul_params <- allocateCultivarGenes(simul_params, "Resistant2", c("MG 2")) simul_params <- allocateCultivarGenes(simul_params, "Pyramid", c("MG 1", "MG 2")) croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Resistant crop 1", "Mixture S+R", "Mixture R1+R2", "Pyramid crop")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 1", "Resistant1") croptypes <- allocateCroptypeCultivars(croptypes, "Mixture S+R", c("Susceptible", "Resistant1")) croptypes <- allocateCroptypeCultivars(croptypes, "Mixture R1+R2", c("Resistant1", "Resistant2")) croptypes <- allocateCroptypeCultivars(croptypes, "Pyramid crop", c("Pyramid")) simul_params <- setCroptypes(simul_params, croptypes) simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = 0, prop=rep(1/5,5), aggreg=3 , rotation_sequence = croptypes$croptypeID) getMatrixPolyPatho(simul_params) ## End(Not run)
Creates and initialises a LandsepiParams object with default parameters.
## S4 method for signature 'LandsepiParams' initialize( .Object, Landscape = st_sf(st_sfc()), Croptypes = data.frame(), Cultivars = data.frame(matrix(ncol = length(.cultivarsColNames), nrow = 0, dimnames = list(NULL, .cultivarsColNames))), CultivarsGenes = data.frame(), Genes = data.frame(matrix(ncol = length(.geneColNames), nrow = 0, dimnames = list(NULL, .geneColNames))), Pathogen = list(name = "no pathogen", survival_prob = 0, repro_sex_prob = 0, infection_rate = 0, propagule_prod_rate = 0, latent_period_mean = 0, latent_period_var = 0, infectious_period_mean = 0, infectious_period_var = 0, sigmoid_kappa = 0, sigmoid_sigma = 0, sigmoid_plateau = 1, sex_propagule_viability_limit = 0, sex_propagule_release_mean = 0, clonal_propagule_gradual_release = 0), PI0 = 0, DispHost = vector(), DispPathoClonal = vector(), DispPathoSex = vector(), Treatment = list(treatment_degradation_rate = 0.1, treatment_efficiency = 0, treatment_timesteps = vector(), treatment_cultivars = vector(), treatment_cost = 0, treatment_application_threshold = vector()), OutputDir = normalizePath(character(getwd())), OutputGPKG = "landsepi_landscape.gpkg", Outputs = list(epid_outputs = "", evol_outputs = "", thres_breakdown = NA, audpc100S = NA), TimeParam = list(Nyears = 0, nTSpY = 0), Seed = NULL, ... )
## S4 method for signature 'LandsepiParams' initialize( .Object, Landscape = st_sf(st_sfc()), Croptypes = data.frame(), Cultivars = data.frame(matrix(ncol = length(.cultivarsColNames), nrow = 0, dimnames = list(NULL, .cultivarsColNames))), CultivarsGenes = data.frame(), Genes = data.frame(matrix(ncol = length(.geneColNames), nrow = 0, dimnames = list(NULL, .geneColNames))), Pathogen = list(name = "no pathogen", survival_prob = 0, repro_sex_prob = 0, infection_rate = 0, propagule_prod_rate = 0, latent_period_mean = 0, latent_period_var = 0, infectious_period_mean = 0, infectious_period_var = 0, sigmoid_kappa = 0, sigmoid_sigma = 0, sigmoid_plateau = 1, sex_propagule_viability_limit = 0, sex_propagule_release_mean = 0, clonal_propagule_gradual_release = 0), PI0 = 0, DispHost = vector(), DispPathoClonal = vector(), DispPathoSex = vector(), Treatment = list(treatment_degradation_rate = 0.1, treatment_efficiency = 0, treatment_timesteps = vector(), treatment_cultivars = vector(), treatment_cost = 0, treatment_application_threshold = vector()), OutputDir = normalizePath(character(getwd())), OutputGPKG = "landsepi_landscape.gpkg", Outputs = list(epid_outputs = "", evol_outputs = "", thres_breakdown = NA, audpc100S = NA), TimeParam = list(Nyears = 0, nTSpY = 0), Seed = NULL, ... )
.Object |
a LandsepiParam object. |
Landscape |
a landscape as sf object. |
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. |
Cultivars |
a dataframe of parameters associated with each host genotype (i.e. cultivars, lines) when cultivated in pure crops. |
CultivarsGenes |
a list containing, for each host genotype, the indices of carried resistance genes. |
Genes |
a data.frame of parameters associated with each resistance gene and with the evolution of each corresponding pathogenicity gene. |
Pathogen |
a list of pathogen aggressiveness parameters on a susceptible host for a pathogen genotype not adapted to resistance. |
PI0 |
vector of length Npoly.Nhost.Npatho filled with the initial probabilities for hosts to be infectious (i.e. state I), for each pathogen genotype, at the beginning of the simulation. |
DispHost |
a vectorized matrix giving the probability of host dispersal from any polygon of the landscape to any other polygon |
DispPathoClonal |
a vectorized matrix giving the probability of pathogen dispersal from any polygon of the landscape to any other polygon. |
DispPathoSex |
a vectorized matrix giving the probability of pathogen dispersal from any polygon of the landscape to any other polygon (sexual propagule). |
Treatment |
a list of chemical treatment parameters (indices of treated cultivars, times of application, efficiency and degradation rate) |
OutputDir |
the directory for simulation outputs |
OutputGPKG |
the name of the output GPKG file containing parameters of the deployment strategy |
Outputs |
a list of outputs parameters. |
TimeParam |
a list of time parameters. |
Seed |
an integer used as seed value (for random number generator). |
... |
more options |
Transform the inoculum pI0 (1D vector of length NhostNpathoNpoly) into a 3D array (for visualization purpose)
inoculumToMatrix(params)
inoculumToMatrix(params)
params |
a LandsepiParams object. |
After defining the inoculum with setInoculum()
, this function returns
the inoculum as a 3D array.
a 3D array of structure (1:Nhost,1:Npatho,1:Npoly)
## Not run: simul_params <- createSimulParams() simul_params <- setTime(simul_params, Nyears = 1, nTSpY = 80) simul_params <- setPathogen(simul_params, loadPathogen(disease = "rust")) simul_params <- setLandscape(simul_params, loadLandscape(id = 1)) simul_params <- setDispersalPathogen(simul_params, loadDispersalPathogen(id = 1)[[1]]) gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) simul_params <- allocateCultivarGenes(simul_params, "Resistant", c("MG 1", "MG 2")) croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Resistant crop")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop", c("Resistant")) simul_params <- setCroptypes(simul_params, croptypes) simul_params@Croptypes simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = 0 , rotation_sequence = croptypes$croptypeID , prop = c(1/2,1/2), aggreg = 1, graphic = FALSE) pI0 <- loadInoculum(simul_params, pI0_patho=c(1E-3,1E-4,1E-4,1E-5), pI0_host=c(1,1)) simul_params <- setInoculum(simul_params, pI0) inoculumToMatrix(simul_params)[,,1:5] ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setTime(simul_params, Nyears = 1, nTSpY = 80) simul_params <- setPathogen(simul_params, loadPathogen(disease = "rust")) simul_params <- setLandscape(simul_params, loadLandscape(id = 1)) simul_params <- setDispersalPathogen(simul_params, loadDispersalPathogen(id = 1)[[1]]) gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) simul_params <- allocateCultivarGenes(simul_params, "Resistant", c("MG 1", "MG 2")) croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Resistant crop")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop", c("Resistant")) simul_params <- setCroptypes(simul_params, croptypes) simul_params@Croptypes simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = 0 , rotation_sequence = croptypes$croptypeID , prop = c(1/2,1/2), aggreg = 1, graphic = FALSE) pI0 <- loadInoculum(simul_params, pI0_patho=c(1E-3,1E-4,1E-4,1E-5), pI0_host=c(1,1)) simul_params <- setInoculum(simul_params, pI0) inoculumToMatrix(simul_params)[,,1:5] ## End(Not run)
Given a numeric object, return the invlogit of the values. Missing values (NAs) are allowed.
invlogit(x)
invlogit(x)
x |
a numeric object |
The invlogit is defined by . 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.
An object of the same type as x containing the invlogits of the input values.
invlogit(10)
invlogit(10)
Tests if a number or vector is in the interval [0,1]
is.in.01(x, exclude0 = FALSE)
is.in.01(x, exclude0 = FALSE)
x |
a number or vector or matrix |
exclude0 |
TRUE is 0 is excluded, FALSE otherwise (default) |
a logical of the same size as x
is.in.01(-5) is.in.01(0) is.in.01(1) is.in.01(0, exclude0 = TRUE) is.in.01(2.5) is.in.01(matrix(5:13/10, nrow=3))
is.in.01(-5) is.in.01(0) is.in.01(1) is.in.01(0, exclude0 = TRUE) is.in.01(2.5) is.in.01(matrix(5:13/10, nrow=3))
Tests if a number or vector is positive (including 0)
is.positive(x)
is.positive(x)
x |
a number or vector or matrix |
a logical of the same size as x
is.positive(-5) is.positive(10) is.positive(2.5) is.positive(matrix(1:9, nrow=3))
is.positive(-5) is.positive(10) is.positive(2.5) is.positive(matrix(1:9, nrow=3))
Tests if a number or vector is strictly positive (i.e. excluding 0)
is.strict.positive(x)
is.strict.positive(x)
x |
a number or vector or matrix |
a logical of the same size as x
is.strict.positive(-5) is.strict.positive(10) is.strict.positive(2.5) is.strict.positive(matrix(1:9, nrow=3))
is.strict.positive(-5) is.strict.positive(10) is.strict.positive(2.5) is.strict.positive(matrix(1:9, nrow=3))
Tests if a number or vector is a whole number
is.wholenumber(x, tol = .Machine$double.eps^0.5)
is.wholenumber(x, tol = .Machine$double.eps^0.5)
x |
a number or vector or matrix |
tol |
double tolerance |
a logical of the same format as x
is.wholenumber(-5) is.wholenumber(10) is.wholenumber(2.5) is.wholenumber(matrix(1:9, nrow=3))
is.wholenumber(-5) is.wholenumber(10) is.wholenumber(2.5) is.wholenumber(matrix(1:9, nrow=3))
Five simulated landscapes, composed of 155, 154, 152, 153 and 156 fields, respectively.
landscapeTEST1 landscapeTEST2 landscapeTEST3 landscapeTEST4 landscapeTEST5
landscapeTEST1 landscapeTEST2 landscapeTEST3 landscapeTEST4 landscapeTEST5
Landscapes have been generated using a T-tesselation algorithm. The format is a formal class 'SpatialPolygons' [package "sp"].
The landscape structure is simulated using a T-tessellation algorithm (Kiêu et al. 2013) in order to control specific features such as number, area and shape of the fields.
Kiêu K, Adamczyk-Chauvat K, Monod H, Stoica RS. A completely random T-tessellation model and Gibbsian extensions. Spat. Stat. 2013;6:118-38. doi: http://dx.doi.org/10.1016/j.spasta.2013.09.003.
library(sp) library(landsepi) landscapeTEST1 plot(landscapeTEST1)
library(sp) library(landsepi) landscapeTEST1 plot(landscapeTEST1)
Landsepi simulation parameters
An object of class LandsepiParams that can be created by calling createSimulParams
Landscape
a landscape as sf object. See loadLandscape
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 loadCroptypes
, setCroptypes
and allocateCroptypeCultivars
Cultivars
a dataframe of parameters associated with each host genotype (i.e. cultivars, lines)
when cultivated in pure crops.See loadCultivar
and setCultivars
CultivarsGenes
a list containing, for each host genotype, the indices of carried resistance genes.
See allocateCultivarGenes
Genes
a data.frame of parameters associated with each resistance gene and with the evolution of
each corresponding pathogenicity gene. See loadGene
and setGenes
Pathogen
a list of i. pathogen aggressiveness parameters on a susceptible host
for a pathogen genotype not adapted to resistance and ii. sexual reproduction parameters. See loadPathogen
and setPathogen
ReproSexProb
a vector of size TimeParam$nTSpY + 1 (end of season) of the probabilities for an infectious host to reproduce via sex rather than via cloning at each step.
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 setInoculum
DispHost
a vectorized matrix giving the probability of host dispersal
from any field of the landscape to any other field. See loadDispersalHost
and setDispersalHost
DispPathoClonal
a vectorized matrix giving the probability of pathogen dispersal (clonal propagules)
from any field of the landscape to any other field. See loadDispersalPathogen
and setDispersalPathogen
DispPathoSex
a vectorized matrix giving the probability of pathogen dispersal (sexual propagules)
from any field of the landscape to any other field. See loadDispersalPathogen
and setDispersalPathogen
Treatment
a list of parameters to simulate the effect of chemical treatments on the pathogen,
see loadTreatment
and setTreatment
OutputDir
the directory for simulation outputs
OutputGPKG
the name of the output GPKG file containing parameters of the deployment strategy
Outputs
a list of outputs parameters. See loadOutputs
and setOutputs
TimeParam
a list of time parameters. See setTime
Seed
an integer used as seed value (for random number generator). See setTime
Creates a data.frame containing croptype parameters and filled with 0
loadCroptypes(params, croptypeIDs = NULL, names = NULL)
loadCroptypes(params, croptypeIDs = NULL, names = NULL)
params |
a LandsepiParams Object. |
croptypeIDs |
a vector of indices of croptypes (must start at 0 and match with croptype IDs in the landscape) |
names |
a vector containing the names of all croptypes |
Croptypes need to be later updated with allocateCroptypeCultivars
.
If neither croptypeIDs nor names are given, it will automatically generate
1 croptype per cultivar.
a data.frame with croptype parameters
## Not run: simul_params <- createSimulParams() cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Mixture")) croptypes ## End(Not run)
## Not run: simul_params <- createSimulParams() cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Mixture")) croptypes ## End(Not run)
create a data.frame containing cultivar parameters depending of his type
loadCultivar(name, type = "wheat")
loadCultivar(name, type = "wheat")
name |
a character string (without space) specifying the cultivar name. |
type |
the cultivar type, among: "wheat" (default), "grapevine", "banana", "pepper" or "nonCrop". |
"wheat" is adapted to situations where the infection unit is a piece of leaf (e.g. where a fungal lesion can develop); the number of available infection units increasing during the season due to plant growth (as typified by cereal crops).
"grapevine" corresponds to parameters for grapevine (including host growth).
"banana" corresponds to parameters for banana (including host growth).
"pepper" corresponds to situations where the infection unit is the whole plant (e.g. for viral systemic infection); thus the number of infection units is constant.
"nonCrop" is not planted, does not cost anything and does not yield anything (e.g. forest, fallow).
a dataframe of parameters associated with each host genotype (i.e. cultivars, lines) when cultivated in pure crops.
c1 <- loadCultivar("winterWheat", type = "wheat") c1 c2 <- loadCultivar("forest", type = "nonCrop") c2
c1 <- loadCultivar("winterWheat", type = "wheat") c1 c2 <- loadCultivar("forest", type = "nonCrop") c2
It loads a vectorised diagonal matrix to simulate no host dispersal.
loadDispersalHost(params, type = "no")
loadDispersalHost(params, type = "no")
params |
a LandsepiParams Object. |
type |
a character string specifying the type of dispersal ("no" for no dispersal) |
as the size of the matrix depends on the number of polygons in the landscape,
the landscape must be defined before calling loadDispersalHost
.
a vectorised dispersal matrix.
## Not run: simul_params <- createSimulParams() simul_params <- setLandscape(simul_params, loadLandscape(1)) d <- loadDispersalHost(simul_params) d ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setLandscape(simul_params, loadLandscape(1)) d <- loadDispersalHost(simul_params) d ## End(Not run)
It loads one of the five built-in vectorised dispersal matrices of rust fungi associated with the five built-in landscapes. Landscape and DispersalPathogen ID must be the same. And set a vectorized identity matrix for sexual reproduction dispersal.
loadDispersalPathogen(id = 1)
loadDispersalPathogen(id = 1)
id |
a matrix ID between 1 to 5 (must match the ID of the landscape loaded with
|
landsepi includes built-in dispersal matrices to represent rust dispersal in the
five built-in landscapes. These have been computed from a power-law dispersal kernel:
with a=40 the scale parameter and b=7 a parameter related to the width of the dispersal kernel.
The expected mean dispersal distance is given by
.
a vectorised dispersal matrix representing the dispersal of clonal propagules, and a vectorised dispersal identity matrix for sexual propagules. All by columns.
d <- loadDispersalPathogen(1) d
d <- loadDispersalPathogen(1) d
Creates a data.frame containing parameters of a gene depending of his type
loadGene(name, type = "majorGene")
loadGene(name, type = "majorGene")
name |
name of the gene |
type |
type of the gene: "majorGene", "APR", "QTL" or "immunity" (default = "majorGene") |
"majorGene" means a completely efficient gene that can be broken down via a single pathogen mutation
"APR" means a major gene that is active only after a delay of 30 days after planting
"QTL" means a partial resistance (50% efficiency) that requires several pathogen mutations to be completely eroded
"immunity" means a completely efficient resistance that the pathogen has no way to adapt (i.e. the cultivar is non-host).
For different scenarios, the data.frame can be manually updated later.
a data.frame with gene parameters
gene1 <- loadGene(name = "MG 1", type = "majorGene") gene1 gene2 <- loadGene(name = "Lr34", type = "APR") gene2
gene1 <- loadGene(name = "MG 1", type = "majorGene") gene1 gene2 <- loadGene(name = "Lr34", type = "APR") gene2
Loads an inoculum for the beginning of the simulation (t=0), with controlled localisation (polygons), infected cultivars and pathogen genotypes. Note that landscape, gene, cultivar and croptype parameters must be set before loading the inoculum.
loadInoculum( params, pI0_all = NULL, pI0_host = NULL, pI0_patho = NULL, pI0_poly = NULL, pI0_mat = NULL )
loadInoculum( params, pI0_all = NULL, pI0_host = NULL, pI0_patho = NULL, pI0_poly = NULL, pI0_mat = NULL )
params |
a LandsepiParams object. |
pI0_all |
a numeric indicating the (same) probability to infect a host for all pathogen genotypes, all cultivars and in all polygons |
pI0_host |
a vector of length Nhost indicating the probabilities to infect an host, for each cultivar (for all pathogen genotypes and all polygons). |
pI0_patho |
a vector of length Npatho indicating the probabilities to infect an host, for each pathogen genotype (for all cultivars and all polygons). |
pI0_poly |
a vector of length Npoly indicating the probabilities to infect an host, for each polygon (for all pathogen genotypes and all cultivars). |
pI0_mat |
a 3D array of dimensions (1:Nhost,1:Npatho,1:Npoly) indicating the
probability to infect an host, for each cultivar, pathogen genotype and polygon.
Note that |
The different options enable different types of inoculum (localisation,
infected cultivars and pathogen genetic diversity,
see different options in Examples).
Unless the array pI0_mat
is filled, the probability for a host to be infected
at the beginning of the simulation is computed in every polygon (poly), cultivar (host)
and pathogen genotype (patho) with
pI0[host, patho, poly] = pI0_all * pI0_patho[patho] * pI0_host[host] * pI0_poly[poly]
.
Before loading the inoculum, one can use
getMatrixGenePatho()
, getMatrixCultivarPatho()
and getMatrixCroptypePatho()
to acknowledge which pathogen genotypes are adapted to which genes, cultivars and croptypes.
Once setInoculum()
is used, one can call inoculumToMatrix()
to get the inoculum
as a 3D array (1:Nhost,1:Npatho,1:Npoly)
a 3D array of dimensions (1:Nhost,1:Npatho,1:Npoly)
inoculumToMatrix, getMatrixGenePatho, getMatrixCultivarPatho, getMatrixCroptypePatho, setInoculum
## Not run: simul_params <- createSimulParams() simul_params <- setTime(simul_params, Nyears = 1, nTSpY = 80) basic_patho_param <- loadPathogen(disease = "rust") simul_params <- setPathogen(simul_params, patho_params = basic_patho_param) simul_params <- setLandscape(simul_params, loadLandscape(id = 1)) simul_params <- setDispersalPathogen(simul_params, loadDispersalPathogen(id = 1)[[1]]) gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) simul_params <- allocateCultivarGenes(simul_params, "Resistant", c("MG 1", "MG 2")) croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Resistant crop")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop", c("Resistant")) simul_params <- setCroptypes(simul_params, croptypes) simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = 0 , rotation_sequence = croptypes$croptypeID , prop = c(1/2,1/2), aggreg = 1, graphic = FALSE) #### Definition of the inoculum #### ### Scenario 1. Only the avirulent pathogen on the susceptible cultivar ### # In this situation, the susceptible cultivar must be entered # at the first line of the table cultivars ## Global inoculum (i.e. in the whole landscape) # Option 1: simply use the default parameterisation simul_params <- setInoculum(simul_params, 5E-4) # Option 2: use loadInoculum() Npatho <- prod(simul_params@Genes$Nlevels_aggressiveness) Nhost <- nrow(simul_params@Cultivars) pI0 <- loadInoculum(simul_params, pI0_all=5E-4, pI0_host=c(1,rep(0, Nhost-1)), pI0_patho=c(1,rep(0, Npatho-1))) simul_params <- setInoculum(simul_params, pI0) inoculumToMatrix(simul_params) ## Local inoculum (i.e. in some random polygons only) Npatho <- prod(simul_params@Genes$Nlevels_aggressiveness) Nhost <- nrow(simul_params@Cultivars) Npoly <- nrow(simul_params@Landscape) Npoly_inoc <- 5 ## number of inoculated polygons ## whether the avr pathogen can infect the polygons compatible_poly <- getMatrixPolyPatho(simul_params)[,1] ## random polygon picked among compatible ones id_poly <- sample(grep(1, compatible_poly), Npoly_inoc) pI0_poly <- as.numeric(1:Npoly %in% id_poly) pI0 <- loadInoculum(simul_params, pI0_all=5E-4, pI0_host=c(1,rep(0, Nhost-1)), pI0_patho=c(1,rep(0, Npatho-1)), pI0_poly=pI0_poly) simul_params <- setInoculum(simul_params, pI0) inoculumToMatrix(simul_params) ### Scenario 2. Diversity of pathogen genotypes in the inoculum ### # in this example, Nhost=2 cultivars, Npatho=4 ## Global inoculum (i.e. in all polygons of the landscape) pI0 <- loadInoculum(simul_params, pI0_patho=c(1E-3,1E-4,1E-4,1E-5), pI0_host=c(1,1)) simul_params <- setInoculum(simul_params, pI0) inoculumToMatrix(simul_params)[,,1:5] ## Local inoculum (i.e. in some polygons only) ## Npoly <- nrow(simul_params@Landscape) Npoly_inoc <- 5 ## number of inoculated polygons id_poly <- sample(1:Npoly, Npoly_inoc) ## random polygon pI0_poly <- as.numeric(1:Npoly %in% id_poly) pI0 <- loadInoculum(simul_params, pI0_patho=c(1E-3,1E-4,1E-4,1E-5), pI0_host=c(1,1), pI0_poly=pI0_poly) simul_params <- setInoculum(simul_params, pI0) inoculumToMatrix(simul_params) ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setTime(simul_params, Nyears = 1, nTSpY = 80) basic_patho_param <- loadPathogen(disease = "rust") simul_params <- setPathogen(simul_params, patho_params = basic_patho_param) simul_params <- setLandscape(simul_params, loadLandscape(id = 1)) simul_params <- setDispersalPathogen(simul_params, loadDispersalPathogen(id = 1)[[1]]) gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) simul_params <- allocateCultivarGenes(simul_params, "Resistant", c("MG 1", "MG 2")) croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Resistant crop")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop", c("Resistant")) simul_params <- setCroptypes(simul_params, croptypes) simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = 0 , rotation_sequence = croptypes$croptypeID , prop = c(1/2,1/2), aggreg = 1, graphic = FALSE) #### Definition of the inoculum #### ### Scenario 1. Only the avirulent pathogen on the susceptible cultivar ### # In this situation, the susceptible cultivar must be entered # at the first line of the table cultivars ## Global inoculum (i.e. in the whole landscape) # Option 1: simply use the default parameterisation simul_params <- setInoculum(simul_params, 5E-4) # Option 2: use loadInoculum() Npatho <- prod(simul_params@Genes$Nlevels_aggressiveness) Nhost <- nrow(simul_params@Cultivars) pI0 <- loadInoculum(simul_params, pI0_all=5E-4, pI0_host=c(1,rep(0, Nhost-1)), pI0_patho=c(1,rep(0, Npatho-1))) simul_params <- setInoculum(simul_params, pI0) inoculumToMatrix(simul_params) ## Local inoculum (i.e. in some random polygons only) Npatho <- prod(simul_params@Genes$Nlevels_aggressiveness) Nhost <- nrow(simul_params@Cultivars) Npoly <- nrow(simul_params@Landscape) Npoly_inoc <- 5 ## number of inoculated polygons ## whether the avr pathogen can infect the polygons compatible_poly <- getMatrixPolyPatho(simul_params)[,1] ## random polygon picked among compatible ones id_poly <- sample(grep(1, compatible_poly), Npoly_inoc) pI0_poly <- as.numeric(1:Npoly %in% id_poly) pI0 <- loadInoculum(simul_params, pI0_all=5E-4, pI0_host=c(1,rep(0, Nhost-1)), pI0_patho=c(1,rep(0, Npatho-1)), pI0_poly=pI0_poly) simul_params <- setInoculum(simul_params, pI0) inoculumToMatrix(simul_params) ### Scenario 2. Diversity of pathogen genotypes in the inoculum ### # in this example, Nhost=2 cultivars, Npatho=4 ## Global inoculum (i.e. in all polygons of the landscape) pI0 <- loadInoculum(simul_params, pI0_patho=c(1E-3,1E-4,1E-4,1E-5), pI0_host=c(1,1)) simul_params <- setInoculum(simul_params, pI0) inoculumToMatrix(simul_params)[,,1:5] ## Local inoculum (i.e. in some polygons only) ## Npoly <- nrow(simul_params@Landscape) Npoly_inoc <- 5 ## number of inoculated polygons id_poly <- sample(1:Npoly, Npoly_inoc) ## random polygon pI0_poly <- as.numeric(1:Npoly %in% id_poly) pI0 <- loadInoculum(simul_params, pI0_patho=c(1E-3,1E-4,1E-4,1E-5), pI0_host=c(1,1), pI0_poly=pI0_poly) simul_params <- setInoculum(simul_params, pI0) inoculumToMatrix(simul_params) ## End(Not run)
Loads one of the five built-in landscapes simulated using a T-tesselation algorithm and composed of 155, 154, 152, 153 and 156 polygons, respectively. Each landscape is identified by a numeric from 1 to 5.
loadLandscape(id = 1)
loadLandscape(id = 1)
id |
a landscape ID between 1 to 5 (default = 1) |
a landscape in sp format
land <- loadLandscape(1) length(land)
land <- loadLandscape(1) length(land)
Creates an output list
loadOutputs(epid_outputs = "all", evol_outputs = "all", disease = "rust")
loadOutputs(epid_outputs = "all", evol_outputs = "all", disease = "rust")
epid_outputs |
a character string (or a vector of character strings if several outputs are to be computed) specifying the type of epidemiological and economic outputs to generate (see details):
|
evol_outputs |
a character string (or a vector of character strings if several outputs are to be computed) specifying the type of evolutionary outputs to generate :
|
disease |
a disease name, among "rust" (default), "mildew", "sigatoka" and "no pathogen" |
a list of outputs and parameters for output generation
outputList <- loadOutputs(epid_outputs = "audpc", evol_outputs = "durability") outputList
outputList <- loadOutputs(epid_outputs = "audpc", evol_outputs = "durability") outputList
Loads default pathogen parameters for a specific disease
loadPathogen(disease = "rust")
loadPathogen(disease = "rust")
disease |
a disease name, among "rust" (default), "mildew", "sigatoka" and "no pathogen" |
Available diseases:
"no pathogen"
"rust" (genus Puccinia, e.g. stripe rust, stem rust and leaf rust of wheat and barley)
"mildew" (Plasmopara viticola, downy mildew of grapevine)
"sigatoka" (Pseudocercospora fijiensis, black sigatoka of banana) Note that when disease = "mildew" a price reduction between 0% and 5% is applied to the market value according to disease severity.
a list of pathogen parameters on a susceptible host for a pathogen genotype not adapted to resistance
basic_patho_params <- loadPathogen() basic_patho_params
basic_patho_params <- loadPathogen() basic_patho_params
Loads a GPKG file from the output of a landsepi simulation.
loadSimulParams(inputGPKG = "")
loadSimulParams(inputGPKG = "")
inputGPKG |
name of the GPKG file. |
a LandsepiParams object.
Loads a list of treatment parameters for a specific disease (initialised at 0 , i.e. absence of treatments)
loadTreatment(disease = "no pathogen")
loadTreatment(disease = "no pathogen")
disease |
a disease name, among "mildew", "sigatoka" and "no pathogen" |
Chemical treatment is applied in a polygon only if disease severity (i.e. I/N) in
this polygon exceeds the threshold given by treatment_application_threshold
.
Treatment efficiency is maximum (i.e. equal to the parameter treatment_efficiency)
at the time of treatment application (noted ); then it decreases with time
(i.e. natural pesticide degradation) and host growth (i.e. new biomass is not protected
by treatments): protected by treatments):Efficiency of the treatment at time t after the application date is given by:
with
:
is the reduction of
fungicide concentration due to time (e.g. natural degradation, volatilization, weathering),
with
the timelag passed since the time of
treatment application.
is the reduction of fungicide concentration due
to plant growth, since new plant tissue is not covered by fungicide.
and
being the number of
host individuals a the time of treatment
and at time
, respectively.
and
are shape parameters.
a list of treatment parameters:
treatment_degradation_rate = degradation rate (per time step) of chemical concentration,
treatment_efficiency = maximal efficiency of chemical treatments (i.e. fractional reduction of pathogen infection rate at the time of application),
treatment_timesteps = vector of time steps corresponding to treatment application dates,
treatment_cultivars = vector of indices of the cultivars that receive treatments,
treatment_cost = cost of a single treatment application (monetary units/ha)
treatment_application_threshold = vector of thresholds (i.e. disease severity, one for each treated cultivar) above which the treatment is applied in a polygon.
treat <- loadTreatment("sigatoka") treat
treat <- loadTreatment("sigatoka") treat
Given a numeric object, return the logit of the values. Missing values (NAs) are allowed.
logit(x)
logit(x)
x |
a numeric object containing values between 0 and 1 |
The logit is defined by . Values in x of 0 or 1 return logits of -Inf or Inf respectively.
Any NAs in the input will also be NAs in the output.
An object of the same type as x containing the logits of the input values.
logit(0.5)
logit(0.5)
Stochastic, spatially-explicit, demo-genetic model simulating the spread and evolution of a plant pathogen in a heterogeneous landscape.
model_landsepi( time_param, area_vector, rotation_matrix, croptypes_cultivars_prop, dispersal, inits, seed, cultivars_param, basic_patho_param, genes_param, treatment_param )
model_landsepi( time_param, area_vector, rotation_matrix, croptypes_cultivars_prop, dispersal, inits, seed, cultivars_param, basic_patho_param, genes_param, treatment_param )
time_param |
list of simulation parameters:
|
area_vector |
a vector containing areas of polygons (i.e. fields), in surface units. |
rotation_matrix |
a matrix containing for each field (rows) and year (columns, named "year_1", "year_2", etc.), the index of the cultivated croptype. Importantly, the matrix must contain 1 more column than the real number of simulated years. |
croptypes_cultivars_prop |
a matrix with three columns named 'croptypeID' for croptype index, 'cultivarID' for cultivar index and 'proportion' for the proportion of the cultivar within the croptype. |
dispersal |
list of dispersal parameters:
|
inits |
list of initial conditions:
|
seed |
seed (for random number generation). |
cultivars_param |
list of parameters associated with each host genotype (i.e. cultivars) when cultivated in pure crops:
|
basic_patho_param |
list of i. pathogen aggressiveness parameters on a susceptible host for a pathogen genotype not adapted to resistance and ii. sexual reproduction parameters:
|
genes_param |
list of parameters associated with each resistance gene and with the evolution of each corresponding pathogenicity gene:
|
treatment_param |
list of parameters related to pesticide treatments:
|
See ?landsepi
for details on the model and assumptions.
Briefly, the model is stochastic, spatially explicit (the basic spatial unit is an individual field), based on a SEIR
(‘susceptible-exposed-infectious-removed’, renamed HLIR for 'healthy-latent-infectious-removed' to avoid confusions
with 'susceptible host') structure with a discrete time step. It simulates the spread and
evolution (via mutation, recombination through sexual reproduction, selection and drift)
of a pathogen in a heterogeneous cropping landscape, across cropping seasons split by host harvests which impose
potential bottlenecks to the pathogen. A wide array of resistance deployment strategies
(possibly including chemical treatments) can be simulated.
A set of binary files is generated for every year of simulation and every compartment:
H: healthy hosts,
Hjuv: juvenile healthy hosts (for host reproduction),
L: latently infected hosts,
I: infectious hosts,
R: removed hosts,
P: propagules.
Each file indicates for every time-step the number of individuals in each field, and when appropriate for each host and pathogen genotypes). Additionally, a binary file called TFI is generated and gives the Treatment Frequency Indicator (expressed as the number of treatment applications per polygon).
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. PLoS Computational Biology 14(4):e1006067.
## Not run: #### Spatially-implicit simulation with 2 patches (S + R) during 3 years #### ## Simulation parameters time_param <- list(Nyears=3, nTSpY=120) Npoly=2 Npatho=2 area <- c(100000, 100000) basic_patho_param <- loadPathogen(disease = "rust") basic_patho_param$repro_sex_prob <- rep(0, time_param$nTSpY+1) cultivars <- as.list(rbind(loadCultivar(name="Susceptible", type="growingHost") , loadCultivar(name="Resistant", type="growingHost"))) names(cultivars)[names(cultivars)=="cultivarName"] <- "name" yield0 <- cultivars$yield_H + as.numeric(cultivars$yield_H==0) cultivars <- c(cultivars, list(relative_yield_H = as.numeric(cultivars$yield_H / yield0) , relative_yield_L = as.numeric(cultivars$yield_L / yield0) , relative_yield_I = as.numeric(cultivars$yield_I / yield0) , relative_yield_R = as.numeric(cultivars$yield_R / yield0) , sigmoid_kappa_host=0.002, sigmoid_sigma_host=1.001, sigmoid_plateau_host=1 , cultivars_genes_list=list(numeric(0),0))) rotation <- data.frame(year_1=c(0,1), year_2=c(0,1), year_3=c(0,1), year_4=c(0,1)) croptypes_cultivars_prop <- data.frame(croptypeID=c(0,1), cultivarID=c(0,1), proportion=c(1,1)) genes <- as.list(loadGene(name="MG", type="majorGene")) treatment=list(treatment_degradation_rate=0.1, treatment_efficiency=0, treatment_timesteps=logical(0), treatment_cultivars=logical(0), treatment_cost=0, treatment_application_threshold = logical(0)) ## run simulation model_landsepi(seed=1, time_param = time_param, basic_patho_param = basic_patho_param, inits = list(pI0=c(0.1, rep(0, 7))), area_vector = area, dispersal = list(disp_patho_clonal=c(0.99,0.01,0.01,0.99), disp_patho_sex=c(1,0,0,1), disp_host=c(1,0,0,1)), rotation_matrix = as.matrix(rotation), croptypes_cultivars_prop = as.matrix(croptypes_cultivars_prop), cultivars_param = cultivars, genes_param = genes, treatment_param = treatment) ## Compute outputs eco_param <- list(yield_perHa = cbind(H = as.numeric(cultivars$relative_yield_H), L = as.numeric(cultivars$relative_yield_L), I = as.numeric(cultivars$relative_yield_I), R = as.numeric(cultivars$relative_yield_R)), planting_cost_perHa = as.numeric(cultivars$planting_cost), market_value = as.numeric(cultivars$market_value)) evol_res <- evol_output(, time_param, Npoly, cultivars, genes) epid_res <- epid_output(, time_param, Npatho, area, rotation , croptypes_cultivars_prop, cultivars, eco_param, treatment, basic_patho_param) #### 1-year simulation of a rust epidemic in pure susceptible crop in a single 1-km2 patch #### ## Simulation and pathogen parameters time_param <- list(Nyears=1, nTSpY=120) area <- c(1E6) basic_patho_param = loadPathogen(disease = "rust") basic_patho_param$repro_sex_prob <- rep(0, time_param$nTSpY+1) ## croptypes, cultivars and genes rotation <- data.frame(year_1=c(0), year_2=c(0)) croptypes_cultivars_prop <- data.frame(croptypeID=c(0), cultivarID=c(0), proportion=c(1)) cultivars <- as.list(rbind(loadCultivar(name="Susceptible", type="growingHost"))) names(cultivars)[names(cultivars)=="cultivarName"] <- "name" yield0 <- cultivars$yield_H + as.numeric(cultivars$yield_H==0) cultivars <- c(cultivars, list(relative_yield_H = as.numeric(cultivars$yield_H / yield0) , relative_yield_L = as.numeric(cultivars$yield_L / yield0) , relative_yield_I = as.numeric(cultivars$yield_I / yield0) , relative_yield_R = as.numeric(cultivars$yield_R / yield0) , sigmoid_kappa_host=0.002, sigmoid_sigma_host=1.001, sigmoid_plateau_host=1 , cultivars_genes_list=list(numeric(0)))) genes <- list(geneName = character(0) , adaptation_cost = numeric(0) , relative_advantage = numeric(0) , mutation_prob = numeric(0) , efficiency = numeric(0) , tradeoff_strength = numeric(0) , Nlevels_aggressiveness = numeric(0) , age_of_activ_mean = numeric(0) , age_of_activ_var = numeric(0) , target_trait = character(0) , recombination_sd = numeric(0)) treatment=list(treatment_degradation_rate=0.1 , treatment_efficiency=0 , treatment_timesteps=logical(0) , treatment_cultivars=logical(0) , treatment_cost=0 , treatment_application_threshold = logical(0)) ## run simulation model_landsepi(seed=1, time_param = time_param , basic_patho_param = basic_patho_param , inits = list(pI0=5E-4), area_vector = area , dispersal = list(disp_patho_clonal=c(1), disp_patho_sex=c(1), disp_host=c(1)) , rotation_matrix = as.matrix(rotation) , treatment_param = treatment , croptypes_cultivars_prop = as.matrix(croptypes_cultivars_prop) , cultivars_param = cultivars, genes_param = genes) ## End(Not run)
## Not run: #### Spatially-implicit simulation with 2 patches (S + R) during 3 years #### ## Simulation parameters time_param <- list(Nyears=3, nTSpY=120) Npoly=2 Npatho=2 area <- c(100000, 100000) basic_patho_param <- loadPathogen(disease = "rust") basic_patho_param$repro_sex_prob <- rep(0, time_param$nTSpY+1) cultivars <- as.list(rbind(loadCultivar(name="Susceptible", type="growingHost") , loadCultivar(name="Resistant", type="growingHost"))) names(cultivars)[names(cultivars)=="cultivarName"] <- "name" yield0 <- cultivars$yield_H + as.numeric(cultivars$yield_H==0) cultivars <- c(cultivars, list(relative_yield_H = as.numeric(cultivars$yield_H / yield0) , relative_yield_L = as.numeric(cultivars$yield_L / yield0) , relative_yield_I = as.numeric(cultivars$yield_I / yield0) , relative_yield_R = as.numeric(cultivars$yield_R / yield0) , sigmoid_kappa_host=0.002, sigmoid_sigma_host=1.001, sigmoid_plateau_host=1 , cultivars_genes_list=list(numeric(0),0))) rotation <- data.frame(year_1=c(0,1), year_2=c(0,1), year_3=c(0,1), year_4=c(0,1)) croptypes_cultivars_prop <- data.frame(croptypeID=c(0,1), cultivarID=c(0,1), proportion=c(1,1)) genes <- as.list(loadGene(name="MG", type="majorGene")) treatment=list(treatment_degradation_rate=0.1, treatment_efficiency=0, treatment_timesteps=logical(0), treatment_cultivars=logical(0), treatment_cost=0, treatment_application_threshold = logical(0)) ## run simulation model_landsepi(seed=1, time_param = time_param, basic_patho_param = basic_patho_param, inits = list(pI0=c(0.1, rep(0, 7))), area_vector = area, dispersal = list(disp_patho_clonal=c(0.99,0.01,0.01,0.99), disp_patho_sex=c(1,0,0,1), disp_host=c(1,0,0,1)), rotation_matrix = as.matrix(rotation), croptypes_cultivars_prop = as.matrix(croptypes_cultivars_prop), cultivars_param = cultivars, genes_param = genes, treatment_param = treatment) ## Compute outputs eco_param <- list(yield_perHa = cbind(H = as.numeric(cultivars$relative_yield_H), L = as.numeric(cultivars$relative_yield_L), I = as.numeric(cultivars$relative_yield_I), R = as.numeric(cultivars$relative_yield_R)), planting_cost_perHa = as.numeric(cultivars$planting_cost), market_value = as.numeric(cultivars$market_value)) evol_res <- evol_output(, time_param, Npoly, cultivars, genes) epid_res <- epid_output(, time_param, Npatho, area, rotation , croptypes_cultivars_prop, cultivars, eco_param, treatment, basic_patho_param) #### 1-year simulation of a rust epidemic in pure susceptible crop in a single 1-km2 patch #### ## Simulation and pathogen parameters time_param <- list(Nyears=1, nTSpY=120) area <- c(1E6) basic_patho_param = loadPathogen(disease = "rust") basic_patho_param$repro_sex_prob <- rep(0, time_param$nTSpY+1) ## croptypes, cultivars and genes rotation <- data.frame(year_1=c(0), year_2=c(0)) croptypes_cultivars_prop <- data.frame(croptypeID=c(0), cultivarID=c(0), proportion=c(1)) cultivars <- as.list(rbind(loadCultivar(name="Susceptible", type="growingHost"))) names(cultivars)[names(cultivars)=="cultivarName"] <- "name" yield0 <- cultivars$yield_H + as.numeric(cultivars$yield_H==0) cultivars <- c(cultivars, list(relative_yield_H = as.numeric(cultivars$yield_H / yield0) , relative_yield_L = as.numeric(cultivars$yield_L / yield0) , relative_yield_I = as.numeric(cultivars$yield_I / yield0) , relative_yield_R = as.numeric(cultivars$yield_R / yield0) , sigmoid_kappa_host=0.002, sigmoid_sigma_host=1.001, sigmoid_plateau_host=1 , cultivars_genes_list=list(numeric(0)))) genes <- list(geneName = character(0) , adaptation_cost = numeric(0) , relative_advantage = numeric(0) , mutation_prob = numeric(0) , efficiency = numeric(0) , tradeoff_strength = numeric(0) , Nlevels_aggressiveness = numeric(0) , age_of_activ_mean = numeric(0) , age_of_activ_var = numeric(0) , target_trait = character(0) , recombination_sd = numeric(0)) treatment=list(treatment_degradation_rate=0.1 , treatment_efficiency=0 , treatment_timesteps=logical(0) , treatment_cultivars=logical(0) , treatment_cost=0 , treatment_application_threshold = logical(0)) ## run simulation model_landsepi(seed=1, time_param = time_param , basic_patho_param = basic_patho_param , inits = list(pI0=5E-4), area_vector = area , dispersal = list(disp_patho_clonal=c(1), disp_patho_sex=c(1), disp_host=c(1)) , rotation_matrix = as.matrix(rotation) , treatment_param = treatment , croptypes_cultivars_prop = as.matrix(croptypes_cultivars_prop) , cultivars_param = cultivars, genes_param = genes) ## End(Not run)
Algorithm based on latent Gaussian fields to allocate two different types of crops across a landscape.
multiN(d, area, prop, range = 0, algo = "random")
multiN(d, area, prop, range = 0, algo = "random")
d |
a symmetric matrix of the pairwise distances between the centroids of the fields of the landscape. |
area |
vector containing field areas. |
prop |
proportion of landscape surface covered by the second type of crop. |
range |
range of spatial autocorrelation between fields (must be greater or equal 0). The greater the value of range, the higher the degree of spatial aggregation (roughly, range between 0 and 0.1 for fragmented landscapes, between 0.1 and 0.5 for balanced landscapes, between 0.5 and 3 for aggregated landscapes, and above 3 for highly aggregated landscapes). |
algo |
the algorithm used for the computation of the variance-covariance matrix of the multivariate normal distribution: "exp" for exponential function, "periodic" for periodic function, "random" for random draw (see details). If algo="random", the parameter range is ignored. |
This algorithm allows the control of the proportions of each type of crop in terms of surface coverage, and their level of spatial aggregation. A random vector of values is drawn from a multivariate normal distribution with expectation 0 and a variance-covariance matrix which depends on the pairwise distances between the centroids of the fields. Two different functions allow the computation of the variance-covariance matrix to allocate crops with more or less spatial aggregation (depending on the value of the range parameter). The exponential function codes for an exponential decay of the spatial autocorrelation as distance between fields increases. The periodic function codes for a periodic fluctuation of the spatial autocorrelation as distance between fields increases. Alternatively, a normal distribution can be used for a random allocation of the types of crops. Next, the two types of crops are allocated to different fields depending on whether the value drawn from the multivariate normal distribution is above or below a threshold. The proportion of each type of crop in the landscape is controlled by the value of this threshold (parameter prop).
A dataframe containing the index of each field (column 1) and the index (0 or 1) of the type of crop grown on these fields (column 2).
AgriLand, allocateLandscapeCroptypes
## Not run: d <- matrix(rpois(100, 100), nrow = 10) d <- d + t(d) ## ensures that d is symmetric area <- data.frame(id = 1:10, area = 10) multiN(d, area, prop = 0.5, range = 0.5, algo = "periodic") ## End(Not run)
## Not run: d <- matrix(rpois(100, 100), nrow = 10) d <- d + t(d) ## ensures that d is symmetric area <- data.frame(id = 1:10, area = 10) multiN(d, area, prop = 0.5, range = 0.5, algo = "periodic") ## End(Not run)
Periodic function used to compute the variance-covariance matrix of the fields of the landscape.
periodic_cov(d, range, phi = 1)
periodic_cov(d, range, phi = 1)
d |
a numeric object containing pairwise distances between the centroids of the fields |
range |
range (half-period of oscillations) |
phi |
amplitude of the oscillations |
The periodic covariance is defined by . It is used to generate
highly fragmented or highly aggregated landscapes.
An object of the same type as d.
periodic_cov(10, range = 5)
periodic_cov(10, range = 5)
Plots croptype allocation in the landscape at a given year of the simulation
plot_allocation( landscape, year, croptype_names = c(), title = "", subtitle = "", filename = "landscape.png" )
plot_allocation( landscape, year, croptype_names = c(), title = "", subtitle = "", filename = "landscape.png" )
landscape |
a SpatialPolygonsDataFrame |
year |
year to be plotted |
croptype_names |
croptype names (for legend) |
title |
title of the graphic |
subtitle |
subtitle of the graphic |
filename |
name of the .png file to be generated |
a png file.
## Not run: landscape <- landscapeTEST1 croptypes <- data.frame(sample.int(3, length(landscape), replace = TRUE)) allocation <- SpatialPolygonsDataFrame(landscape, croptypes, match.ID = TRUE) plot_allocation(allocation, 1, title = "Simulated landscape", subtitle = "Year 1", filename = paste(getwd(), "/landscape.png", sep = "") ) ## End(Not run)
## Not run: landscape <- landscapeTEST1 croptypes <- data.frame(sample.int(3, length(landscape), replace = TRUE)) allocation <- SpatialPolygonsDataFrame(landscape, croptypes, match.ID = TRUE) plot_allocation(allocation, 1, title = "Simulated landscape", subtitle = "Year 1", filename = paste(getwd(), "/landscape.png", sep = "") ) ## End(Not run)
Plots in a .tiff file the dynamics of pathotype frequencies with respect to pathogen adaptation to a specific resistance gene.
plot_freqPatho( name_gene, Nlevels_aggressiveness, I_aggrProp, nTS, Nyears, nTSpY )
plot_freqPatho( name_gene, Nlevels_aggressiveness, I_aggrProp, nTS, Nyears, nTSpY )
name_gene |
a string specifying the name of the gene under investigation |
Nlevels_aggressiveness |
number of pathotypes with respect to the gene under investigation |
I_aggrProp |
a matrix giving the frequency of every pathotype (rows) for every time-step (columns) |
nTS |
number of simulated time-steps |
Nyears |
number of simulated cropping seasons |
nTSpY |
number of time-steps per cropping season |
## Not run: freqMatrix <- matrix(0, nrow = 2, ncol = 100) freqMatrix[2, 26:100] <- (26:100) / 100 freqMatrix[1, ] <- 1 - freqMatrix[2, ] plot_freqPatho( index_gene = 1, Nlevels_aggressiveness = 2, freqMatrix, nTS = 100, Nyears = 10, nTSpY = 10 ) ## End(Not run)
## Not run: freqMatrix <- matrix(0, nrow = 2, ncol = 100) freqMatrix[2, 26:100] <- (26:100) / 100 freqMatrix[1, ] <- 1 - freqMatrix[2, ] plot_freqPatho( index_gene = 1, Nlevels_aggressiveness = 2, freqMatrix, nTS = 100, Nyears = 10, nTSpY = 10 ) ## End(Not run)
Plots a landscape with colors or hatched lines to represent different types of fields
plotland( 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 = "" )
plotland( 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 = "" )
landscape |
a spatialpolygon object containing field coordinates |
COL |
vector containing the color of each field |
DENS |
vector containing the density of hatched lines for each field |
ANGLE |
vector containing the angle of hatched lines for each field |
COL.LEG |
vector containing the colors in the first legend |
DENS.LEG |
vector containing the density of hatched lines in the second legend |
ANGLE.LEG |
vector containing the angle of hatched lines in the second legend |
TITLE |
title of the graphic |
SUBTITLE |
subtitle of the graphic |
LEGEND1 |
labels in the first legend (colors) |
LEGEND2 |
labels in the second legend (hatched lines) |
TITLE.LEG2 |
title for the second legend |
## Not run: ## Draw a landscape with various colours landscapeTEST1 plotland(landscapeTEST1, COL = 1:length(landscapeTEST1), DENS = rep(0, length(landscapeTEST1)), ANGLE = rep(30, length(landscapeTEST1)) ) ## End(Not run)
## Not run: ## Draw a landscape with various colours landscapeTEST1 plotland(landscapeTEST1, COL = 1:length(landscapeTEST1), DENS = rep(0, length(landscapeTEST1)), ANGLE = rep(30, length(landscapeTEST1)) ) ## End(Not run)
Give the price reduction rate associated with the infection on the (grapevine) fruits
price_reduction( I_host, N_host, Nhost, Nyears, nTSpY, severity_thresh = 0.075, price_penalty = 0.3 )
price_reduction( I_host, N_host, Nhost, Nyears, nTSpY, severity_thresh = 0.075, price_penalty = 0.3 )
I_host |
number of infected individuals for each cultivar and timestep |
N_host |
total number of individuals for each cultivar and timestep |
Nhost |
total number of cultivars considered in the simulation |
Nyears |
number of simulated cropping seasons |
nTSpY |
number of timesteps (e.g. days) per cropping season |
severity_thresh |
disease severity threshold above which the price reduction is applied |
price_penalty |
percentage of price reduction |
A matrix with the price reduction rate per cultivar and per year of simulation
Savary, S., Delbac, L., Rochas, A., Taisant, G., & Willocquet, L. (2009). Analysis of nonlinear relationships in dual epidemics, and its application to the management of grapevine downy and powdery mildews. Phytopathology, 99(8), 930-942.
Prints a LandsepiParams object.
## S4 method for signature 'LandsepiParams' print(x, ...)
## S4 method for signature 'LandsepiParams' print(x, ...)
x |
a LandsepiParams object |
... |
print options |
Resets the lists of genes carried by all cultivars
resetCultivarsGenes(params)
resetCultivarsGenes(params)
params |
a LandsepiParams object. |
a LandsepiParams object
Launches landsepi shiny application into browser
runShinyApp()
runShinyApp()
R packages needed to run the shiny app : install.packages(c("shiny","DT", "shinyjs", "gridExtra", "png", "grid", "future", "promises", "tools"))
Runs a simulation with landsepi, a stochastic, spatially-explicit, demo-genetic model simulating the spread and evolution of a pathogen in a heterogeneous landscape and generating a wide range of epidemiological, evolutionary and economic outputs.
runSimul( params, graphic = TRUE, writeTXT = TRUE, videoMP4 = FALSE, keepRawResults = FALSE )
runSimul( params, graphic = TRUE, writeTXT = TRUE, videoMP4 = FALSE, keepRawResults = FALSE )
params |
a LandsepiParams Object containing all simulation parameters. Must be initialised
with |
graphic |
a logical indicating if graphics must be generated (TRUE, default) or not (FALSE). |
writeTXT |
a logical indicating if outputs must be written in text files (TRUE, default) or not (FALSE). |
videoMP4 |
a logical indicating if a video must be generated (TRUE) or not (FALSE, default). Works only if graphic=TRUE and audpc_rel is computed. |
keepRawResults |
a logical indicating if binary files must be kept after the end of the simulation (default=FALSE). Careful, many files may be generated if keepRawResults=TRUE. |
See ?landsepi
for details on the model, assumptions and outputs, and our
vignettes for tutorials (browseVignettes("landsepi")
). The function runs the model
simulation using a LandsepiParams object.
Briefly, the model is stochastic, spatially explicit (the basic spatial unit is an
individual field or polygon), based on a SEIR (‘susceptible-exposed-infectious-removed’,
renamed HLIR for 'healthy-latent-infectious-removed' to avoid confusions with 'susceptible host')
structure with a discrete time step. It simulates the spread and
evolution (via mutation, recombination through sexual reproduction, selection and drift)
of a pathogen in a heterogeneous cropping landscape, across cropping seasons split
by host harvests which impose potential bottlenecks to the pathogen. A wide array of
resistance deployment strategies (possibly including chemical treatments)
can be simulated and evaluated using several possible
outputs to assess the epidemiological, evolutionary and economic performance
of deployment strategies.
A list containing all required outputs. A set of text files, graphics and a video showing epidemic dynamics can be generated. If keepRawResults=TRUE, a set of binary files is generated for every year of simulation and every compartment:
H: healthy hosts,
Hjuv: juvenile healthy hosts (for host reproduction),
L: latently infected hosts,
I: infectious hosts,
R: removed hosts,
P: propagules.
Each file indicates for every time step the number of individuals in each polygon, and when appropriate for each host and pathogen genotype. Additionally, a binary file called TFI is generated and gives the Treatment Frequency Indicator (expressed as the number of treatment applications per polygon).
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. PLoS Computational Biology 14(4):e1006067.
## Not run: ### Here is an example of simulation of a mosaic of three cultivars (S + R1 + R2). ## See our tutorials for more examples. ## Initialisation simul_params <- createSimulParams(outputDir = getwd()) ## Seed & Time parameters simul_params <- setSeed(simul_params, seed = 1) simul_params <- setTime(simul_params, Nyears = 10, nTSpY = 120) ## Pathogen parameters simul_params <- setPathogen(simul_params, loadPathogen("rust")) ## Landscape & dispersal simul_params <- setLandscape(simul_params, loadLandscape(1)) simul_params <- setDispersalPathogen(simul_params, loadDispersalPathogen[[1]]) ## Genes gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) ## Cultivars cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) ## Allocate genes to cultivars simul_params <- allocateCultivarGenes(simul_params, "Resistant1", c("MG 1")) simul_params <- allocateCultivarGenes(simul_params, "Resistant2", c("MG 2")) ## Allocate cultivars to croptypes croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Resistant crop 1", "Resistant crop 2")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 1", "Resistant1") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 2", "Resistant2") simul_params <- setCroptypes(simul_params, croptypes) ## Allocate croptypes to landscape rotation_sequence <- croptypes$croptypeID ## No rotation => 1 rotation_sequence element rotation_period <- 0 ## same croptypes every years prop <- c(1 / 3, 1 / 3, 1 / 3) ## croptypes proportions aggreg <- 10 ## aggregated landscape simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = rotation_period, rotation_sequence = rotation_sequence, rotation_realloc = FALSE, prop = prop, aggreg = aggreg) ## Set the inoculum simul_params <- setInoculum(simul_params, 5e-4) ## list of outputs to be generated simul_params <- setOutputs(simul_params, loadOutputs()) ## Check simulation parameters checkSimulParams(simul_params) ## Save deployment strategy into GPKG file simul_params <- saveDeploymentStrategy(simul_params) ## Run simulation runSimul(simul_params) ### Simulation of rust epidemics in a 1-km^2 patch cultivated ### with a susceptible wheat cultivar seed=10 Nyears=5 disease="rust" hostType="wheat" simul_params <- createSimulParams(outputDir = getwd()) ## Seed and time parameters simul_params <- setSeed(simul_params, seed) simul_params <- setTime(simul_params, Nyears, nTSpY=120) ## Pathogen parameters simul_params <- setPathogen(simul_params, loadPathogen(disease)) myLand <- Polygons(list(Polygon(matrix(c(0,0,1,1,0,1,1,0)*1000, nrow=4))), "ID1") myLand <- SpatialPolygons(list(myLand)) simul_params <- setLandscape(simul_params, myLand) ## Simulation, pathogen, landscape and dispersal parameters simul_params <- setDispersalPathogen(simul_params, c(1)) ## Cultivars simul_params <- setCultivars(simul_params, loadCultivar(name = "Susceptible", type = hostType)) ## Croptypes croptype <- data.frame(croptypeID = 0, croptypeName = c("Fully susceptible crop"), Susceptible = 1) simul_params <- setCroptypes(simul_params, croptype) simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = 0, rotation_sequence = list(c(0)), rotation_realloc = FALSE, prop = 1, aggreg = 1) ## Inoculum simul_params <- setInoculum(simul_params, 5e-4) ## list of outputs to be generated outputlist <- loadOutputs(epid_outputs = "all", evol_outputs = "") simul_params <- setOutputs(simul_params, outputlist) ## Check, save and run simulation checkSimulParams(simul_params) runSimul(simul_params, graphic = TRUE) ## End(Not run)
## Not run: ### Here is an example of simulation of a mosaic of three cultivars (S + R1 + R2). ## See our tutorials for more examples. ## Initialisation simul_params <- createSimulParams(outputDir = getwd()) ## Seed & Time parameters simul_params <- setSeed(simul_params, seed = 1) simul_params <- setTime(simul_params, Nyears = 10, nTSpY = 120) ## Pathogen parameters simul_params <- setPathogen(simul_params, loadPathogen("rust")) ## Landscape & dispersal simul_params <- setLandscape(simul_params, loadLandscape(1)) simul_params <- setDispersalPathogen(simul_params, loadDispersalPathogen[[1]]) ## Genes gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) ## Cultivars cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) ## Allocate genes to cultivars simul_params <- allocateCultivarGenes(simul_params, "Resistant1", c("MG 1")) simul_params <- allocateCultivarGenes(simul_params, "Resistant2", c("MG 2")) ## Allocate cultivars to croptypes croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Resistant crop 1", "Resistant crop 2")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 1", "Resistant1") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 2", "Resistant2") simul_params <- setCroptypes(simul_params, croptypes) ## Allocate croptypes to landscape rotation_sequence <- croptypes$croptypeID ## No rotation => 1 rotation_sequence element rotation_period <- 0 ## same croptypes every years prop <- c(1 / 3, 1 / 3, 1 / 3) ## croptypes proportions aggreg <- 10 ## aggregated landscape simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = rotation_period, rotation_sequence = rotation_sequence, rotation_realloc = FALSE, prop = prop, aggreg = aggreg) ## Set the inoculum simul_params <- setInoculum(simul_params, 5e-4) ## list of outputs to be generated simul_params <- setOutputs(simul_params, loadOutputs()) ## Check simulation parameters checkSimulParams(simul_params) ## Save deployment strategy into GPKG file simul_params <- saveDeploymentStrategy(simul_params) ## Run simulation runSimul(simul_params) ### Simulation of rust epidemics in a 1-km^2 patch cultivated ### with a susceptible wheat cultivar seed=10 Nyears=5 disease="rust" hostType="wheat" simul_params <- createSimulParams(outputDir = getwd()) ## Seed and time parameters simul_params <- setSeed(simul_params, seed) simul_params <- setTime(simul_params, Nyears, nTSpY=120) ## Pathogen parameters simul_params <- setPathogen(simul_params, loadPathogen(disease)) myLand <- Polygons(list(Polygon(matrix(c(0,0,1,1,0,1,1,0)*1000, nrow=4))), "ID1") myLand <- SpatialPolygons(list(myLand)) simul_params <- setLandscape(simul_params, myLand) ## Simulation, pathogen, landscape and dispersal parameters simul_params <- setDispersalPathogen(simul_params, c(1)) ## Cultivars simul_params <- setCultivars(simul_params, loadCultivar(name = "Susceptible", type = hostType)) ## Croptypes croptype <- data.frame(croptypeID = 0, croptypeName = c("Fully susceptible crop"), Susceptible = 1) simul_params <- setCroptypes(simul_params, croptype) simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = 0, rotation_sequence = list(c(0)), rotation_realloc = FALSE, prop = 1, aggreg = 1) ## Inoculum simul_params <- setInoculum(simul_params, 5e-4) ## list of outputs to be generated outputlist <- loadOutputs(epid_outputs = "all", evol_outputs = "") simul_params <- setOutputs(simul_params, outputlist) ## Check, save and run simulation checkSimulParams(simul_params) runSimul(simul_params, graphic = TRUE) ## End(Not run)
Generates a GPKG file containing the landscape and all parameters of the deployment strategy
saveDeploymentStrategy( params, outputGPKG = "landsepi_landscape.gpkg", overwrite = FALSE )
saveDeploymentStrategy( params, outputGPKG = "landsepi_landscape.gpkg", overwrite = FALSE )
params |
a LandsepiParams Object. |
outputGPKG |
name of the GPKG output (default: "landsepi_landscape.gpkg") to be generated. |
overwrite |
a boolean specifying if existing files can be overwritten (TRUE) or not (FALSE, default). |
The function generates a GPKG file in the simulation path. The GPKG file contains all input parameters needed to restore the landscape (sf object) and deployment strategy (croptypes, cultivars and genes).
an updated LandsepiParams object.
## Not run: ## Initialisation simul_params <- createSimulParams(outputDir = getwd()) ## Time parameters simul_params <- setTime(simul_params, Nyears = 10, nTSpY = 120) ## Landscape simul_params <- setLandscape(simul_params, loadLandscape(1)) ## Genes gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) ## Cultivars cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) ## Allocate genes to cultivars simul_params <- allocateCultivarGenes(simul_params, "Resistant1", c("MG 1")) simul_params <- allocateCultivarGenes(simul_params, "Resistant2", c("MG 2")) ## Allocate cultivars to croptypes croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop" , "Resistant crop 1" , "Resistant crop 2")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 1", "Resistant1") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 2", "Resistant2") simul_params <- setCroptypes(simul_params, croptypes) ## Allocate croptypes to landscape rotation_sequence <- croptypes$croptypeID ## No rotation -> 1 rotation_sequence element rotation_period <- 0 ## same croptypes every years prop <- c(1 / 3, 1 / 3, 1 / 3) ## croptypes proportions aggreg <- 10 ## aggregated landscape simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = rotation_period, rotation_sequence = rotation_sequence, rotation_realloc = FALSE, prop = prop, aggreg = aggreg) ## Save into a GPKG file simul_params <- saveDeploymentStrategy(simul_params) ## End(Not run)
## Not run: ## Initialisation simul_params <- createSimulParams(outputDir = getwd()) ## Time parameters simul_params <- setTime(simul_params, Nyears = 10, nTSpY = 120) ## Landscape simul_params <- setLandscape(simul_params, loadLandscape(1)) ## Genes gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) ## Cultivars cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) ## Allocate genes to cultivars simul_params <- allocateCultivarGenes(simul_params, "Resistant1", c("MG 1")) simul_params <- allocateCultivarGenes(simul_params, "Resistant2", c("MG 2")) ## Allocate cultivars to croptypes croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop" , "Resistant crop 1" , "Resistant crop 2")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 1", "Resistant1") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop 2", "Resistant2") simul_params <- setCroptypes(simul_params, croptypes) ## Allocate croptypes to landscape rotation_sequence <- croptypes$croptypeID ## No rotation -> 1 rotation_sequence element rotation_period <- 0 ## same croptypes every years prop <- c(1 / 3, 1 / 3, 1 / 3) ## croptypes proportions aggreg <- 10 ## aggregated landscape simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = rotation_period, rotation_sequence = rotation_sequence, rotation_realloc = FALSE, prop = prop, aggreg = aggreg) ## Save into a GPKG file simul_params <- saveDeploymentStrategy(simul_params) ## End(Not run)
Updates a LandsepiParams object with croptypes and their composition with regard to cultivar proportions. Note that landscape and cultivar parameters may be required if not all information is present to set croptypes.
setCroptypes(params, dfCroptypes)
setCroptypes(params, dfCroptypes)
params |
a LandsepiParams Object. |
dfCroptypes |
a data.frame containing cultivar proportions in each croptype (see details).
It can be generated manually, or initialised with |
The data.frame for cultivar allocations into croptypes must take this format (example):
croptypeID | croptypeName | cultivarName1 | cultivarName2 | ... |
0 | "cropt1" | 1 | 0 | ... |
1 | "cropt2" | 0.5 | 0.5 | ... |
croptypeIDs must start at 0 and match with values from landscape "croptypeID" layer with feature year_X. Cultivars names have to match cultivar names in the cultivars data.frame.
a LandsepiParams object
## Not run: simul_params <- createSimulParams() cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Mixture")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Mixture", c("Resistant1", "Resistant2")) simul_params <- setCroptypes(simul_params, croptypes) simul_params@Croptypes ## End(Not run)
## Not run: simul_params <- createSimulParams() cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant1", type = "wheat") cultivar3 <- loadCultivar(name = "Resistant2", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2, cultivar3), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) croptypes <- loadCroptypes(simul_params, names = c("Susceptible crop", "Mixture")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Mixture", c("Resistant1", "Resistant2")) simul_params <- setCroptypes(simul_params, croptypes) simul_params@Croptypes ## End(Not run)
Updates a LandsepiParams object with cultivars parameters
setCultivars(params, dfCultivars)
setCultivars(params, dfCultivars)
params |
a landsepiParams object. |
dfCultivars |
a data.frame defining the cultivars (see details). It can be generated
manually or, alternatively, via |
dfCultivars is a dataframe of parameters associated with each host genotype (i.e. cultivars, lines) when cultivated in pure crops. Columns of the dataframe are:
cultivarName: cultivar names (cannot accept space),
initial_density: host densities (per square meter) at the beginning of the cropping season as if cultivated in pure crop,
max_density: maximum host densities (per square meter) at the end of the cropping season as if cultivated in pure crop,
growth rate: host growth rates,
reproduction rate: host reproduction rates,
yield_H: theoretical yield (in weight or volume units / ha / cropping season) associated with hosts in sanitary status H as if cultivated in pure crop,
yield_L: theoretical yield (in weight or volume units / ha / cropping season) associated with hosts in sanitary status L as if cultivated in pure crop,
yield_I: theoretical yield (in weight or volume units / ha / cropping season) associated with hosts in sanitary status I as if cultivated in pure crop,
yield_R: theoretical yield (in weight or volume units / ha / cropping season) associated with hosts in sanitary status R as if cultivated in pure crop,
planting_cost = planting costs (in monetary units / ha / cropping season) as if cultivated in pure crop,
market_value = market values of the production (in monetary units / weight or volume unit).
The data.frame must be defined as follow (example):
cultivarName | initial_density | max_density | growth_rate | reproduction_rate | yield_H | yield_L | yield_I | yield_R | planting_cost | market_value |
Susceptible | 0.1 | 2.0 | 0.1 | 0.0 | 2.5 | 0.0 | 0.0 | 0.0 | 225 | 200 |
Resistant1 | 0.1 | 2.0 | 0.1 | 0.0 | 2.5 | 0.0 | 0.0 | 0.0 | 225 | 200 |
Resistant2 | 0.1 | 2.0 | 0.1 | 0.0 | 2.5 | 0.0 | 0.0 | 0.0 | 225 | 200 |
a LandsepiParams object
## Not run: simul_params <- createSimulParams() cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) simul_params@Cultivars ## End(Not run)
## Not run: simul_params <- createSimulParams() cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) simul_params@Cultivars ## End(Not run)
Updates a LandsepiParams object with a host dispersal matrix. Note that landscape parameters must be set before updating setting dispersal.
setDispersalHost(params, mat)
setDispersalHost(params, mat)
params |
a LandsepiParams Object. |
mat |
a square matrix giving the probability of host dispersal
from any polygon of the landscape to any other polygon.
It can be generated manually, or, alternatively, via |
the dispersal matrix gives the probability for a host individual in a polygon i (row) to migrate to polygon j (column) through dispersal. If the host is a cultivated plant: seeds are harvested and do not disperse. Thus the dispersal matrix is the identity matrix.
a LandsepiParam object.
## Not run: simul_params <- createSimulParams() simul_params <- setLandscape(simul_params, loadLandscape(1)) d <- loadDispersalHost(simul_params) simul_params <- setDispersalHost(simul_params, d) simul_params@DispHost ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setLandscape(simul_params, loadLandscape(1)) d <- loadDispersalHost(simul_params) simul_params <- setDispersalHost(simul_params, d) simul_params@DispHost ## End(Not run)
Updates a LandsepiParams object with a pathogen dispersal matrix. Note that landscape parameters must be set before updating setting dispersal.
setDispersalPathogen(params, mat_clonal, mat_sex = NULL)
setDispersalPathogen(params, mat_clonal, mat_sex = NULL)
params |
a LandsepiParams Object. |
mat_clonal |
a square matrix giving the probability of pathogen dispersal
(clonal propagules) from any polygon of the landscape to any other polygon.
It can be generated manually, or, alternatively, via |
mat_sex |
a square matrix giving the probability of pathogen dispersal (sexual propagules)
from any polygon of the landscape to any other polygon (default identity matrix) .
It can be generated manually, or, alternatively, via |
See tutorial (vignettes) on how to use your own landscape and compute your own pathogen dispersal kernel. The dispersal matrix a square matrix whose size is the number of polygons in the landscape and whose elements are, for each line i and each column i' the probability that propagules migrate from polygon i to polygon i'. Lines of the matrix can be normalised to sum to 1 (reflective boundaries); otherwise propagules dispersing outside the landscape are lost (absorbing boundaries).
a LandsepiParam object.
## Not run: simul_params <- createSimulParams() simul_params <- setLandscape(simul_params, loadLandscape(1)) d <- loadDispersalPathogen(1) simul_params <- setDispersalPathogen(simul_params, d[[1]], d[[2]]) simul_params@DispPathoClonal ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setLandscape(simul_params, loadLandscape(1)) d <- loadDispersalPathogen(1) simul_params <- setDispersalPathogen(simul_params, d[[1]], d[[2]]) simul_params@DispPathoClonal ## End(Not run)
Updates a LandsepiParams object with parameters associated with resistance genes and pathogen adaptation.
setGenes(params, dfGenes)
setGenes(params, dfGenes)
params |
a LandsepiParams object |
dfGenes |
a data.frame containing gene parameters. It can be defined manually, or,
alternatively, with |
dfGenes is a data.frame of parameters associated with each resistance gene and with the evolution of each corresponding pathogenicity gene. Columns of the dataframe are:
geneName: names of resistance genes,
target_trait: aggressiveness components ("IR", "LAT", "IP", or "PR") targeted by resistance genes,
efficiency: resistance gene efficiencies, i.e. the percentage of reduction of the targeted aggressiveness component (IR, 1/LAT, IP and PR),
age_of_activ_mean: expected delays to resistance activation (for APRs),
age_of_activ_var: variances of the delay to resistance activation (for APRs),
mutation_prob: mutation probabilities for pathogenicity genes (each of them corresponding to a resistance gene),
Nlevels_aggressiveness: number of adaptation levels related to each resistance gene (i.e. 1 + number of required mutations for a pathogenicity gene to fully adapt to the corresponding resistance gene),
adaptation_cost: fitness penalties paid by pathogen genotypes fully adapted to the considered resistance genes on all hosts,
relative_advantage: fitness advantages of pathogen genotypes fully adapted to the resistance genes on hosts carrying these genes, relative to those that do not carry these genes,
tradeoff_strength: strengths of the trade-off relationships between the level of aggressiveness on hosts that do and do not carry the resistance genes.
recombination_sd: standard deviation of the normal distribution used for recombination of quantitative traits during sexual reproduction (infinitesimal model)
The data.frame must be defined as follow (example):
geneName | efficiency | age_of_activ_mean | age_of_activ_var | mutation_prob | Nlevels_agressiveness | adaptation_cost | relative advantage | tradeoff_strength | target_trait | recombination_sd |
MG1 | 1 | 0 | 0 | 1e-07 | 2 | 0.5 | 0.5 | 1 | IR | 0.27 |
QTL1 | 0.5 | 0 | 0 | 0.0001 | 10 | 0.74 | 0.74 | 1 | LAT | 0.27 |
a LandsepiParams object.
## Not run: simul_params <- createSimulParams() gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) simul_params@Genes ## End(Not run)
## Not run: simul_params <- createSimulParams() gene1 <- loadGene(name = "MG 1", type = "majorGene") gene2 <- loadGene(name = "MG 2", type = "majorGene") genes <- data.frame(rbind(gene1, gene2), stringsAsFactors = FALSE) simul_params <- setGenes(simul_params, genes) simul_params@Genes ## End(Not run)
Updates a LandsepiParams object with the initial probability for an individual host to be infectious (i.e. state I) at the beginning of the simulation (i.e. t=0).
setInoculum(params, val = 5e-04)
setInoculum(params, val = 5e-04)
params |
a LandsepiParams object. |
val |
a numeric value (default = 5e-4) indicating the probability for the first cultivar
to be infected by the first pathogen genotype in all polygons of the landscape
(must be between 0 and 1).
The parameter can also be entered as a 3D array of dimensions (1:Nhost,1:Npatho,1:Npoly)
indicating the initial probability to be infectious, for each cultivar, pathogen genotype and
polygon (independently from the possible presence of cultivars carrying resistance genes).
It can be generated manually or, alternatively, via |
Before setting the inoculum, one can use getMatrixGenePatho()
,
getMatrixCultivarPatho()
,
getMatrixCroptypePatho()
and getMatrixPolyPatho()
to acknowledge which
pathogen genotypes are compatible to which genes, cultivars, croptypes and polygons.
Once setInoculum()
is used, one can call inoculumToMatrix()
to get
the inoculum as a 3D array (1:Nhost,1:Npatho,1:Npoly)
a LandsepiParams object
inoculumToMatrix, loadInoculum
## Not run: simul_params <- createSimulParams() simul_params <- setInoculum(simul_params, 1E-3) simul_params@PI0 ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setInoculum(simul_params, 1E-3) simul_params@PI0 ## End(Not run)
Updates a LandsepiParams object with a sp or sf object as landscape.
setLandscape(params, land)
setLandscape(params, land)
params |
a LandsepiParams Object. |
land |
a landscape as sp or sf object |
The landscape should be a sp or sf object. Built-in landscape are available using
loadLandscape
.
See our tutorial (vignettes) for details on how to use your own landscape.
If the landscape contains only polygons, croptypes can be allocated later using
allocateLandscapeCroptypes
.
Otherwise the landscape has to contain a data.frame specifying for every year, the index
of the croptype cultivated in each polygon.
Each features has a field identified by "year_XX" (XX <- seq(1:Nyears+1)) and containing
the croptype ID.
Features/fields | year_1 | year_2 | ... year_Nyears+1 |
polygons1 | 13 | 10 | 13 |
polygonsX | 2 | 1 | 2 |
a LandsepiParams object.
## Not run: simul_params <- createSimulParams() simul_params <- setLandscape(simul_params, loadLandscape(1)) simul_params@Landscape ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setLandscape(simul_params, loadLandscape(1)) simul_params@Landscape ## End(Not run)
Updates a LandsepiParams object with a list of output parameters.
setOutputs(params, output_list)
setOutputs(params, output_list)
params |
a LandsepiParams object. |
output_list |
a list of outputs to be generated and parameters for output generation.
It can be generated manually or, alternatively, via
|
"epid_outputs" is a character string (or a vector of character strings if several outputs are to be computed) specifying the type of epidemiological and economic outputs to generate:
"audpc" : Area Under Disease Progress Curve (average number of diseased host individuals per time step and square meter)
"audpc_rel" : Relative Area Under Disease Progress Curve (average proportion of diseased host individuals relative to the total number of existing hosts)
"gla" : Green Leaf Area (average number of healthy host individuals per square meter)
"gla_rel" : Relative Green Leaf Area (average proportion of healthy host individuals relative to the total number of existing hosts)
"eco_yield" : total crop yield (in weight or volume units per ha)
"eco_cost" : operational crop costs (in monetary units per ha)
"eco_product" : total crop products (in monetary units per ha)
"eco_margin" : Margin (products - costs, in monetary units per ha)
"contrib": contribution of pathogen genotypes to LIR dynamics
"HLIR_dynamics", "H_dynamics", "L_dynamics", "IR_dynamics", "HLI_dynamics", etc.: Epidemic dynamics related to the specified sanitary status (H, L, I or R and all their combinations). Graphics only, works only if graphic=TRUE.
"all" : compute all these outputs (default)
"" : none of these outputs will be generated.
"evol_outputs" is a character string (or a vector of character strings if several outputs are to be computed) specifying the type of evolutionary outputs to generate :
"evol_patho": Dynamics of pathogen genotype frequencies
"evol_aggr": Evolution of pathogen aggressiveness
"durability": Durability of resistance genes
"all": compute all these outputs (default)
"": none of these outputs will be generated.
a LandsepiParams object.
## Not run: simul_params <- createSimulParams() simul_params <- setOutputs(simul_params, loadOutputs()) simul_params@Outputs ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setOutputs(simul_params, loadOutputs()) simul_params@Outputs ## End(Not run)
Updates a LandsepiParams object with pathogen parameters
setPathogen(params, patho_params)
setPathogen(params, patho_params)
params |
a LandsepiParams Object. |
patho_params |
a list of pathogen aggressiveness parameters on a susceptible host for a pathogen genotype not adapted to resistance:
It can be generated manually, or, alternatively, via |
a set of parameters representative of rust fungi, downy mildew or black sigatoka
can be loaded via loadPathogen
.
a LandsepiParams object
## Not run: simul_params <- createSimulParams() simul_params <- setPathogen(simul_params, loadPathogen()) simul_params@Pathogen ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setPathogen(simul_params, loadPathogen()) simul_params@Pathogen ## End(Not run)
Updates a LandsepiParams object with a seed value for random number generator
setSeed(params, seed)
setSeed(params, seed)
params |
a LandsepiParams Object. |
seed |
an integer used as seed value (for random number generator). |
a LandsepiParams object.
## Not run: simul_params <- createSimulParams() simul_params <- setSeed(simul_params, 100) simul_params@Seed ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setSeed(simul_params, 100) simul_params@Seed ## End(Not run)
Set RNG seed to seed value if not NULL, otherwise set it to timestamps value
setSeedValue(seed = NULL)
setSeedValue(seed = NULL)
seed |
an interger as seed value or NULL |
Sets seed for "Mersenne-Twister" algorithm using Inversion generation
the new seed value for RNG
setSeedValue(seed = 10)
setSeedValue(seed = 10)
Updates a LandsepiParams object with time parameters : Nyears and nTSpY
setTime(params, Nyears, nTSpY)
setTime(params, Nyears, nTSpY)
params |
a LandsepiParams Object. |
Nyears |
an integer giving the number of cropping seasons (e.g. years) to simulate. |
nTSpY |
an integer giving the number of time steps per cropping season (e.g. days). |
a LandsepiParams object.
## Not run: simul_params <- createSimulParams() simul_params <- setTime(simul_params, Nyears=10, nTSpY=120) simul_params@TimeParam ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setTime(simul_params, Nyears=10, nTSpY=120) simul_params@TimeParam ## End(Not run)
Updates a LandsepiParams object with treatment parameters
setTreatment(params, treatment_params)
setTreatment(params, treatment_params)
params |
a LandsepiParams Object. |
treatment_params |
list of parameters related to pesticide treatments:
|
Chemical treatment is applied in a polygon only if disease severity (i.e. I/N) in
this polygon exceeds the threshold given by treatment_application_threshold
.
Treatment efficiency is maximum (i.e. equal to the parameter treatment_efficiency)
at the time of treatment application (noted ); then it decreases with time
(i.e. natural pesticide degradation) and host growth (i.e. new biomass is not protected
by treatments): protected by treatments):Efficiency of the treatment at time t after the application date is given by:
with
:
is the reduction of
fungicide concentration due to time (e.g. natural degradation, volatilization, weathering),
with
the timelag passed since the time of
treatment application.
is the reduction of fungicide concentration due
to plant growth, since new plant tissue is not covered by fungicide.
and
being the number of
host individuals a the time of treatment
and at time
, respectively.
and
are shape parameters.
An empty list of treatments (i.e. absence of application) can be loaded using
loadPathogen
.
a LandsepiParams object
## Not run: t <- loadTreatment() simul_params <- setTreatment(simul_params, t) simul_params@Treatment ## End(Not run)
## Not run: t <- loadTreatment() simul_params <- setTreatment(simul_params, t) simul_params@Treatment ## End(Not run)
Shows a LandsepiParams object.
## S4 method for signature 'LandsepiParams' show(object)
## S4 method for signature 'LandsepiParams' show(object)
object |
a LandsepiParams object |
Stochastic, spatially-explicit, demo-genetic model simulating the spread and evolution of a pathogen in a heterogeneous landscape and generating a wide range of epidemiological, evolutionary and economic outputs.
simul_landsepi( seed = 12345, time_param = list(Nyears = 5, nTSpY = 120), croptype_names = c("Susceptible crop"), croptypes_cultivars_prop = data.frame(croptypeID = 0, cultivarID = 0, proportion = 1), cultivars = data.frame(cultivarName = "Susceptible", initial_density = 0.1, max_density = 2, growth_rate = 0.1, reproduction_rate = 0, yield_H = 2.5, yield_L = 0, yield_I = 0, yield_R = 0, planting_cost = 225, market_value = 200), cultivars_genes_list = list(numeric(0)), genes = data.frame(geneName = character(0), mutation_prob = numeric(0), efficiency = numeric(0), tradeoff_strength = numeric(0), Nlevels_aggressiveness = numeric(0), adaptation_cost = numeric(0), relative_advantage = numeric(0), age_of_activ_mean = numeric(0), age_of_activ_var = numeric(0), target_trait = character(0), recombination_sd = numeric(0)), landscape = NULL, area = 1e+06, rotation = data.frame(year_1 = c(0), year_2 = c(0), year_3 = c(0), year_4 = c(0), year_5 = c(0), year_6 = c(0)), basic_patho_param = list(name = "rust", survival_prob = 1e-04, repro_sex_prob = 0, infection_rate = 0.4, propagule_prod_rate = 3.125, latent_period_mean = 10, latent_period_var = 9, infectious_period_mean = 24, infectious_period_var = 105, sigmoid_kappa = 5.333, sigmoid_sigma = 3, sigmoid_plateau = 1, sex_propagule_viability_limit = 1, sex_propagule_release_mean = 1, clonal_propagule_gradual_release = 0), disp_patho_clonal = c(1), disp_patho_sex = c(1), disp_host = c(1), treatment = list(treatment_degradation_rate = 0.1, treatment_efficiency = 0, treatment_timesteps = logical(0), treatment_cultivars = logical(0), treatment_cost = 0, treatment_application_threshold = logical(0)), pI0 = c(5e-04), epid_outputs = "all", evol_outputs = "all", thres_breakdown = 50000, audpc100S = 0.76, writeTXT = TRUE, graphic = TRUE, videoMP4 = FALSE, keepRawResults = FALSE )
simul_landsepi( seed = 12345, time_param = list(Nyears = 5, nTSpY = 120), croptype_names = c("Susceptible crop"), croptypes_cultivars_prop = data.frame(croptypeID = 0, cultivarID = 0, proportion = 1), cultivars = data.frame(cultivarName = "Susceptible", initial_density = 0.1, max_density = 2, growth_rate = 0.1, reproduction_rate = 0, yield_H = 2.5, yield_L = 0, yield_I = 0, yield_R = 0, planting_cost = 225, market_value = 200), cultivars_genes_list = list(numeric(0)), genes = data.frame(geneName = character(0), mutation_prob = numeric(0), efficiency = numeric(0), tradeoff_strength = numeric(0), Nlevels_aggressiveness = numeric(0), adaptation_cost = numeric(0), relative_advantage = numeric(0), age_of_activ_mean = numeric(0), age_of_activ_var = numeric(0), target_trait = character(0), recombination_sd = numeric(0)), landscape = NULL, area = 1e+06, rotation = data.frame(year_1 = c(0), year_2 = c(0), year_3 = c(0), year_4 = c(0), year_5 = c(0), year_6 = c(0)), basic_patho_param = list(name = "rust", survival_prob = 1e-04, repro_sex_prob = 0, infection_rate = 0.4, propagule_prod_rate = 3.125, latent_period_mean = 10, latent_period_var = 9, infectious_period_mean = 24, infectious_period_var = 105, sigmoid_kappa = 5.333, sigmoid_sigma = 3, sigmoid_plateau = 1, sex_propagule_viability_limit = 1, sex_propagule_release_mean = 1, clonal_propagule_gradual_release = 0), disp_patho_clonal = c(1), disp_patho_sex = c(1), disp_host = c(1), treatment = list(treatment_degradation_rate = 0.1, treatment_efficiency = 0, treatment_timesteps = logical(0), treatment_cultivars = logical(0), treatment_cost = 0, treatment_application_threshold = logical(0)), pI0 = c(5e-04), epid_outputs = "all", evol_outputs = "all", thres_breakdown = 50000, audpc100S = 0.76, writeTXT = TRUE, graphic = TRUE, videoMP4 = FALSE, keepRawResults = FALSE )
seed |
an integer used as seed value (for random number generator). |
time_param |
a list of simulation parameters:
|
croptype_names |
a vector of croptypes names. |
croptypes_cultivars_prop |
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. |
cultivars |
a dataframe of parameters associated with each host genotype (i.e. cultivars) when cultivated in pure crops. Columns of the dataframe are:
|
cultivars_genes_list |
a list containing, for each host genotype, the indices of carried resistance genes. |
genes |
a data.frame of parameters associated with each resistance gene and with the evolution of each corresponding pathogenicity gene. Columns of the dataframe are:
|
landscape |
a sp object containing the landscape (required only if videoMP4=TRUE). |
area |
a vector containing polygon areas (must be in square meters). |
rotation |
a dataframe containing for each field (rows) and year (columns, named "year_1", "year_2", etc.), the index of the cultivated croptype. Importantly, the matrix must contain 1 more column than the real number of simulated years. |
basic_patho_param |
a list of i. pathogen aggressiveness parameters on a susceptible host for a pathogen genotype not adapted to resistance and ii. sexual reproduction parameters:
|
disp_patho_clonal |
a vectorized matrix giving the probability of pathogen dispersal from any field of the landscape to any other field. |
disp_patho_sex |
a vectorized matrix giving the probability of pathogen dispersal for sexual propagules from any field of the landscape to any other field. |
disp_host |
a vectorized matrix giving the probability of host dispersal from any field of the landscape to any other field |
treatment |
list of parameters related to pesticide treatments:
|
pI0 |
probability for the first cultivar to be infected (and infectious, i.e. state I) by the first pathogen genotype in all polygons of the landscape at t=0 (i.e. the beginning of the simulation). It can also be entered as a vector of length NhostNpathoNpoly giving the probability for each cultivar, pathogen genotype and polygon (independently from the possible presence of cultivars carrying resistance genes). |
epid_outputs |
a character string (or a vector of character strings if several outputs are to be computed) specifying the type of epidemiological and economic outputs to generate (see details):
|
evol_outputs |
a character string (or a vector of character strings if several outputs are to be computed) specifying the type of evolutionary outputs to generate :
|
thres_breakdown |
an integer (or vector of integers) giving the threshold (i.e. number of infections) above which a pathogen genotype is unlikely to go extinct, used to characterise the time to invasion of resistant hosts (several values are computed if several thresholds are given in a vector). |
audpc100S |
the audpc in a fully susceptible landscape (used as reference value for graphics). |
writeTXT |
a logical indicating if outputs must be written in text files (TRUE, default) or not (FALSE). |
graphic |
a logical indicating if graphics must be generated (TRUE, default) or not (FALSE). |
videoMP4 |
a logical indicating if a video must be generated (TRUE) or not (FALSE, default). Works only if graphic=TRUE and epid_outputs="audpc_rel" (or epid_outputs="all"). |
keepRawResults |
a logical indicating if binary files must be kept after the end of the simulation (default=FALSE). Careful, many files may be generated if keepRawResults=TRUE. |
See ?landsepi
for details on the model and assumptions.
Briefly, the model is stochastic, spatially explicit (the basic spatial unit is an individual field), based on a SEIR
(‘susceptible-exposed-infectious-removed’, renamed HLIR for 'healthy-latent-infectious-removed' to avoid confusions
with 'susceptible host') structure with a discrete time step. It simulates the spread and
evolution (via mutation, recombination through sexual reproduction, selection and drift)
of a pathogen in a heterogeneous cropping landscape, across cropping seasons split by host harvests which impose
potential bottlenecks to the pathogen. A wide array of resistance deployment strategies
(possibly including chemical treatments) can be simulated and evaluated using several possible
outputs to assess the epidemiological, evolutionary and economic performance
of deployment strategies (See ?epid_output
and ?evol_output
for details).
A list containing all outputs that have been required via "epid_outputs" and "evol_outputs". A set of text files, graphics and a video showing epidemic dynamics can be generated. If keepRawResults=TRUE, a set of binary files is generated for every year of simulation and every compartment:
H: healthy hosts,
Hjuv: juvenile healthy hosts (for host reproduction),
L: latently infected hosts,
I: infectious hosts,
R: removed hosts,
P: propagules.
Each file indicates for every time-step the number of individuals in each field, and when appropriate for each host and pathogen genotype. Additionally, a binary file called TFI is generated and gives the Treatment Frequency Indicator (expressed as the number of treatment applications per polygon).
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. PLoS Computational Biology 14(4):e1006067.
model_landsepi, epid_output, evol_output, video, runSimul
## Not run: #### Spatially-implicit simulation with a single 1-km^2 patch 100% cultivated # with a susceptible cultivar simul_landsepi() #### Spatially-implicit simulation with 2 patches (S + R) during 3 years #### ## Simulation parameters time_param <- list(Nyears = 3, nTSpY = 120) area <- c(100000, 100000) rotation <- data.frame(year_1 = c(0, 1), year_2 = c(0, 1), year_3 = c(0, 1), year_4 = c(0, 1)) croptype_names <- c("Susceptible crop", "Resistant crop") croptypes_cultivars_prop <- data.frame( croptypeID = c(0, 1), cultivarID = c(0, 1), proportion = c(1, 1) ) cultivars <- rbind( loadCultivar(name = "Susceptible", type = "growingHost"), loadCultivar(name = "Resistant", type = "growingHost") ) genes <- loadGene(name = "MG", type = "majorGene") cultivars_genes_list <- list(numeric(0), 0) ## Run simulation simul_landsepi( seed = 12345, time_param, croptype_names, croptypes_cultivars_prop, cultivars, cultivars_genes_list, genes, landscape = NULL, area, rotation, basic_patho_param = loadPathogen(disease = "rust"), disp_patho_clonal = c(0.99, 0.01, 0.01, 0.99), disp_patho_sex = c(0.99, 0.01, 0.01, 0.99), disp_host = c(1, 0, 0, 1), pI0 = c(5e-4) ) #### Spatially-explicit simulation with built-in landscape during 10 years #### # Generate a mosaic of four croptypes in balanced proportions # and medium level of spatial aggregation ## Simulation and Landscape parameters Nyears <- 10 nTSpY <- 120 landscape <- loadLandscape(1) Npoly <- length(landscape) library(sf) area <- st_area(st_as_sf(landscape)) rotation <- AgriLand(landscape, Nyears, rotation_period = 1, rotation_realloc = FALSE, rotation_sequence = c(0, 1, 2, 3), prop = rep(1 / 4, 4), aggreg = 0.5, graphic = TRUE, outputDir = getwd() ) rotation <- data.frame(rotation)[, 1:(Nyears + 1)] croptype_names <- c("Susceptible crop" , "Resistant crop 1" , "Resistant crop 2" , "Resistant crop 3") croptypes_cultivars_prop <- data.frame(croptypeID = c(0, 1, 2, 3), cultivarID = c(0, 1, 2, 3), proportion = c(1, 1, 1, 1)) cultivars <- data.frame(rbind( loadCultivar(name = "Susceptible", type = "growingHost"), loadCultivar(name = "Resistant1", type = "growingHost"), loadCultivar(name = "Resistant2", type = "growingHost"), loadCultivar(name = "Resistant3", type = "growingHost") ), stringsAsFactors = FALSE) Nhost <- nrow(cultivars) genes <- data.frame(rbind( loadGene(name = "MG 1", type = "majorGene"), loadGene(name = "MG 2", type = "majorGene"), loadGene(name = "MG 3", type = "majorGene") ), stringsAsFactors = FALSE) cultivars_genes_list <- list(numeric(0), 0, 1, 2) Npatho <- prod(genes$Nlevels_aggressiveness) ## Run simulation simul_landsepi( seed = 12345, time_param = list(Nyears = Nyears, nTSpY = nTSpY), croptype_names, croptypes_cultivars_prop, cultivars, cultivars_genes_list, genes, landscape, area, rotation, basic_patho_param = loadPathogen(disease = "rust"), disp_patho_clonal = loadDispersalPathogen(1)[[1]], disp_patho_sex = as.numeric(diag(Npoly)), disp_host = as.numeric(diag(Npoly)), pI0 = c(5E-4) ) ## End(Not run)
## Not run: #### Spatially-implicit simulation with a single 1-km^2 patch 100% cultivated # with a susceptible cultivar simul_landsepi() #### Spatially-implicit simulation with 2 patches (S + R) during 3 years #### ## Simulation parameters time_param <- list(Nyears = 3, nTSpY = 120) area <- c(100000, 100000) rotation <- data.frame(year_1 = c(0, 1), year_2 = c(0, 1), year_3 = c(0, 1), year_4 = c(0, 1)) croptype_names <- c("Susceptible crop", "Resistant crop") croptypes_cultivars_prop <- data.frame( croptypeID = c(0, 1), cultivarID = c(0, 1), proportion = c(1, 1) ) cultivars <- rbind( loadCultivar(name = "Susceptible", type = "growingHost"), loadCultivar(name = "Resistant", type = "growingHost") ) genes <- loadGene(name = "MG", type = "majorGene") cultivars_genes_list <- list(numeric(0), 0) ## Run simulation simul_landsepi( seed = 12345, time_param, croptype_names, croptypes_cultivars_prop, cultivars, cultivars_genes_list, genes, landscape = NULL, area, rotation, basic_patho_param = loadPathogen(disease = "rust"), disp_patho_clonal = c(0.99, 0.01, 0.01, 0.99), disp_patho_sex = c(0.99, 0.01, 0.01, 0.99), disp_host = c(1, 0, 0, 1), pI0 = c(5e-4) ) #### Spatially-explicit simulation with built-in landscape during 10 years #### # Generate a mosaic of four croptypes in balanced proportions # and medium level of spatial aggregation ## Simulation and Landscape parameters Nyears <- 10 nTSpY <- 120 landscape <- loadLandscape(1) Npoly <- length(landscape) library(sf) area <- st_area(st_as_sf(landscape)) rotation <- AgriLand(landscape, Nyears, rotation_period = 1, rotation_realloc = FALSE, rotation_sequence = c(0, 1, 2, 3), prop = rep(1 / 4, 4), aggreg = 0.5, graphic = TRUE, outputDir = getwd() ) rotation <- data.frame(rotation)[, 1:(Nyears + 1)] croptype_names <- c("Susceptible crop" , "Resistant crop 1" , "Resistant crop 2" , "Resistant crop 3") croptypes_cultivars_prop <- data.frame(croptypeID = c(0, 1, 2, 3), cultivarID = c(0, 1, 2, 3), proportion = c(1, 1, 1, 1)) cultivars <- data.frame(rbind( loadCultivar(name = "Susceptible", type = "growingHost"), loadCultivar(name = "Resistant1", type = "growingHost"), loadCultivar(name = "Resistant2", type = "growingHost"), loadCultivar(name = "Resistant3", type = "growingHost") ), stringsAsFactors = FALSE) Nhost <- nrow(cultivars) genes <- data.frame(rbind( loadGene(name = "MG 1", type = "majorGene"), loadGene(name = "MG 2", type = "majorGene"), loadGene(name = "MG 3", type = "majorGene") ), stringsAsFactors = FALSE) cultivars_genes_list <- list(numeric(0), 0, 1, 2) Npatho <- prod(genes$Nlevels_aggressiveness) ## Run simulation simul_landsepi( seed = 12345, time_param = list(Nyears = Nyears, nTSpY = nTSpY), croptype_names, croptypes_cultivars_prop, cultivars, cultivars_genes_list, genes, landscape, area, rotation, basic_patho_param = loadPathogen(disease = "rust"), disp_patho_clonal = loadDispersalPathogen(1)[[1]], disp_patho_sex = as.numeric(diag(Npoly)), disp_host = as.numeric(diag(Npoly)), pI0 = c(5E-4) ) ## End(Not run)
Prints the summary of a LandsepiParams object.
## S4 method for signature 'LandsepiParams' summary(object)
## S4 method for signature 'LandsepiParams' summary(object)
object |
a LandsepiParams object. |
Transform the off-season survival probability of the pathogen (1D vector of length Nyears*Ncroptypes) into a matrix (for visualization purpose)
survivalProbToMatrix(params)
survivalProbToMatrix(params)
params |
a LandsepiParams object. |
After updating the off-season survival probability with updateSurvivalProb()
,
this function returns the probability as a matrix for every year (rows) and croptypes (columns)
as well as, if croptypes have been previously allocated to a landscape, a matrix for every
polygon (rows) and year (columns).
a list containing a matrix of dimensions (Nyears, Ncroptypes) as well as a matrix of dimensions (Npoly, Nyears)
## Not run: simul_params <- createSimulParams() simul_params <- setTime(simul_params, Nyears=10, nTSpY=120) simul_params <- setPathogen(simul_params, loadPathogen("rust")) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) croptypes <- loadCroptypes(simul_params , names = c("Susceptible crop", "Resistant crop", "Mixture")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop", "Resistant") croptypes <- allocateCroptypeCultivars(croptypes, "Mixture", c("Susceptible", "Resistant")) simul_params <- setCroptypes(simul_params, croptypes) Ncroptypes <- nrow(simul_params@Croptypes) Nyears <- simul_params@TimeParam$Nyears landscape <- loadLandscape(1) simul_params <- setLandscape(simul_params, landscape) simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = 0, rotation_sequence = croptypes$croptypeID, rotation_realloc = FALSE, prop = rep(1/Ncroptypes, Ncroptypes), aggreg = 0.05, graphic = FALSE) ## One probability per year and per croptype: simul_params <- updateSurvivalProb(simul_params , mat=matrix(runif(Nyears*Ncroptypes), ncol=Ncroptypes)) simul_params@Pathogen survivalProbToMatrix(simul_params) ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setTime(simul_params, Nyears=10, nTSpY=120) simul_params <- setPathogen(simul_params, loadPathogen("rust")) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) croptypes <- loadCroptypes(simul_params , names = c("Susceptible crop", "Resistant crop", "Mixture")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop", "Resistant") croptypes <- allocateCroptypeCultivars(croptypes, "Mixture", c("Susceptible", "Resistant")) simul_params <- setCroptypes(simul_params, croptypes) Ncroptypes <- nrow(simul_params@Croptypes) Nyears <- simul_params@TimeParam$Nyears landscape <- loadLandscape(1) simul_params <- setLandscape(simul_params, landscape) simul_params <- allocateLandscapeCroptypes(simul_params, rotation_period = 0, rotation_sequence = croptypes$croptypeID, rotation_realloc = FALSE, prop = rep(1/Ncroptypes, Ncroptypes), aggreg = 0.05, graphic = FALSE) ## One probability per year and per croptype: simul_params <- updateSurvivalProb(simul_params , mat=matrix(runif(Nyears*Ncroptypes), ncol=Ncroptypes)) simul_params@Pathogen survivalProbToMatrix(simul_params) ## End(Not run)
Finds the level of aggressiveness on different components (targeted by different resistance genes) from the index of a given pathogen genotype
switch_patho_to_aggr(index_patho, Ngenes, Nlevels_aggressiveness)
switch_patho_to_aggr(index_patho, Ngenes, Nlevels_aggressiveness)
index_patho |
index of pathogen genotype |
Ngenes |
number of resistance genes |
Nlevels_aggressiveness |
vector of the number of adaptation levels related to each resistance gene |
a vector containing the indices of aggressiveness on the different components targeted by the resistance genes
switch_patho_to_aggr(5, 3, c(2, 2, 3))
switch_patho_to_aggr(5, 3, c(2, 2, 3))
set the probabilities for an infectious host to reproduce via sex rather than via cloning at every time step. Note that time parameters must be set before updating sexual reproduction probabilities.
updateReproSexProb(params, vec)
updateReproSexProb(params, vec)
params |
a LandsepiParams object |
vec |
a vector of size TimeParam$nTSpY +1 (season end) with the probabilities for an infectious host to reproduce via sex rather than via cloning at each time step. |
a LandsepiParams object updated
## Not run: simul_params <- createSimulParams() simul_params <- setTime(simul_params, Nyears=10, nTSpY=120) simul_params <- setPathogen(simul_params, loadPathogen("rust")) repro_sex_probs <- c(rep(0.0, 120), 1.0) simul_params <- updateReproSexProb(simul_params, repro_sex_probs) simul_params@Pathogen ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setTime(simul_params, Nyears=10, nTSpY=120) simul_params <- setPathogen(simul_params, loadPathogen("rust")) repro_sex_probs <- c(rep(0.0, 120), 1.0) simul_params <- updateReproSexProb(simul_params, repro_sex_probs) simul_params@Pathogen ## End(Not run)
update survival probability of the pathogen with a probability value for every simulated year (number of years = Nyears) and every croptype (number of croptypes = Ncroptypes). Note that time parameters, pathogen and croptypes must be set before updating survival probabilities.
updateSurvivalProb(params, mat_year = NULL, mat_croptype = NULL, mat = NULL)
updateSurvivalProb(params, mat_year = NULL, mat_croptype = NULL, mat = NULL)
params |
a LandsepiParams object |
mat_year |
a vector of size Nyear, giving survival probabilities for every year (replicated for every croptype). |
mat_croptype |
a vector of size Ncroptypes, giving survival probabilities for every croptype (replicated for every year). |
mat |
a matrix of dimension (Nyears, Ncroptypes) giving survival probabilities for every year (rows) and every croptype (columns). |
Unless the matrix mat
is filled, the matrix containing the survival
probability during the offseason
is computed for every year and croptype with
mat[year, croptype] = mat_year[year] * mat_croptype[croptype]
.
a LandsepiParams object updated.
## Not run: simul_params <- createSimulParams() simul_params <- setTime(simul_params, Nyears=10, nTSpY=120) simul_params <- setPathogen(simul_params, loadPathogen("rust")) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) croptypes <- loadCroptypes(simul_params , names = c("Susceptible crop", "Resistant crop", "Mixture")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop", "Resistant") croptypes <- allocateCroptypeCultivars(croptypes, "Mixture", c("Susceptible", "Resistant")) simul_params <- setCroptypes(simul_params, croptypes) Ncroptypes <- nrow(simul_params@Croptypes) Nyears <- simul_params@TimeParam$Nyears ## Same probability in every croptype: simul_params <- updateSurvivalProb(simul_params, mat_year=1:Nyears/100) simul_params@Pathogen ## Same probability every year: simul_params <- updateSurvivalProb(simul_params, mat_croptype=1:Ncroptypes/10) simul_params@Pathogen ## specific probability for different croptypes and years: simul_params <- updateSurvivalProb(simul_params , mat_year=1:Nyears/100, mat_croptype=1:Ncroptypes/10) simul_params@Pathogen ## One probability per year and per croptype: simul_params <- updateSurvivalProb(simul_params , mat=matrix(runif(Nyears*Ncroptypes), ncol=Ncroptypes)) simul_params@Pathogen survivalProbToMatrix(simul_params) ## End(Not run)
## Not run: simul_params <- createSimulParams() simul_params <- setTime(simul_params, Nyears=10, nTSpY=120) simul_params <- setPathogen(simul_params, loadPathogen("rust")) cultivar1 <- loadCultivar(name = "Susceptible", type = "wheat") cultivar2 <- loadCultivar(name = "Resistant", type = "wheat") cultivars <- data.frame(rbind(cultivar1, cultivar2), stringsAsFactors = FALSE) simul_params <- setCultivars(simul_params, cultivars) croptypes <- loadCroptypes(simul_params , names = c("Susceptible crop", "Resistant crop", "Mixture")) croptypes <- allocateCroptypeCultivars(croptypes, "Susceptible crop", "Susceptible") croptypes <- allocateCroptypeCultivars(croptypes, "Resistant crop", "Resistant") croptypes <- allocateCroptypeCultivars(croptypes, "Mixture", c("Susceptible", "Resistant")) simul_params <- setCroptypes(simul_params, croptypes) Ncroptypes <- nrow(simul_params@Croptypes) Nyears <- simul_params@TimeParam$Nyears ## Same probability in every croptype: simul_params <- updateSurvivalProb(simul_params, mat_year=1:Nyears/100) simul_params@Pathogen ## Same probability every year: simul_params <- updateSurvivalProb(simul_params, mat_croptype=1:Ncroptypes/10) simul_params@Pathogen ## specific probability for different croptypes and years: simul_params <- updateSurvivalProb(simul_params , mat_year=1:Nyears/100, mat_croptype=1:Ncroptypes/10) simul_params@Pathogen ## One probability per year and per croptype: simul_params <- updateSurvivalProb(simul_params , mat=matrix(runif(Nyears*Ncroptypes), ncol=Ncroptypes)) simul_params@Pathogen survivalProbToMatrix(simul_params) ## End(Not run)
Generates a video showing the epidemic dynamics on a map representing the cropping landscape. (requires ffmpeg library).
video( audpc, time_param, Npatho, landscape, area, rotation, croptypes, croptype_names = c(), cultivars_param, keyDates = NULL, nMapPY = 10, path = getwd() )
video( audpc, time_param, Npatho, landscape, area, rotation, croptypes, croptype_names = c(), cultivars_param, keyDates = NULL, nMapPY = 10, path = getwd() )
audpc |
A dataframe containing audpc outputs (generated through epid_output). 1 line per year and 1 column per cultivar, with an additional column for the average audpc in the landscape. |
time_param |
list of simulation parameters:
|
Npatho |
number of pathogen genotypes. |
landscape |
a sp object containing the landscape. |
area |
a vector containing polygon areas (must be in square meters). |
rotation |
a dataframe containing for each field (rows) and year (columns, named "year_1", "year_2", etc.), the index of the cultivated croptype. Importantly, the matrix must contain 1 more column than the real number of simulated years. |
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. |
croptype_names |
a vector of croptype names (for legend). |
cultivars_param |
a list of parameters associated with each host genotype (i.e. cultivars) when cultivated in pure crops:
|
keyDates |
a vector of times (in time steps) where to draw vertical lines in the AUDPC graphic. Usually used to delimit durabilities of the resistance genes. No line is drawn if keyDates=NULL (default). |
nMapPY |
an integer specifying the number of epidemic maps per year to generate. |
path |
path where binary files are located and where the video will be generated. |
The left panel shows the year-after-year dynamics of AUDPC, for each cultivar as well as the global average. The right panel illustrates the landscape, where fields are hatched depending on the cultivated croptype, and coloured depending on the prevalence of the disease. Note that up to 9 different croptypes can be represented properly in the right panel.
A video file of format webM
## Not run: demo_landsepi() ## End(Not run)
## Not run: demo_landsepi() ## End(Not run)