Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CSIRO-INRA
landsepi
Commits
662ac0a5
Commit
662ac0a5
authored
Jul 19, 2021
by
Jean-Francois Rey
☕
Browse files
Merge remote-tracking branch 'upstream/master'
parents
e5e0748d
80bb0e2f
Changes
38
Expand all
Hide whitespace changes
Inline
Side-by-side
.Rbuildignore
View file @
662ac0a5
...
...
@@ -24,3 +24,6 @@
^doc$
^Meta$
^_pkgdown.yml$
^pkgdown$
^index.md$
.gitlab-ci.yml
View file @
662ac0a5
...
...
@@ -141,7 +141,7 @@ buildDocker:
after_script
:
-
docker logout $CI_REGISTRY
rules
:
-
if
:
$CI_COMMIT_BRANCH ==
"master"
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH'
deploy
:
image
:
debian
...
...
@@ -150,7 +150,7 @@ deploy:
name
:
shinyproxy
url
:
https://shiny.biosp.inrae.fr/
rules
:
-
if
:
$CI_COMMIT_BRANCH ==
"master"
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH'
before_script
:
-
apt-get update && apt-get install -y sshpass openssh-client
-
export SSHPASS=$DEPLOY_PWD
...
...
@@ -171,7 +171,5 @@ pages:
paths
:
-
public
rules
:
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
'
when
:
always
DESCRIPTION
View file @
662ac0a5
...
...
@@ -2,16 +2,26 @@ Package: landsepi
Type: Package
Encoding: UTF-8
Title: Landscape Epidemiology and Evolution
Version: 1.0.2
Date: 2020-11-26
Authors@R: c(person("Loup", "Rimbaud", role = "aut", email = "loup.rimbaud@inrae.fr"),
person("Julien", "Papaix", role = "aut", email = "julien.papaix@inrae.fr"),
person("Jean-Francois", "Rey", role = "cre", email = "jean-francois.rey@inrae.fr"),
person("Jean-Loup", "Gaussen", role = "ctb", email = "jean-loup-thomas.gaussen@inrae.fr"))
Author: Loup Rimbaud [aut],
Julien Papaix [aut],
Jean-Francois Rey [cre],
Jean-Loup Gaussen [ctb]
Version: 1.1.0
Date: 2021-07-19
Authors@R:
c(person(given = "Loup",
family = "Rimbaud",
role = "aut",
email = "loup.rimbaud@inrae.fr"),
person(given = "Julien",
family = "Papaix",
role = "aut",
email = "julien.papaix@inrae.fr"),
person(given = "Jean-François",
family = "Rey",
role = c("aut","cre"),
email = "jean-francois.rey@inrae.fr",
comment = c(ORCID = "0000-0003-3281-6701")),
person(given = "Jean-Loup",
family = "Gaussen",
role = "ctb",
email = "jean-loup-thomas.gaussen@inrae.fr"))
Maintainer: Jean-Francois Rey <jean-francois.rey@inrae.fr>
Description: A stochastic, spatially-explicit, demo-genetic model simulating the spread and evolution
of a plant pathogen in a heterogeneous landscape to assess resistance deployment strategies.
...
...
@@ -22,7 +32,9 @@ Description: A stochastic, spatially-explicit, demo-genetic model simulating the
respect to their epidemiological, evolutionary and economic outcomes.
Loup Rimbaud, Julien Papaïx, Jean-François Rey, Luke G Barrett,
Peter H Thrall (2018) <doi:10.1371/journal.pcbi.1006067>.
URL: https://gitlab.paca.inrae.fr/CSIRO-INRA/landsepi
URL: https://csiro-inra.pages.biosp.inrae.fr/landsepi/,
https://gitlab.paca.inra.fr/CSIRO-INRA/landsepi
BugReports: https://gitlab.paca.inrae.fr/CSIRO-INRA/landsepi/-/issues
License: GPL (>= 2) | file LICENSE
LazyData: true
...
...
R/AgriLand.R
View file @
662ac0a5
...
...
@@ -42,7 +42,8 @@
#' "rotation_sequence" are associated with the same level of aggregation.
#' @param 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.
#' "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.
#' @param croptype_names a vector of croptype names (for legend in graphic).
#' @param graphic a logical indicating if a graphic of the landscape must be generated (TRUE) or not (FALSE).
#' @param outputDir a directory to save graphic
...
...
R/GPKGTools.R
View file @
662ac0a5
...
...
@@ -128,7 +128,7 @@ GPKGAddTables <- function(gpkgfile) {
yield_L REAL NOT NULL CHECK(yield_L >= 0),
yield_I REAL NOT NULL CHECK(yield_I >= 0),
yield_R REAL NOT NULL CHECK(yield_R >= 0),
p
roduction
_cost REAL NOT NULL CHECK(p
roduction
_cost >= 0),
p
lanting
_cost REAL NOT NULL CHECK(p
lanting
_cost >= 0),
market_value REAL NOT NULL CHECK(market_value >= 0));"
)
...
...
R/Methods-LandsepiParams.R
View file @
662ac0a5
...
...
@@ -22,7 +22,7 @@
.croptypesColNames
<-
c
(
"croptypeID"
,
"croptypeName"
)
.cultivarsColNames
<-
c
(
"cultivarName"
,
"initial_density"
,
"max_density"
,
"growth_rate"
,
"reproduction_rate"
,
"death_rate"
,
"yield_H"
,
"yield_L"
,
"yield_I"
,
"yield_R"
,
"p
roduction
_cost"
,
"market_value"
)
,
"yield_R"
,
"p
lanting
_cost"
,
"market_value"
)
.cultivarsGenesColNames
<-
c
()
.geneColNames
<-
c
(
"geneName"
,
"efficiency"
,
"time_to_activ_exp"
,
"time_to_activ_var"
,
"mutation_prob"
,
"Nlevels_aggressiveness"
,
"fitness_cost"
...
...
@@ -465,7 +465,7 @@ saveDeploymentStrategy <- function(params, outputGPKG = "landsepi_landscape.gpkg
#' @param writeTXT a logical indicating if outputs must be written in text files (TRUE, default)
#' or not (FALSE).
#' @param videoMP4 a logical indicating if a video must be generated (TRUE) or not (FALSE, default).
#' Works only if graphic=TRUE and audpc is computed.
#' Works only if graphic=TRUE and audpc
_rel
is computed.
#' @param 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.
#' @details See ?landsepi for details on the model, assumptions and outputs, and our vignettes
...
...
@@ -559,8 +559,24 @@ runSimul <- function(params, graphic=TRUE, writeTXT=TRUE, videoMP4=FALSE, keepRa
initPath
<-
getwd
()
setwd
(
params
@
OutputDir
)
## remove genes not used from CultivarsGenes and Genes
if
(
ncol
(
params
@
CultivarsGenes
)
>=
1
)
{
drop_genes
<-
lapply
(
1
:
ncol
(
params
@
CultivarsGenes
),
FUN
=
function
(
c
)
{
if
(
sum
(
params
@
CultivarsGenes
[,
c
])
==
0
)
return
(
c
);
})
drop_genes
<-
which
(
!
sapply
(
drop_genes
,
is.null
))
}
else
{
drop_genes
<-
NULL
}
if
(
!
is.null
(
drop_genes
)
&&
length
(
drop_genes
)
>
0
){
print
(
paste0
(
"Genes not affected "
,
params
@
Genes
[
drop_genes
,
1
]))
cultivarsGenes_tmp
<-
params
@
CultivarsGenes
[,
-
drop_genes
]
Genes_tmp
<-
params
@
Genes
[
-
drop_genes
,]
}
else
{
cultivarsGenes_tmp
<-
params
@
CultivarsGenes
Genes_tmp
<-
params
@
Genes
}
cultivars_genes_list
<-
lapply
(
1
:
nrow
(
params
@
Cultivars
),
FUN
=
function
(
i
)
{
return
(
which
(
params
@
C
ultivarsGenes
[
i
,
]
==
1
)
-
1
)
return
(
which
(
c
ultivarsGenes
_tmp
[
i
,
]
==
1
)
-
1
)
})
cdf
<-
as.data.frame
(
params
@
Landscape
)
...
...
@@ -576,7 +592,7 @@ runSimul <- function(params, graphic=TRUE, writeTXT=TRUE, videoMP4=FALSE, keepRa
croptype_names
=
params
@
Croptypes
$
croptypeName
,
cultivars
=
params
@
Cultivars
,
cultivars_genes_list
=
cultivars_genes_list
,
genes
=
params
@
Genes
,
genes
=
Genes
_tmp
,
landscape
=
as_Spatial
(
st_geometry
(
params
@
Landscape
)),
area
=
as.vector
(
params
@
Landscape
$
area
[,
1
]),
rotation
=
rotation
,
...
...
@@ -723,7 +739,8 @@ setLandscape <- function(params, land) {
params
@
Landscape
$
area
<-
data.frame
(
area
=
st_area
(
params
@
Landscape
))
## Initialise host and pathogen dispersal with diagonal matrices
if
(
length
(
params
@
DispHost
)
==
0
){
if
(
length
(
params
@
DispHost
)
==
0
|
length
(
params
@
DispHost
)
!=
(
nrow
(
params
@
Landscape
))
^
2
){
disp_host
<-
loadDispersalHost
(
params
,
type
=
"no"
)
params
<-
setDispersalHost
(
params
,
disp_host
)
}
...
...
@@ -1007,7 +1024,8 @@ checkDispersalHost <- function(params) {
#' @param 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.
#' If algo="random", the parameter aggreg is not used.
#' Algorithm "exp" is preferable for big landscapes.
#' @param graphic a logical indicating if graphics must be generated (TRUE) or not (FALSE).
#' @details 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
...
...
@@ -1143,7 +1161,7 @@ loadPathogen <- function(disease = "rust") {
#' for a pathogen genotype not adapted to resistance: \itemize{
#' \item infection_rate = maximal expected infection rate of a propagule on a healthy host,
#' \item propagule_prod_rate = maximal expected effective propagule production rate of an
#' infectious host per timestep,
#' infectious host per time
step,
#' \item latent_period_exp = minimal expected duration of the latent period,
#' \item latent_period_var = variance of the latent period duration,
#' \item infectious_period_exp = maximal expected duration of the infectious period,
...
...
@@ -1508,7 +1526,7 @@ loadCultivar <- function(name, type = "growingHost") {
"yield_L"
=
0.0
,
"yield_I"
=
0.0
,
"yield_R"
=
0.0
,
"p
roduction
_cost"
=
225
,
"p
lanting
_cost"
=
225
,
"market_value"
=
200
),
"nongrowingHost"
=
list
(
...
...
@@ -1522,7 +1540,7 @@ loadCultivar <- function(name, type = "growingHost") {
"yield_L"
=
0.0
,
"yield_I"
=
0.0
,
"yield_R"
=
0.0
,
"p
roduction
_cost"
=
225
,
"p
lanting
_cost"
=
225
,
"market_value"
=
200
),
"nonCrop"
=
list
(
...
...
@@ -1536,7 +1554,7 @@ loadCultivar <- function(name, type = "growingHost") {
"yield_L"
=
0.0
,
"yield_I"
=
0.0
,
"yield_R"
=
0.0
,
"p
roduction
_cost"
=
0
,
"p
lanting
_cost"
=
0
,
"market_value"
=
0
),
list
()
...
...
@@ -1565,31 +1583,32 @@ loadCultivar <- function(name, type = "growingHost") {
#' @details 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:\itemize{
#' \item cultivarName: cultivar names (cannot accept space),
#' \item initial_density: host densities (per square meter) at the beginning of the cropping season,
#' \item max_density: maximum host densities (per square meter) at the end of the cropping season,
#' \item initial_density: host densities (per square meter) at the beginning of the cropping season
#' as if cultivated in pure crop,
#' \item max_density: maximum host densities (per square meter) at the end of the cropping season
#' as if cultivated in pure crop,
#' \item growth rate: host growth rates,
#' \item reproduction rate: host reproduction rates,
#' \item death rate: host death rates,
#' \item yield_H: yield (in weight or volume units / ha / cropping season)
#' associated with hosts in sanitary status H,
#' \item yield_L: yield (in weight or volume units / ha / cropping season)
#' associated with hosts in sanitary status L,
#' \item yield_I: yield (in weight or volume units / ha / cropping season)
#' associated with hosts in sanitary status I,
#' \item yield_R: yield (in weight or volume units / ha / cropping season)
#' associated with hosts in sanitary status R,
#' \item production_cost = overall production costs (in monetary units / ha / cropping season)
#' including planting costs, amortisation, labour etc.,
#' \item market_value = market values of the productions (in monetary units / weight or volume unit).
#' \item 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,
#' \item 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,
#' \item 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,
#' \item 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,
#' \item planting_cost = planting costs (in monetary units / ha / cropping season) as if cultivated in pure crop,
#' \item 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 | death_rate | yield_H | yield_L | yield_I |yield_R | p
roduction
_cost | market_value |
#' | ------------ | --------------- | ----------- | ----------- | ----------------- | ---------- | ------- | ------- | ------- | ------ | -------------
--
| ------------ |
#' | Susceptible | 0.1 | 2.0 | 0.1 | 0.0 | 0.0 | 2.5 | 0.0 | 0.0 | 0.0 | 225
| 200 |
#' | Resistant1 | 0.1 | 2.0 | 0.1 | 0.0 | 0.0 | 2.5 | 0.0 | 0.0 | 0.0 | 225
| 200 |
#' | Resistant2 | 0.1 | 2.0 | 0.1 | 0.0 | 0.0 | 2.5 | 0.0 | 0.0 | 0.0 | 225
| 200 |
#' | cultivarName | initial_density | max_density | growth_rate | reproduction_rate | death_rate | yield_H | yield_L | yield_I |yield_R | p
lanting
_cost | market_value |
#' | ------------ | --------------- | ----------- | ----------- | ----------------- | ---------- | ------- | ------- | ------- | ------ | ------------- | ------------ |
#' | Susceptible | 0.1 | 2.0 | 0.1 | 0.0 | 0.0 | 2.5 | 0.0 | 0.0 | 0.0 | 225 | 200 |
#' | Resistant1 | 0.1 | 2.0 | 0.1 | 0.0 | 0.0 | 2.5 | 0.0 | 0.0 | 0.0 | 225 | 200 |
#' | Resistant2 | 0.1 | 2.0 | 0.1 | 0.0 | 0.0 | 2.5 | 0.0 | 0.0 | 0.0 | 225 | 200 |
#'
#' @return a LandsepiParams object
#' @seealso \link{loadCultivar}
...
...
@@ -1659,7 +1678,7 @@ checkCultivars <- function(params) {
!
is.numeric
(
params
@
Cultivars
$
yield_L
)
||
!
is.numeric
(
params
@
Cultivars
$
yield_I
)
||
!
is.numeric
(
params
@
Cultivars
$
yield_R
)
||
!
is.numeric
(
params
@
Cultivars
$
p
roduction
_cost
)
||
!
is.numeric
(
params
@
Cultivars
$
p
lanting
_cost
)
||
!
is.numeric
(
params
@
Cultivars
$
market_value
)
||
sum
(
!
is.positive
(
params
@
Cultivars
$
initial_density
)
)
>
0
||
...
...
@@ -1667,9 +1686,9 @@ checkCultivars <- function(params) {
sum
(
!
is.positive
(
params
@
Cultivars
$
yield_L
)
)
>
0
||
sum
(
!
is.positive
(
params
@
Cultivars
$
yield_I
)
)
>
0
||
sum
(
!
is.positive
(
params
@
Cultivars
$
yield_R
)
)
>
0
||
sum
(
!
is.positive
(
params
@
Cultivars
$
p
roduction
_cost
)
)
>
0
||
sum
(
!
is.positive
(
params
@
Cultivars
$
p
lanting
_cost
)
)
>
0
||
sum
(
!
is.positive
(
params
@
Cultivars
$
market_value
)
)
>
0
){
warning
(
"initial_density, yield, p
roduction
_cost and market_value must be >= 0"
)
warning
(
"initial_density, yield, p
lanting
_cost and market_value must be >= 0"
)
ret
<-
FALSE
}
...
...
@@ -2029,15 +2048,17 @@ checkInoculum <- function(params) {
#' @param 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):\itemize{
#' \item "audpc" : Area Under Disease Progress Curve (average proportion of diseased hosts relative
#' to the carryng capacity)
#' \item "gla_abs" : Absolute Green Leaf Area (average number of healthy hosts per square meter)
#' \item "gla_rel" : Relative Green Leaf Area (average proportion of healthy hosts relative to the
#' \item "audpc" : Area Under Disease Progress Curve (average number of diseased host individuals
#' per time step and square meter)
#' \item "audpc_rel" : Relative Area Under Disease Progress Curve (average proportion of diseased host
#' individuals relative to the total number of existing hosts)
#' \item "gla" : Green Leaf Area (average number of healthy host individuals per time step and square meter)
#' \item "gla_rel" : Relative Green Leaf Area (average proportion of healthy host individuals relative to the
#' total number of existing hosts)
#' \item "eco_
cost
" : total crop
costs
(in weight or volume units per ha)
#' \item "eco_
product" : total crop production
(in monetary units per ha)
#' \item "eco_
benefi
t" : total crop
benefi
ts (in monetary units per ha)
#' \item "eco_
gross
margin" :
Gross
Margin (
benefits -
costs, in monetary units per ha)
#' \item "eco_
yield
" : total crop
yield
(in weight or volume units per ha)
#' \item "eco_
cost" : operational crop costs
(in monetary units per ha)
#' \item "eco_
produc
t" : total crop
produc
ts (in monetary units per ha)
#' \item "eco_margin" : Margin (
products - operational
costs, in monetary units per ha)
#' \item "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.
...
...
@@ -2063,7 +2084,7 @@ loadOutputs <- function(epid_outputs = "all", evol_outputs = "all"){
,
evol_outputs
=
evol_outputs
,
thres_breakdown
=
50000
,
GLAnoDis
=
1.48315
,
audpc100S
=
0.
38
)
,
audpc100S
=
0.
76
)
return
(
outputList
)
}
...
...
@@ -2084,21 +2105,23 @@ loadOutputs <- function(epid_outputs = "all", evol_outputs = "all"){
#' \item GLAnoDis = the absolute Green Leaf Area in absence of disease (used to compute
#' economic outputs).
#' \item audpc100S = the audpc in a fully susceptible landscape (used as reference value
#' for graphics
and video
).
#' for graphics).
#' }
#' @details "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:
#' \itemize{
#' \item "audpc" : Area Under Disease Progress Curve (average proportion of diseased hosts relative
#' to the carryng capacity)
#' \item "gla_abs" : Absolute Green Leaf Area (average number of healthy hosts per square meter)
#' \item "gla_rel" : Relative Green Leaf Area (average proportion of healthy hosts relative to the
#' \item "audpc" : Area Under Disease Progress Curve (average number of diseased host individuals
#' per time step and square meter)
#' \item "audpc_rel" : Relative Area Under Disease Progress Curve (average proportion of diseased host
#' individuals relative to the total number of existing hosts)
#' \item "gla" : Green Leaf Area (average number of healthy host individuals per square meter)
#' \item "gla_rel" : Relative Green Leaf Area (average proportion of healthy host individuals relative to the
#' total number of existing hosts)
#' \item "eco_
cost
" : total crop
costs
(in weight or volume units per ha)
#' \item "eco_
product" : total crop production
(in monetary units per ha)
#' \item "eco_
benefi
t" : total crop
benefi
ts (in monetary units per ha)
#' \item "eco_
gross
margin" :
Gross
Margin (
benefi
ts - costs, in monetary units per ha)
#' \item "eco_
yield
" : total crop
yield
(in weight or volume units per ha)
#' \item "eco_
cost" : operational crop costs
(in monetary units per ha)
#' \item "eco_
produc
t" : total crop
produc
ts (in monetary units per ha)
#' \item "eco_margin" : Margin (
produc
ts - costs, in monetary units per ha)
#' \item "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.
...
...
R/RcppExports.R
View file @
662ac0a5
...
...
@@ -118,7 +118,7 @@
#' L = as.numeric(cultivars$yield_L),
#' I = as.numeric(cultivars$yield_I),
#' R = as.numeric(cultivars$yield_R)),
#' p
roduction
_cost_perHa = as.numeric(cultivars$p
roduction
_cost),
#' p
lanting
_cost_perHa = as.numeric(cultivars$p
lanting
_cost),
#' market_value = as.numeric(cultivars$market_value))
#'
#' evol_res <- evol_output(, time_param, Npoly, cultivars, genes)
...
...
R/demo_landsepi.R
View file @
662ac0a5
...
...
@@ -128,7 +128,7 @@ demo_landsepi <- function(seed = 12345, strat = "MO", Nyears = 20, nTSpY = 120,
# yield_L = rep(0.0, 3),
# yield_I = rep(0.0, 3),
# yield_R = rep(0.0, 3),
# p
roduction
_cost = rep(225, 3),
# p
lanting
_cost = rep(225, 3),
# market_value = rep(200, 3),
# stringsAsFactors = FALSE)
simul_params
<-
setCultivars
(
simul_params
,
cultivars
)
...
...
R/graphics.R
View file @
662ac0a5
...
...
@@ -75,13 +75,16 @@ plotland <- function(landscape, COL = rep(0, length(landscape)), DENS = rep(0, l
}
if
(
LEGEND1
[
1
]
!=
""
)
{
if
(
TITLE.LEG2
==
""
)
{
legend
(
bounds
$
xmax
/
2.66
,
-
bounds
$
ymax
/
40
,
legend
=
LEGEND1
,
fill
=
COL.LEG
,
bty
=
"n"
)
legend
(
bounds
$
xmin
+
(
bounds
$
xmax
-
bounds
$
xmin
)
/
2.66
,
bounds
$
ymin
-
(
bounds
$
ymax
-
bounds
$
ymin
)
/
40
,
# bounds$xmax / 2.66, -bounds$ymax / 40,
# mean(c(bounds$xmin, bounds$xmax)), bounds$ymin,
legend
=
LEGEND1
,
fill
=
COL.LEG
,
bty
=
"n"
)
}
else
{
legend
(
bounds
$
xm
ax
/
2.66
,
-
bounds
$
ymax
/
40
,
legend
=
LEGEND1
,
col
=
"black"
,
density
=
2
*
DENS.LEG
,
angle
=
ANGLE.LEG
,
bty
=
"n"
)
legend
(
-
bounds
$
xmax
/
5
,
bounds
$
ymax
,
legend
=
LEGEND2
,
fill
=
COL.LEG
,
bty
=
"n"
,
title
=
TITLE.LEG2
)
legend
(
bounds
$
xm
in
+
(
bounds
$
xmax
-
bounds
$
xmin
)
/
2.66
,
bounds
$
ymin
-
(
bounds
$
ymax
-
bounds
$
ymin
)
/
40
,
# bounds$xmax / 2.66, -bounds$ymax / 40
,
legend
=
LEGEND1
,
col
=
"black"
,
density
=
2
*
DENS.LEG
,
angle
=
ANGLE.LEG
,
bty
=
"n"
)
legend
(
bounds
$
xmin
-
(
bounds
$
xmax
-
bounds
$
xmin
)
/
5
,
bounds
$
ymax
,
legend
=
LEGEND2
,
fill
=
COL.LEG
,
bty
=
"n"
,
title
=
TITLE.LEG2
)
}
}
}
...
...
R/landsepi.R
View file @
662ac0a5
...
...
@@ -37,8 +37,8 @@
#' @details \tabular{ll}{
#' Package: \tab landsepi\cr
#' Type: \tab Package\cr
#' Version: \tab 1.
0.2
\cr
#' Date: \tab 202
0-11-26
\cr
#' Version: \tab 1.
1.0
\cr
#' Date: \tab 202
1-07-19
\cr
#' License: \tab GPL (>=2)\cr
#' }
#'
...
...
@@ -52,7 +52,8 @@
#' 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 field). *landsepi* includes built-in simulated landscapes
#' (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.
#'
...
...
@@ -98,9 +99,10 @@
#' \describe{
#' \item{\strong{Assumptions} (in bold those that can be relaxed with appropriate parameterization): }{
#' \enumerate{
#' \item The spatial unit is the field, 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 field is considered a homogeneous mixture of individuals (i.e. there is no
#' intra-field structuration).
#' \item 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). A field may be composed
#' of a single or several polygons..
#' \item Host individuals are in one of these four categories: H (healthy),
#' E (latent, i.e. infected but not infectious nor symptomatic), I (infectious and symptomatic),
#' or R (removed, i.e. epidemiologically inactive).
...
...
@@ -116,6 +118,9 @@
#' susceptible to disease from the first to the last day of every cropping season.
#' \item 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.**
#' \item Components of a mixture are independent each other (i.e. there is neither plant-plant interaction
#' nor competition for space, and harvests are segregated).
#' \item The pathogen is haploid.
#' \item Initially, the pathogen is not adapted to any source of resistance, and is only present on
#' susceptible hosts (at state I).
#' \item **Pathogen dispersal is isotropic (i.e. equally probable in every direction).**
...
...
@@ -129,19 +134,22 @@
#' \item When there is a delay for activation of a given resistance gene (APR), the time to activation is the same for
#' all hosts carrying this gene and located in the same field.
#' \item Variances of the durations of the latent and the infectious periods of the pathogen are not affected by plant resistance.
#' \item If there is sexual reproduction (or gene recombination), it occurs only between parental infections located in the same field
#' and the same host genotype. The propagule production rate of a couple is the sum of the propagule production rates of the parents.
#' The genotype of each daughter propagule is issued from random loci segregation between parental loci.
#' \item If there is sexual reproduction (or gene recombination), it occurs only between parental infections located
#' in the same polygon and the same host genotype. The host population is panmictic (i.e. all pairs of parents have
#' the same probability to occur). The propagule production rate of a couple is the sum of the propagule production
#' rates of the parents. The genotype of each daughter propagule is issued from random loci segregation between parental loci.
#' }
#' }
#' \item{\strong{Epidemiological outputs}}{
#' The epidemiological outcome of a deployment strategy is evaluated using: \enumerate{
#' \item the area under the disease progress curve (AUDPC) to measure disease severity
#' (i.e. the average proportion of diseased hosts -status I and R- relative to the carrying capacity),
#' \item the absolute Green Leaf Area (GLAa) to measure the average amount of healthy tissue (status H),
#' (i.e. the average number of diseased plant tissue -status I and R- per time step and square meter),
#' \item 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).
#' \item the Green Leaf Area (GLA) to measure the average amount of healthy plant tissue (status H) per time step and square meter,
#' \item the relative Green Leaf Area (GLAr) to measure the average proportion of healthy tissue (status H)
#' relative to the total number of existing hosts (H+L+I+R).
#' relative to the total number of existing host
individual
s (H+L+I+R).
#' }
#' A set of graphics and a video showing epidemic dynamics can also be generated.
#' }
...
...
@@ -159,13 +167,13 @@
#' \item{\strong{Economic outputs}}{
#' The economic outcome of a simulation can be evaluated using: \enumerate{
#' \item the crop
production
: yearly crop production (e.g. grains, fruits, wine) in weight (or volume) units
#' per hectare (depends on the number of productive hosts and associated yield),
#' \item the crop
benefi
ts: yearly
benefi
ts generated from
product
sales, in monetary units per hectare
#' (depends on crop
production
and market value
of the product
),
#' \item the crop costs: yearly costs associated with crop p
roduction (including planting, amortisation, labour, ...)
#'
in monetary units per hectare (depends on initial host density and p
roduction
cost),
#' \item the
gross
margin, i.e.
benefits -
costs, in monetary units per hectare.
#' \item 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),
#' \item the crop
produc
ts: yearly
produc
ts generated from sales, in monetary units per hectare
#' (depends on crop
yield
and market value),
#' \item the crop
operational
costs: yearly costs associated with crop p
lanting,
#' in monetary units per hectare (depends on initial host density and p
lanting
cost),
#' \item the margin, i.e.
products - operational
costs, in monetary units per hectare.
#' }
#' }
#' }
...
...
R/output.R
View file @
662ac0a5
This diff is collapsed.
Click to expand it.
R/runShiny.R
View file @
662ac0a5
...
...
@@ -10,9 +10,9 @@ runShinyApp <- function() {
stop
(
"Could not find example directory. Try re-installing `landsepi`."
,
call.
=
FALSE
)
}
needed_packages
<-
c
(
"shiny"
,
"DT"
,
"shinyjs"
,
"gridExtra"
,
"png"
,
"grid"
,
"future"
,
"promises"
,
"tools"
)
needed_packages
<-
c
(
"shiny"
,
"shinyBS"
,
"shinyalert"
,
"DT"
,
"shinyjs"
,
"gridExtra"
,
"png"
,
"grid"
,
"future"
,
"promises"
,
"tools"
)
if
(
sum
(
needed_packages
%in%
utils
::
installed.packages
()[,
1
]
==
FALSE
)
!=
0
)
{
stop
(
'Install packages : install.packages(c("shiny","DT", "shinyjs", "gridExtra", "png", "grid", "future", "promises", "tools"))'
)
stop
(
'Install packages : install.packages(c("shiny",
"shinyBS", "shinyalert",
"DT", "shinyjs", "gridExtra", "png", "grid", "future", "promises", "tools"))'
)
}
shiny
::
runApp
(
appDir
,
launch.browser
=
TRUE
,
display.mode
=
"normal"
)
...
...
R/simul_landsepi.R
View file @
662ac0a5
...
...
@@ -33,18 +33,23 @@
#' @param cultivars a dataframe of parameters associated with each host genotype (i.e. cultivars)
#' when cultivated in pure crops. Columns of the dataframe are:\itemize{
#' \item cultivarName: cultivar names,
#' \item initial_density: host densities (per square meter) at the beginning of the cropping season,
#' \item max_density: maximum host densities (per square meter) at the end of the cropping season,
#' \item growth rate: host growth rates,
#' \item initial_density: host densities (per square meter) at the beginning of the cropping season
#' as if cultivated in pure crop,
#' \item max_density: maximum host densities (per square meter) at the end of the cropping season
#' as if cultivated in pure crop,
#' \item growth_rate: host growth rates,
#' \item reproduction rate: host reproduction rates,
#' \item death rate: host death rates,
#' \item yield_H: yield (in weight or volume units / ha / cropping season) associated with hosts in sanitary status H,
#' \item yield_L: yield (in weight or volume units / ha / cropping season) associated with hosts in sanitary status L,
#' \item yield_I: yield (in weight or volume units / ha / cropping season) associated with hosts in sanitary status I,
#' \item yield_R: yield (in weight or volume units / ha / cropping season) associated with hosts in sanitary status R,
#' \item production_cost = overall production costs (in monetary units / ha / cropping season)
#' including planting costs, amortisation, labour etc.,
#' \item market_value = market values of the productions (in monetary units / weight or volume unit).
#' \item death_rate: host death rates,
#' \item 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,
#' \item 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,
#' \item 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,
#' \item 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,
#' \item planting_cost = planting costs (in monetary units / ha / cropping season) as if cultivated in pure crop,
#' \item market_value = market values of the production (in monetary units / weight or volume unit).
#' }
#' @param cultivars_genes_list a list containing, for each host genotype, the indices of carried resistance genes.
#' @param genes a data.frame of parameters associated with each resistance gene and with the evolution of
...
...
@@ -71,7 +76,7 @@
#' @param basic_patho_param a list of pathogen aggressiveness parameters on a susceptible host
#' for a pathogen genotype not adapted to resistance: \itemize{
#' \item infection_rate = maximal expected infection rate of a propagule on a healthy host,
#' \item propagule_prod_rate = maximal expected effective propagule production rate of an infectious host per timestep,
#' \item propagule_prod_rate = maximal expected effective propagule production rate of an infectious host per time
step,
#' \item latent_period_exp = minimal expected duration of the latent period,
#' \item latent_period_var = variance of the latent period duration,
#' \item infectious_period_exp = maximal expected duration of the infectious period,
...
...
@@ -91,15 +96,17 @@
#' @param 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):
#' \itemize{
#' \item "audpc" : Area Under Disease Progress Curve (average proportion of diseased hosts relative
#' to the carryng capacity)
#' \item "gla_abs" : Absolute Green Leaf Area (average number of healthy hosts per square meter)
#' \item "gla_rel" : Relative Green Leaf Area (average proportion of healthy hosts relative to the
#' \item "audpc" : Area Under Disease Progress Curve (average number of diseased host individuals
#' per time step and square meter)
#' \item "audpc_rel" : Relative Area Under Disease Progress Curve (average proportion of diseased host
#' individuals relative to the total number of existing hosts)
#' \item "gla" : Green Leaf Area (average number of healthy host individuals per time step and square meter)
#' \item "gla_rel" : Relative Green Leaf Area (average proportion of healthy host individuals relative to the
#' total number of existing hosts)
#' \item "eco_
cost
" : total crop
costs
(in weight or volume units per ha)
#' \item "eco_
product" : total crop production
(in monetary units per ha)
#' \item "eco_
benefi
t" : total crop
benefi
ts (in monetary units per ha)
#' \item "eco_
gross
margin" :
Gross
Margin (
benefits -
costs, in monetary units per ha)
#' \item "eco_
yield
" : total crop
yield
(in weight or volume units per ha)
#' \item "eco_
cost" : operational crop costs
(in monetary units per ha)
#' \item "eco_
produc
t" : total crop
produc
ts (in monetary units per ha)
#' \item "eco_margin" : Margin (
products - operational
costs, in monetary units per ha)
#' \item "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.
...
...
@@ -118,11 +125,11 @@
#' 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).
#' @param GLAnoDis the absolute Green Leaf Area in absence of disease (used to compute economic outputs).
#' @param audpc100S the audpc in a fully susceptible landscape (used as reference value for graphics
and video
).
#' @param audpc100S the audpc in a fully susceptible landscape (used as reference value for graphics).
#' @param writeTXT a logical indicating if outputs must be written in text files (TRUE, default) or not (FALSE).
#' @param graphic a logical indicating if graphics must be generated (TRUE, default) or not (FALSE).
#' @param videoMP4 a logical indicating if a video must be generated (TRUE) or not (FALSE, default).
#' Works only if graphic=TRUE and epid_outputs="audpc" (or epid_outputs="all").
#' Works only if graphic=TRUE and epid_outputs="audpc
_rel
" (or epid_outputs="all").
#' @param 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.
#' @details See ?landsepi for details on the model and assumptions.
...
...
@@ -234,7 +241,7 @@ simul_landsepi <- function(seed = 12345, time_param = list(Nyears = 20, nTSpY =
genes
,
landscape
=
NULL
,
area
,
rotation
,
basic_patho_param
,
disp_patho
,
disp_host
,
pI0
=
5e-4
,
epid_outputs
=
"all"
,
evol_outputs
=
"all"
,
thres_breakdown
=
50000
,
GLAnoDis
=
1.48315
,
audpc100S
=
0.38
,
GLAnoDis
=
1.48315
,
audpc100S
=
0.76
,
#
0.38,
writeTXT
=
TRUE
,
graphic
=
TRUE
,
videoMP4
=
FALSE
,
keepRawResults
=
FALSE
)
{
# Host parameters
...
...
@@ -250,7 +257,7 @@ simul_landsepi <- function(seed = 12345, time_param = list(Nyears = 20, nTSpY =
sigmoid_plateau_host
=
1
,
cultivars_genes_list
=
cultivars_genes_list
)
# Evolution parameters
genes_param
<-
list
(
name
=
as.character
(
genes
$
geneName
),
...
...
@@ -272,7 +279,7 @@ simul_landsepi <- function(seed = 12345, time_param = list(Nyears = 20, nTSpY =
I
=
as.numeric
(
cultivars
$
yield_I
),
R
=
as.numeric
(
cultivars
$
yield_R
)
),
p
roduction
_cost_perHa
=
as.numeric
(
cultivars
$
p
roduction
_cost
),
p
lanting
_cost_perHa
=
as.numeric
(
cultivars
$
p
lanting
_cost
),
market_value
=
as.numeric
(
cultivars
$
market_value
)
)
...
...
@@ -321,12 +328,13 @@ simul_landsepi <- function(seed = 12345, time_param = list(Nyears = 20, nTSpY =
## Limits for graphics
ylim_param
<-
list
(
audpc
=
c
(
0
,
audpc100S
),
gla_abs
=
c
(
0
,
GLAnoDis
),
audpc_rel
=
c
(
0
,
1
),
gla
=
c
(
0
,
GLAnoDis
),
gla_rel
=
c
(
0
,
1
),
<