Commit 4d053bb0 authored by loup.rimbaud@csiro.au's avatar loup.rimbaud@csiro.au
Browse files

correction of seed; documentation; epidemic maps

parent cedf3ede
Pipeline #61 failed with stage
in 5 minutes and 44 seconds
......@@ -7,6 +7,8 @@ export(invlogit)
export(logit)
export(modeleLandsLPI)
export(multiN)
export(periodic_cov)
export(plot.evol.QR)
export(plot.land)
import(MASS)
import(RCALI)
......
#' @title AgriLand
#' @title Landscape generation
#' @name AgriLand
#' @description Generate a landscape composed of fields where a susceptible (SC) and one (RC) or two (RC1 and RC2) resistant cultivars
#' are allocated with controlled proportions and spatio-temporal aggregation
#' @param landscape a spatialpolygon object containing field coordinates
......@@ -12,12 +13,13 @@
#' @param nYears number of simulated years
#' @param Cmax0 carrying capacity of the susceptible cultivar
#' @param Cmax1 carrying capacity of the resistant cultivars
#' @param seed seed value (for random number generator)
#' @param graphOn if a graph of the landscape must be generated
#' @details An algorithm based on latent Gaussian fields is used to allocate two different crop cultivars across the simulated landscapes
#' (e.g. a susceptible and a resistant cultivar, denoted as SC and RC, respectively). This algorithm allows the control of the proportions
#' of each cultivar in terms of surface coverage, and their level of spatial aggregation. A random vector of values is drawn from a
#' 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 crop cultivars are allocated to different fields depending on whether the each value drawn from the
#' the centroids of the fields. Next, the crop cultivars 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. The sequential use of this algorithm allows the allocation of more than two crop cultivars (e.g. SC, RC1 and RC2).
#' Therefore, deployment strategies involving two sources of resistance is simulated by:
......@@ -38,8 +40,8 @@
#' data(landscapeTEST)
#' AgriLand(landscapeTEST,filename="landscapeTEST",propSR=2/3,isolSR=3,propRR=1/2,isolRR=3,strat="MO",Nhote=3,nYears=30,Cmax0=2,Cmax1=2,graphOn=1)
#' @export
AgriLand <- function(landscape,filename="landscapeTEST",propSR,isolSR,propRR,isolRR,strat,Nhote,nYears,Cmax0,Cmax1,graphOn){
AgriLand <- function(landscape,filename="landscapeTEST",propSR,isolSR,propRR,isolRR,strat,Nhote,nYears,Cmax0,Cmax1,seed,graphOn){
set.seed(seed)
nPoly.tmp <- length(landscape)
prop <- c(propSR, propRR)
isol <- c(isolSR, isolRR)
......
#' @title HLIRdynamics
#' @description generate epidemiological and evolutionary outputs from simulations
#' @param pathRES path to resultats
#' @param graphOn if graphics of the output must be generated
#' @param times times
#' @param landscape a landscape
#' @param host host
#' @param epiP epiP
#' @param evolP evolP
#' @param th_break break
#' @param nMapPY nMapPY
#' @return binary files
#' @title Generation of model outputs
#' @name HLIRdynamics
#' @description Generate epidemiological and evolutionary outputs from model simulations.
#' @param pathRES path of the repository where outputs will be generated
#' @param graphOn if graphics of the outputs must be generated
#' @param times list of simulation parameters (number of years, number of time-steps per year)
#' @param landscape agricultural landscape generated through AgriLand
#' @param hostP list of host parameters (number of cultivars, growth rate of the susceptible cultivar, reproduction rate of the susceptible cultivar,
#' growth rate of resistant cultivars, reproduction rate of resistant cultivars, death rate, number of possible resistance sources (8)
#' , resistance formula, parameters of the sigmoid invasion function: kappa, sigma and s)
#' @param epiP list of pathogen parameters (probability to survive the off-season, infection rate
#' , reproduction rate, average latent period duration, variance of the latent period, average infectious period duration
#' , variance of the infectious period duration, parameters of the sigmoid contamination function: kappa, sigma, s)
#' @param evolP list of evolution parameters (cost of infectivity, cost of aggressiveness, mutation rate, efficiency of major
#' resistance genes, efficiency of quantitative resistance, trade-off strength, number of increments of quantitative
#' resistance erosion, adaptation formula)
#' @param th_break threshold (number of infections) above which mutant pathogen are unlikely to go extinct, used to
#' characterise resistance breakdown
#' @param nMapPY number of epidemic maps per year to generate
#' @details Evolutionary outputs. Durability of qualitative resistance: For a given major gene, several computations are
#' performed: (d1) time to first appearance of a pathogen mutant; (d2) time to first true infection of a resistant host by such mutants; and
#' (d3) time when the number of infections of resistant hosts by these mutants reaches a threshold above which mutant pathogens are unlikely to go extinct.
#' Erosion of quantitative resistance: pathogen adaptation to quantitative resistance is gradual, so the three measures described above are computed for every step
#' towards complete erosion of resistance (i.e. nAgw-1 levels). Durability of a deployment strategy: a simulation run is divided into three periods:
#' (1) the initial short-term period when all resistance sources are at their highest potential; (2) a transitory period during which a given deployment strategy
#' is only partially effective; and (3) a longer-term period when all the resistances have been overcome or completely eroded.
#' To assess the end of the short-term period, the time to establishment (durability measure (d3)) is computed for every major gene, and every quantitative trait
#' at the first level of erosion (agw(p)=2). The minimal value of these measures, denoted by D1, delimitates short-term and transitory periods.
#' Similarly, the time to establishment is computed for every major gene, and for every quantitative trait at the highest level of erosion (agw(p)=nAgw).
#' The maximal value of these measures, termed D2, delimits transitory and long-term periods.
#' Epidemiological outputs. The epidemiological impact of pathogen spread is evaluated by two different measures: Green Leaf Area (GLA) and
#' Area Under Disease Progress Curve (AUDPC). The GLA represents the average number of productive hosts per time step and per surface unit. The AUDPC
#' is the average proportion of diseased hosts relative to the carrying capacity and represents disease severity.
#' Global epidemiological control: The GLA and AUDPC of every cultivar as well as the whole landscape are averaged across the whole simulation run,
#' to measure the global epidemiological performance of a deployment strategy. Short-term epidemiological control: The average GLA and AUDPC of the susceptible
#' cultivar is computed on whole cropping seasons from the beginning of the simulation until the end of the season preceding year before D1.
#' Epidemiological control during the transitory period: The average GLA and AUDPC of the susceptible cultivar is computed on whole seasons from the
#' beginning of the season following year after D1 to the end of the season year before preceding D2. Long-term epidemiological control:
#' The average GLA and AUDPC of the whole landscape is computed on whole seasons from the beginning of the season followingyear after D2 to the end of the simulation.
#' @return A set of text files containing all outputs of the simulations: durability, AUDPC, GLA. A set of graphics of host and pathogen dynamics, AUDPC, GLA, and epidemic
#' maps can also be generated.
#' @examples
#' demo_landsepi()
#' @include RcppExports.R logit.R invlogit.R graphLand.R
#' @importFrom sf st_read
#' @importFrom grDevices colorRampPalette dev.off graphics.off gray png tiff
#' @importFrom utils write.table
#' @export
HLIRdynamics <- function(pathRES, graphOn, times, landscape, hostP, epiP, evolP,th_break=50000, nMapPY=0){
#### PARAMETERS ####
nYears <- times$nYears
nTSpY <- times$nTSpY
......@@ -693,7 +721,7 @@ if (graphOn==1) {
, lty=c(1:Nhote,4), lwd=2, pch=PCH[c(1:Nhote,4)], pt.cex=c(rep(1,Nhote),1.5), col=c(rep("black",Nhote), COL.tot), seg.len=2.5)
## Map dynamic of diseased hosts
plot.land(landscape, RED[intvlsIR], dens.H[hab], angle.H[hab], RED, dens.H, angle.H, title.IR, subtitle.H, legend.hab, legend.H, "(I+R)/K")
plot.land(trans.landscape_tmp, RED[intvlsIR], dens.H[hab], angle.H[hab], RED, dens.H, angle.H, title.IR, subtitle.H, legend.hab, legend.H, "(I+R)/K")
dev.off()
} ## for d
} ## for y
......
......@@ -3,18 +3,42 @@
#' @title Modele Lands LPI
#' @name modeleLandsLPI
#' @description Modele ...
#' @param times simulation years and step
#' @param dispersion dispersion features
#' @param landscape list of landscape file name and layer name
#' @param inits list inits variables
#' @param val_seed seed value
#' @param host host param
#' @param epiP epiP val
#' @param evolP evolP val
#' @return nothing yet
#' @description Stochastic, spatially-explicit, demo-genetic model simulating the spread and evolution of a pathogen in a heterogeneous landscape.
#' @param times list of simulation parameters (number of years, number of time-steps per year)
#' @param landscape landscape generated through AgriLand
#' @param dispersal list of dispersal parameters (vectorised dispersal matrix of the pathogen, vectorised dispersal matrix of the host)
#' @param inits list initial conditions (host planting density, initial probability of infection by the pathogen)
#' @param val_seed seed (for random number generation)
#' @param hostP list of host parameters (number of cultivars, growth rate of the susceptible cultivar, reproduction rate of the susceptible cultivar,
#' growth rate of resistant cultivars, reproduction rate of resistant cultivars, death rate, number of possible resistance sources (8)
#' , resistance formula, parameters of the sigmoid invasion function: kappa, sigma and s)
#' @param epiP list of pathogen parameters (probability to survive the off-season, infection rate
#' , reproduction rate, average latent period duration, variance of the latent period, average infectious period duration
#' , variance of the infectious period duration, parameters of the sigmoid contamination function: kappa, sigma, s)
#' @param evolP list of evolution parameters (cost of infectivity, cost of aggressiveness, mutation rate, efficiency of major
#' resistance genes, efficiency of quantitative resistance, trade-off strength, number of increments of quantitative
#' resistance erosion, adaptation formula)
#' @details The model is stochastic, spatially explicit (the basic spatial unit is an individual field), based on a SEIR
#' (‘susceptible-exposed-infectious-removed’) structure with a discrete time step. It simulates the spread and evolution
#' of a pathogen in an agricultural landscape, across cropping seasons split by host harvests which impose potential bottlenecks
#' to the pathogen. A wide array of deployment strategies can be simulated: mosaics, mixtures, rotations and pyramiding of multiple
#' major resistance genes which affect pathogen infectivity, and up to four quantitative resistance traits.
#' These traits target different aggressiveness components of the pathogen, i.e. the infection rate, the duration of the latent
#' period and the infectious period, and the propagule production rate. Initially, the pathogen is not adapted to any source of
#' resistance, and is only present on susceptible hosts. However, through mutation, it can evolve and may acquire infectivity
#' genes (which leads to breakdown of major resistance genes) or increase aggressiveness (which leads to the erosion of the
#' relevant quantitative resistance traits). However, evolution of a pathogen toward infectivity or increased aggressiveness on
#' a resistant host is often penalised by a fitness cost on susceptible hosts. Consequently, in the present model, pathogens
#' carrying infectivity genes may have reduced infection rate (cost of infectivity) on susceptible hosts relative
#' to pathogens that do not carry these genes. Similarly, a gain in pathogen aggressiveness on quantitatively resistant hosts
#' is penalised by a decreased aggressiveness on susceptible hosts, leading to a trade-off.
#' @return A set of binary files is generated for every year of simulation and every compartment
#' (H: healthy hosts, Hjuv: juvenile healthy hosts, L: latently infected hosts, I: infectious hosts, R: removed hosts, S: propagules).
#' Each file indicates for every time-step the number of individuals in each field, and when appropriate for each cultivar and pathotype)
#' @examples
#' demo_landsepi()
#' @export
modeleLandsLPI <- function(times, landscape, dispersion, inits, val_seed, host, epiP, evolP) {
invisible(.Call('_landsepi_modeleLandsLPI', PACKAGE = 'landsepi', times, landscape, dispersion, inits, val_seed, host, epiP, evolP))
modeleLandsLPI <- function(times, landscape, dispersal, inits, val_seed, hostP, epiP, evolP) {
invisible(.Call('_landsepi_modeleLandsLPI', PACKAGE = 'landsepi', times, landscape, dispersal, inits, val_seed, hostP, epiP, evolP))
}
......@@ -19,6 +19,7 @@
#' @export
demo_landsepi <- function(){
seed=12345
#outputs
pathRES <- getwd()
graphOn <- 1
......@@ -30,11 +31,11 @@ demo_landsepi <- function(){
isolRR=3 ## Class of aggregation between R1 and R2 (0:3 with 1=low, 2=medium, 3=high, 4=random aggregation)
strat <- "MO"
Nhote <- 3
nYears <- 30
nYears <- 5
Cmax0 <- 2
Cmax1 <- 2
data(landscapeTEST)
landscape <- AgriLand(landscapeTEST,filename="paysageTEST",propSR,isolSR,propRR,isolRR,strat,Nhote,nYears,Cmax0,Cmax1,graphOn)
landscape <- AgriLand(landscapeTEST,filename="paysageTEST",propSR,isolSR,propRR,isolRR,strat,Nhote,nYears,Cmax0,Cmax1,seed,graphOn)
#time parameters
nTSpY = 120
......@@ -91,25 +92,17 @@ demo_landsepi <- function(){
#initial conditions
C_0 <- 0.1
PI0 <- 5e-4
seed=12345
#run the model!
modeleLandsLPI(times = paramT,
modeleLandsLPI(paramT,
landscape,
dispersion=list(dispP=dispP,dispH=dispH),
dispersal=list(dispP=dispP,dispH=dispH),
inits=list(C_0=C_0, PI0=PI0),
val_seed=seed,
host=paramH,
hostP=paramH,
epiP=paramepi,
evolP=paramevol)
times <- paramT
hostP <- paramH
epiP <- paramepi
evolP <- paramevol
HLIRdynamics(pathRES, graphOn, times, landscape, hostP, epiP, evolP)
## generate the output
HLIRdynamics(pathRES, graphOn, paramT, landscape, paramH, epiP=paramepi, evolP=paramevol,nMapPY=0)
}
#' @title plot.land
#' @description plot a landscape with colors or hatched lines on fields
#' @title Plotting the landscape
#' @name plot.land
#' @description Plot a landscape with colors or hatched lines on fields
#' @param landscape a spatialpolygon object containing field coordinates
#' @param COL vector containing the color of each field
#' @param DENS vector containing the density of hatched lines for each field
......
#' @title invlogit
#' @title Inverse logit function
#' @name invlogit
#' @description Given a numeric object return the invlogit of the values. Missing values (NAs) are allowed.
#' @param x a numeric object
#' @details The invlogit is defined by exp(x) / (1+exp(x)). Values in x of -Inf or Inf return invlogits of 0 or 1 respectively. Any NAs in the input will also be NAs in the output.
......
#' @title logit
#' @title Logit function
#' @name logit
#' @description Given a numeric object return the logit of the values. Missing values (NAs) are allowed.
#' @param x a numeric object containing values between 0 and 1
#' @details The logit is defined by log(x/(1-x)). 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.
......
#' @title multiN
#' @description Use a multivariate normal distribution to An algorithm based on latent Gaussian fields is used to allocate two different crop cultivars across the simulated landscapes Given a numeric object return the invlogit of the values. Missing values (NAs) are allowed.
#' @param x a numeric object
#' @details The invlogit is defined by exp(x) / (1+exp(x)). Values in x of -Inf or Inf return invlogits of 0 or 1 respectively. Any NAs in the input will also be NAs in the output.
#' @return An object of the same type as x containing the invlogits of the input values.
#' @title Allocation of cultivars
#' @name multiN
#' @description Algorithm based on latent Gaussian fields to allocate two different crop cultivars across the simulated landscapes.
#' @param d a matrix of the pairwise distances between the centroids of the fields of the landscape.
#' @param area vector containing the areas of the fields.
#' @param aggreg level of spatial aggregation (<0 for fragmented landscapes, >0 for aggregated landscapes, =0 for random allocation of cultivars).
#' @param prop relative proportion of the second crop.
#' @details This algorithm allows the control of the proportions of each cultivar in terms of surface coverage, and their level of spatial aggregation.
#' A random vector of values is drawn from a multivariate normal distribution with expectation 0 and a variance-covariance matrix
#' which depends on the pairwise distances between the centroids of the fields. The variance-covariance matrix is computed from a periodic function for highly
#' fragmented or highly aggregated landscapes, an exponential function for moderately aggregated landscapes, and from a normal distribution for a random allocation of
#' cultivars. Next, the crop cultivars are allocated to different fields depending on whether the 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 (parameter prop).
#' @return A dataframe containing the index of each field (column 1) and the index (0 or 1) of the cultivar grown on these fields (column 2).
#' @examples
#' d <- matrix(rpois(100,100), nrow=10)
#' area <- data.frame(num=1:10, area=10)
#' ## Fragmented landscape
#' multiN(d, area, aggreg=-2, prop=0.5)
#' @export
#'
## take the matrix d to compute the allocation of cultivars
multiN <- function(d, area, aggreg, prop) {
nPoly <- nrow(area)
......
## periodic covariance function
#' @title Periodic covariance function
#' @name periodic_cov
#' @description Periodic function used to compute the variance-covariance matrix of the fields of the landscape.
#' @param d a numeric object containing pairwise distances between the centroids of the fields
#' @param range range (half-period of oscillations)
#' @param phi amplitude of the oscillations
#' @details The periodic covariance is defined by exp(-2 * sin(d*pi/(2*range))^2 / phi^2). It is used to generate highly fragmented or highly aggregated landscapes.
#' @return An object of the same type as d.
#' @examples
#' periodic_cov(10, range=5)
#' @export
periodic_cov <- function(d,range,phi=1) { return( exp(-2 * sin(d*pi/(2*range))^2 / phi^2) ) }
#' @title Ploting pathotype frequencies
#' @name plot.evol.QR
#' @description Plot the dynamic of pathotype frequencies in a tiff file.
#' @param pathRES the path of the repository where the graphic will be generated
#' @param nIncr number of pathotypes
#' @param trait index of the evolving trait (1 to 4 for major genes, 5 to 8 for quantitative resistance traits against infection rate (5), latent period (6), reproduction rate (7) and infectious period duration (8))
#' @param I_aggrProp a matrix giving the frequency of every pathotype (row) for every time-step (columns)
#' @param D durability of the trait
#' @param nTS number of simulated time-steps
#' @param nYears number of simulated years
#' @param nTSpY number of time-steps per year
#' @examples
#' freqMatrix <- matrix(0, nrow=2, ncol=100)
#' freqMatrix[2,26:100] <- (26:100)/100
#' freqMatrix[1,] <- 1-freqMatrix[2,]
#' plot.evol.QR(getwd(), nIncr=2, trait=1, freqMatrix, D=25, nTS=100,nYears=10,nTSpY=10)
#' @export
plot.evol.QR <- function(pathRES, nIncr,trait, I_aggrProp, D, nTS,nYears,nTSpY) {
COL.grey <- gray(0:150/150)
COL.grey <- COL.grey[length(COL.grey):1]
TITLE <- "Aggressiveness trait"
LABELS <- c("\nS specialist",rep(NA,nIncr-2),"\nR specialist")
if (trait < 5) {
TITLE <- "Infectivity gene"
LABELS <- c("\nNot infective","\nInfective")
}
tiff(file=paste(pathRES,"/EVOLpatho_", names(D), ".tiff",sep=""),width=100,height=100,units='mm',compression='lzw',res=300)
par(xpd=F, mar=c(4,4,2,2))
image(x=1:nIncr, y=1:nTS, z=I_aggrProp, col=COL.grey, ylab="", xlab="Phenotype", main=paste(TITLE,names(D)), axes=F, zlim=c(0,1), ylim=c(1,nTS+1))
box()
axis(side=1, at=1:nIncr, labels=LABELS)
if (nYears==1) {
axis(2, at=round(seq(1,nTS,length.out=8)), las=1)
title(ylab="Evolutionnary time (days)")
} else {
axis(2, at=seq(1,nTS+1,nTSpY*((nYears-1)%/%8+1)), labels=seq(0,nYears,((nYears-1)%/%8+1)), las=1)
title(ylab="Evolutionnary time (years)")
}
if (!is.na(D) & D<=nTS)
abline(h=D, col="blue", lty=trait+1, lwd=2.5) ## durability of the trait
dev.off()
}
COL.grey <- gray(0:150/150)
COL.grey <- COL.grey[length(COL.grey):1]
TITLE <- "Aggressiveness trait"
LABELS <- c("\nS specialist",rep(NA,nIncr-2),"\nR specialist")
if (trait < 5) {
TITLE <- "Infectivity gene"
LABELS <- c("\nNot infective","\nInfective")
}
tiff(file=paste(pathRES,"/EVOLpatho_", names(D), ".tiff",sep=""),width=100,height=100,units='mm',compression='lzw',res=300)
par(xpd=F, mar=c(4,4,2,2))
image(x=1:nIncr, y=1:nTS, z=I_aggrProp, col=COL.grey, ylab="", xlab="Phenotype", main=paste(TITLE,names(D)), axes=F, zlim=c(0,1), ylim=c(1,nTS+1))
box()
axis(side=1, at=1:nIncr, labels=LABELS)
if (nYears==1) {
axis(2, at=round(seq(1,nTS,length.out=8)), las=1)
title(ylab="Evolutionnary time (days)")
} else {
axis(2, at=seq(1,nTS+1,nTSpY*((nYears-1)%/%8+1)), labels=seq(0,nYears,((nYears-1)%/%8+1)), las=1)
title(ylab="Evolutionnary time (years)")
}
if (!is.na(D) & D<=nTS)
abline(h=D, col="blue", lty=trait+1, lwd=2.5) ## durability of the trait
dev.off()
}
......
......@@ -2,10 +2,10 @@
% Please edit documentation in R/AgriLand.R
\name{AgriLand}
\alias{AgriLand}
\title{AgriLand}
\title{Landscape generation}
\usage{
AgriLand(landscape, filename = "landscapeTEST", propSR, isolSR, propRR,
isolRR, strat, Nhote, nYears, Cmax0, Cmax1, graphOn)
isolRR, strat, Nhote, nYears, Cmax0, Cmax1, seed, graphOn)
}
\arguments{
\item{landscape}{a spatialpolygon object containing field coordinates}
......@@ -30,6 +30,8 @@ AgriLand(landscape, filename = "landscapeTEST", propSR, isolSR, propRR,
\item{Cmax1}{carrying capacity of the resistant cultivars}
\item{seed}{seed value (for random number generator)}
\item{graphOn}{if a graph of the landscape must be generated}
}
\description{
......@@ -41,7 +43,7 @@ An algorithm based on latent Gaussian fields is used to allocate two different c
(e.g. a susceptible and a resistant cultivar, denoted as SC and RC, respectively). This algorithm allows the control of the proportions
of each cultivar in terms of surface coverage, and their level of spatial aggregation. A random vector of values is drawn from a
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 crop cultivars are allocated to different fields depending on whether the each value drawn from the
the centroids of the fields. Next, the crop cultivars 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. The sequential use of this algorithm allows the allocation of more than two crop cultivars (e.g. SC, RC1 and RC2).
Therefore, deployment strategies involving two sources of resistance is simulated by:
......
......@@ -2,11 +2,11 @@
\alias{dispH}
\docType{data}
\title{
dispH
Host dispersal data for testing.
%% ~~ data name/kind ... ~~
}
\description{
description
A vectorised dispersal matrix of the host.
%% ~~ A concise (1-5 lines) description of the dataset. ~~
}
\usage{data("disp")}
......@@ -15,7 +15,7 @@
num [1:24025] 1 0 0 0 0 0 0 0 0 0 ...
}
\details{
details
In this example, the host is a cultivated plant: seeds are harvested and do not disperse. Thus the dispersal matrix is the identity matrix.
%% ~~ If necessary, more details than the __description__ above ~~
}
\source{
......@@ -23,7 +23,6 @@
%% ~~ reference to a publication or URL from which the data were obtained ~~
}
\references{
ref
%% ~~ possibly secondary sources and usages ~~
}
\examples{
......
......@@ -2,11 +2,11 @@
\alias{dispP}
\docType{data}
\title{
dispP
Pathogen dispersal data for testing.
%% ~~ data name/kind ... ~~
}
\description{
description
A vectorised dispersal matrix of the pathogen.
%% ~~ A concise (1-5 lines) description of the dataset. ~~
}
\usage{data("disp")}
......@@ -15,7 +15,7 @@
num [1:24025] 5.85e-01 1.54e-02 3.70e-05 1.84e-05 2.41e-03 ...
}
\details{
details
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).
%% ~~ If necessary, more details than the __description__ above ~~
}
\source{
......@@ -23,7 +23,7 @@
%% ~~ reference to a publication or URL from which the data were obtained ~~
}
\references{
ref
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.
%% ~~ possibly secondary sources and usages ~~
}
\examples{
......
......@@ -5,7 +5,7 @@
A landscape for testing
}
\description{
a fucking landscape for testing
A landscape for testing, composed of 155 fields.
}
\usage{data("landscapeTEST")}
\format{
......@@ -1210,7 +1210,10 @@ Formal class 'SpatialPolygons' [package "sp"] with 4 slots
.. .. ..@ projargs: chr NA
}
\details{
some details
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.
}
\references{
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.
}
\examples{
library(sp)
......
......@@ -4,28 +4,55 @@
\alias{modeleLandsLPI}
\title{Modele Lands LPI}
\usage{
modeleLandsLPI(times, landscape, dispersion, inits, val_seed, host, epiP, evolP)
modeleLandsLPI(times, landscape, dispersal, inits, val_seed, hostP, epiP, evolP)
}
\arguments{
\item{times}{simulation years and step}
\item{times}{list of simulation parameters (number of years, number of time-steps per year)}
\item{landscape}{list of landscape file name and layer name}
\item{landscape}{landscape generated through AgriLand}
\item{dispersion}{dispersion features}
\item{dispersal}{list of dispersal parameters (vectorised dispersal matrix of the pathogen, vectorised dispersal matrix of the host)}
\item{inits}{list inits variables}
\item{inits}{list initial conditions (host planting density, initial probability of infection by the pathogen)}
\item{val_seed}{seed value}
\item{val_seed}{seed (for random number generation)}
\item{host}{host param}
\item{hostP}{list of host parameters (number of cultivars, growth rate of the susceptible cultivar, reproduction rate of the susceptible cultivar,
growth rate of resistant cultivars, reproduction rate of resistant cultivars, death rate, number of possible resistance sources (8)
, resistance formula, parameters of the sigmoid invasion function: kappa, sigma and s)}
\item{epiP}{epiP val}
\item{epiP}{list of pathogen parameters (probability to survive the off-season, infection rate
, reproduction rate, average latent period duration, variance of the latent period, average infectious period duration
, variance of the infectious period duration, parameters of the sigmoid contamination function: kappa, sigma, s)}
\item{evolP}{evolP val}
\item{evolP}{list of evolution parameters (cost of infectivity, cost of aggressiveness, mutation rate, efficiency of major
resistance genes, efficiency of quantitative resistance, trade-off strength, number of increments of quantitative
resistance erosion, adaptation formula)}
}
\value{
nothing yet
A set of binary files is generated for every year of simulation and every compartment
(H: healthy hosts, Hjuv: juvenile healthy hosts, L: latently infected hosts, I: infectious hosts, R: removed hosts, S: propagules).
Each file indicates for every time-step the number of individuals in each field, and when appropriate for each cultivar and pathotype)
}
\description{
Modele ...
Stochastic, spatially-explicit, demo-genetic model simulating the spread and evolution of a pathogen in a heterogeneous landscape.
}
\details{
The model is stochastic, spatially explicit (the basic spatial unit is an individual field), based on a SEIR
(‘susceptible-exposed-infectious-removed’) structure with a discrete time step. It simulates the spread and evolution
of a pathogen in an agricultural landscape, across cropping seasons split by host harvests which impose potential bottlenecks
to the pathogen. A wide array of deployment strategies can be simulated: mosaics, mixtures, rotations and pyramiding of multiple
major resistance genes which affect pathogen infectivity, and up to four quantitative resistance traits.
These traits target different aggressiveness components of the pathogen, i.e. the infection rate, the duration of the latent
period and the infectious period, and the propagule production rate. Initially, the pathogen is not adapted to any source of
resistance, and is only present on susceptible hosts. However, through mutation, it can evolve and may acquire infectivity
genes (which leads to breakdown of major resistance genes) or increase aggressiveness (which leads to the erosion of the
relevant quantitative resistance traits). However, evolution of a pathogen toward infectivity or increased aggressiveness on
a resistant host is often penalised by a fitness cost on susceptible hosts. Consequently, in the present model, pathogens
carrying infectivity genes may have reduced infection rate (cost of infectivity) on susceptible hosts relative
to pathogens that do not carry these genes. Similarly, a gain in pathogen aggressiveness on quantitatively resistant hosts
is penalised by a decreased aggressiveness on susceptible hosts, leading to a trade-off.
}
\examples{
demo_landsepi()
}
......@@ -2,7 +2,7 @@
% Please edit documentation in R/graphLand.R
\name{plot.land}
\alias{plot.land}
\title{plot.land}
\title{Plotting the landscape}
\usage{
plot.land(landscape, COL = rep(0, length(landscape)), DENS = rep(0,
length(landscape)), ANGLE = rep(30, length(landscape)),
......@@ -41,7 +41,7 @@ plot.land(landscape, COL = rep(0, length(landscape)), DENS = rep(0,
\item{YMAX}{maximal coordinate on vertical axis}
}
\description{
plot a landscape with colors or hatched lines on fields
Plot a landscape with colors or hatched lines on fields
}
\examples{
## Draw a landscape with various colours
......
......@@ -627,7 +627,7 @@ void sortie_layer(OGRLayer *poLayer,int **H,int Npoly, int Nhote, int pastemps,
/*------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------------------*/
void modeleLandsLPI(Rcpp::List times, Rcpp::List landscape, Rcpp::List dispersion, Rcpp::List inits ,int val_seed, Rcpp::List host, Rcpp::List epiP, Rcpp::List evolP) {
void modeleLandsLPI(Rcpp::List times, Rcpp::List landscape, Rcpp::List dispersal, Rcpp::List inits ,int val_seed, Rcpp::List hostP, Rcpp::List epiP, Rcpp::List evolP) {
int nYears = Rcpp::as<int>(times["nYears"]);
......@@ -652,25 +652,25 @@ void modeleLandsLPI(Rcpp::List times, Rcpp::List landscape, Rcpp::List dispersio
rotation[roti]=*it;
}
//CharacterVector nomfile_disppatho = Rcpp::as<CharacterVector>(dispersion["dispP"]);
//CharacterVector nomfile_disphote = Rcpp::as<CharacterVector>(dispersion["dispH"]);
NumericVector dispP_tmp=Rcpp::as<NumericVector>(dispersion["dispP"]);
NumericVector dispH_tmp=Rcpp::as<NumericVector>(dispersion["dispH"]);
//CharacterVector nomfile_disppatho = Rcpp::as<CharacterVector>(dispersal["dispP"]);
//CharacterVector nomfile_disphote = Rcpp::as<CharacterVector>(dispersal["dispH"]);
NumericVector dispP_tmp=Rcpp::as<NumericVector>(dispersal["dispP"]);
NumericVector dispH_tmp=Rcpp::as<NumericVector>(dispersal["dispH"]);
double C_0 = Rcpp::as<double>(inits["C_0"]);
double PI0 = Rcpp::as<double>(inits["PI0"]);
int Nhote = Rcpp::as<int>(host["Nhote"]);
double CROISH0 = Rcpp::as<double>(host["croisH0"]);
double CROISH1 = Rcpp::as<double>(host["croisH1"]);
double REPROH0 = Rcpp::as<double>(host["reproH0"]);
double REPROH1 = Rcpp::as<double>(host["reproH1"]);
double MORTH = Rcpp::as<double>(host["deathH"]);
double khote = Rcpp::as<double>(host["khost"]);
double sighote = Rcpp::as<double>(host["sighost"]);
double shote = Rcpp::as<double>(host["shost"]);
int Ntrait = Rcpp::as<int>(host["Ntrait"]);
IntegerVector resistance_tmp = Rcpp::as<IntegerVector>(host["resistance"]);
int Nhote = Rcpp::as<int>(hostP["Nhote"]);
double CROISH0 = Rcpp::as<double>(hostP["croisH0"]);
double CROISH1 = Rcpp::as<double>(hostP["croisH1"]);
double REPROH0 = Rcpp::as<double>(hostP["reproH0"]);
double REPROH1 = Rcpp::as<double>(hostP["reproH1"]);
double MORTH = Rcpp::as<double>(hostP["deathH"]);
double khote = Rcpp::as<double>(hostP["khost"]);