Commit 0519fe7e authored by Loup's avatar Loup
Browse files

Update names of eco params and variables

parent 1d76e09b
......@@ -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", "production_cost", "market_value")
, "yield_R", "planting_cost", "market_value")
.cultivarsGenesColNames <- c()
.geneColNames <- c("geneName", "efficiency", "time_to_activ_exp", "time_to_activ_var"
, "mutation_prob", "Nlevels_aggressiveness", "fitness_cost"
......@@ -1145,7 +1145,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,
......@@ -1510,7 +1510,7 @@ loadCultivar <- function(name, type = "growingHost") {
"yield_L" = 0.0,
"yield_I" = 0.0,
"yield_R" = 0.0,
"production_cost" = 225,
"planting_cost" = 225,
"market_value" = 200
),
"nongrowingHost" = list(
......@@ -1524,7 +1524,7 @@ loadCultivar <- function(name, type = "growingHost") {
"yield_L" = 0.0,
"yield_I" = 0.0,
"yield_R" = 0.0,
"production_cost" = 225,
"planting_cost" = 225,
"market_value" = 200
),
"nonCrop" = list(
......@@ -1538,7 +1538,7 @@ loadCultivar <- function(name, type = "growingHost") {
"yield_L" = 0.0,
"yield_I" = 0.0,
"yield_R" = 0.0,
"production_cost" = 0,
"planting_cost" = 0,
"market_value" = 0
),
list()
......@@ -1567,31 +1567,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 | production_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 | planting_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}
......@@ -1661,7 +1662,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$production_cost) ||
!is.numeric(params@Cultivars$planting_cost) ||
!is.numeric(params@Cultivars$market_value) ||
sum( !is.positive(params@Cultivars$initial_density) ) > 0 ||
......@@ -1669,9 +1670,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$production_cost) ) > 0 ||
sum( !is.positive( params@Cultivars$planting_cost) ) > 0 ||
sum( !is.positive(params@Cultivars$market_value) ) > 0 ){
warning("initial_density, yield, production_cost and market_value must be >= 0")
warning("initial_density, yield, planting_cost and market_value must be >= 0")
ret <- FALSE
}
......@@ -2031,15 +2032,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_product" : total crop production (in weight or volume units per ha)
#' \item "eco_cost" : total crop costs (in monetary units per ha)
#' \item "eco_benefit" : total crop benefits (in monetary units per ha)
#' \item "eco_grossmargin" : 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_product" : total crop products (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.
......@@ -2092,15 +2095,17 @@ loadOutputs <- function(epid_outputs = "all", evol_outputs = "all"){
#' 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_product" : total crop production (in weight or volume units per ha)
#' \item "eco_cost" : total crop costs (in monetary units per ha)
#' \item "eco_benefit" : total crop benefits (in monetary units per ha)
#' \item "eco_grossmargin" : 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_product" : total crop products (in monetary units per ha)
#' \item "eco_margin" : Margin (products - 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.
......
......@@ -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 individuals (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 benefits: yearly benefits 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 production (including planting, amortisation, labour, ...)
#' in monetary units per hectare (depends on initial host density and production 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 products: yearly products 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 planting,
#' in monetary units per hectare (depends on initial host density and planting cost),
#' \item the margin, i.e. products - operational costs, in monetary units per hectare.
#' }
#' }
#' }
......
......@@ -23,12 +23,13 @@
#' @param 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):\itemize{
#' \item "audpc": Area Under Disease Progress Curve
#' \item "gla_abs": Absolute Green Leaf Area
#' \item "audpc_rel": Relative Area Under Disease Progress Curve
#' \item "gla": Green Leaf Area
#' \item "gla_rel": Relative Green Leaf Area
#' \item "eco_product": Crop production
#' \item "eco_cost": Crop costs
#' \item "eco_benefit": Crop benefits
#' \item "eco_grossmargin": Gross Margin (benefits - costs)
#' \item "eco_yield": Total crop yield
#' \item "eco_cost": Operational crop costs
#' \item "eco_product": Crop products
#' \item "eco_margin": Margin (products - operational costs)
#' \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.
......@@ -48,42 +49,46 @@
#' @param cultivars_param list of parameters associated with each host genotype (i.e. cultivars):
#' \itemize{
#' \item name = vector of cultivar names,
#' \item initial_density = vector of host densities (per square meter) at the beginning of the cropping season,
#' \item max_density = vector of maximum host densities (per square meter) at the end of the cropping season,
#' \item initial_density = vector of host densities (per square meter) at the beginning of the cropping season
#' as if cultivated in pure crop,
#' \item max_density = vector of maximum host densities (per square meter) at the end of the cropping season
#' as if cultivated in pure crop,
#' \item cultivars_genes_list = a list containing, for each host genotype, the indices of carried resistance genes.
#' }
#' @param eco_param a list of economic parameters for each host genotype as if cultivated in pure crop:\itemize{
#' \item yield_perHa = a dataframe of 4 columns for the yield associated with hosts in sanitary status H, L, I and R,
#' and one row per host genotype (yields are expressed in weight or volume units / ha / cropping season),
#' \item production_cost_perHa = a vector of overall production costs (in monetary units / ha / cropping season)
#' including planting costs, amortisation, labour etc.,
#' \item market_value = a vector of market values of the productions (in monetary units / weight or volume unit).
#' \item yield_perHa = a dataframe of 4 columns for the theoretical yield associated with hosts in sanitary status H, L, I and R,
#' as if cultivated in pure crops, and one row per host genotype
#' (yields are expressed in weight or volume units / ha / cropping season),
#' \item planting_cost_perHa = a vector of planting costs (in monetary units / ha / cropping season),
#' \item market_value = a vector of market values of the production (in monetary units / weight or volume unit).
#' }
#' @param GLAnoDis the value of absolute GLA in absence of disease (required to compute economic outputs).
#' @param ylim_param a list of graphical parameters for each required output: bounds for y-axes for
#' audpc, gla_abs, gla_rel, eco_cost, eco_product, eco_benefit, eco_grossmargin.
#' audpc, gla, gla_rel, eco_cost, eco_yield, eco_product, eco_margin.
#' @param writeTXT a logical indicating if the output is written in a text file (TRUE) or not (FALSE).
#' @param graphic a logical indicating if a tiff graphic of the output is generated (only if more than one year is simulated).
#' @param path path of text file (if writeTXT = TRUE) and tiff graphic (if graphic = TRUE) to be generated.
#' @details Outputs are computed every year for every cultivar as well as for the whole landscape. \describe{
#' \item{\strong{Epidemiological outputs.}}{
#' The epidemiological impact of pathogen spread can be evaluated by different measures: \enumerate{
#' \item Area Under Disease Progress Curve (AUDPC): average proportion of diseased hosts (status I + R)
#' relative to the carrying capacity (i.e. disease severity).
#' \item Absolute Green Leaf Area (GLAa): average number of healthy hosts (status H) per time step and per square meter.
#' \item Relative Green Leaf Area (GLAr): average proportion of healthy hosts (status H) relative to the total number
#' \item Area Under Disease Progress Curve (AUDPC): average number of diseased host individuals (status I + R)
#' per time step and square meter.
#' \item 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).
#' \item Green Leaf Area (GLA): average number of healthy host individuals (status H) per time step and per square meter.
#' \item 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).
#' }
#' }
#' \item{\strong{Economic outputs.}}{
#' The economic outcome of a simulation can be evaluated using: \enumerate{
#' \item 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 Crop benefits: yearly benefits generated from product sales, in monetary units per hectare
#' (depends on crop production and market value of the product).
#' \item Crop costs: yearly costs associated with crop production (including planting, amortisation, labour, ...)
#' in monetary units per hectare (depends on initial host density and production cost).
#' \item Crop gross margin, i.e. benefits - costs, in monetary units per hectare.
#' \item 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).
#' \item Crop products: yearly product generated from sales, in monetary units per hectare
#' (depends on crop yield and market value).
#' \item Operational crop costs: yearly costs associated with crop planting in monetary units per hectare
#' (depends on initial host density and planting cost).
#' \item Crop margin, i.e. products - operational costs, in monetary units per hectare.
#' }
#' }
#' }
......@@ -106,15 +111,16 @@ epid_output <- function(types = "all", time_param, Npatho, area, rotation, cropt
GLAnoDis = cultivars_param$max_density[1] ## true for non-growing host
, ylim_param = list(
audpc = c(0, 0.38),
gla_abs = c(0, 1.48),
audpc_rel = c(0, 1),
gla = c(0, 1.48),
gla_rel = c(0, 1),
eco_cost = c(0, NA),
eco_yield = c(0, NA),
eco_product = c(0, NA),
eco_benefit = c(0, NA),
eco_grossmargin = c(NA, NA)
eco_margin = c(NA, NA)
),
writeTXT = TRUE, graphic = TRUE, path = getwd()) {
valid_outputs <- c("audpc", "gla_abs", "gla_rel", "eco_product", "eco_benefit", "eco_cost", "eco_grossmargin", "HLIR_dynamics")
valid_outputs <- c("audpc", "audpc_rel", "gla", "gla_rel", "eco_yield", "eco_product", "eco_cost", "eco_margin", "HLIR_dynamics")
if (types[1] == "all") {
types <- valid_outputs
}
......@@ -139,7 +145,7 @@ epid_output <- function(types = "all", time_param, Npatho, area, rotation, cropt
max_density <- cultivars_param$max_density
cultivars_genes_list <- cultivars_param$cultivars_genes_list
yield_perIndivPerTS <- eco_param$yield_perHa * 1E-4 / nTSpY / GLAnoDis
production_cost_perIndiv <- eco_param$production_cost_perHa * 1E-4 / initial_density
planting_cost_perIndiv <- eco_param$planting_cost_perHa * 1E-4 / initial_density
market_value <- eco_param$market_value
Nhost <- length(initial_density)
......@@ -174,8 +180,8 @@ epid_output <- function(types = "all", time_param, Npatho, area, rotation, cropt
## IMPORTATION OF THE SIMULATION OUTPUT (only those required depending on parameter "types")
requireH <- sum(is.element(substr(types, 1, 3), c("gla", "eco"))) > 0
requireL <- sum(is.element(types, c("gla_rel", "eco_product", "eco_benefit", "eco_cost", "eco_grossmargin"))) > 0
requireIR <- sum(is.element(types, c("audpc", "gla_rel", "eco_product", "eco_benefit", "eco_cost", "eco_grossmargin"))) > 0
requireL <- sum(is.element(types, c("audpc_rel", "gla_rel", "eco_yield", "eco_product", "eco_cost", "eco_margin"))) > 0
requireIR <- sum(is.element(types, c("audpc", "audpc_rel", "gla_rel", "eco_yield", "eco_product", "eco_cost", "eco_margin"))) > 0
if (graphic & sum(substr(types, nchar(types) - 7, nchar(types)) == "dynamics") > 0) {
requireH <- 1
requireL <- 1
......@@ -352,7 +358,7 @@ epid_output <- function(types = "all", time_param, Npatho, area, rotation, cropt
numerator <- sum(as.numeric(I_host[host, ts_year]), as.numeric(R_host[host, ts_year]))
denominator <- sum(as.numeric(K_host[host, y] * length(ts_year)))
},
"gla_abs" = {
"gla" = {
numerator <- sum(as.numeric(H_host[host, ts_year]))
denominator <- nTSpY * areaTot
},
......@@ -392,7 +398,7 @@ epid_output <- function(types = "all", time_param, Npatho, area, rotation, cropt
output_matrix[y, "total"] <- numerator_tot / denominator_tot
}
},
{ ## i.e. if gla_abs | substr(type,1,3)=="eco"
{ ## i.e. if gla | substr(type,1,3)=="eco"
output_matrix[y, "total"] <- sum(output_matrix[y, 1:Nhost], na.rm = TRUE)
}
)
......@@ -400,22 +406,22 @@ epid_output <- function(types = "all", time_param, Npatho, area, rotation, cropt
## Economic outputs
if (substr(type, 1, 3) == "eco") {
eco <- list(eco_product = output_matrix)
eco[["eco_benefit"]] <- data.frame(rep(market_value, each = Nyears) * eco[["eco_product"]][, 1:Nhost])
eco <- list(eco_yield = output_matrix)
eco[["eco_product"]] <- data.frame(rep(market_value, each = Nyears) * eco[["eco_yield"]][, 1:Nhost])
## data.frame to avoid pb when Nhost=1
colnames(eco[["eco_benefit"]]) <- cultivar_names ## useful if Nhost=1
eco[["eco_benefit"]]$total <- apply(eco[["eco_benefit"]], 1, sum, na.rm = TRUE)
eco[["eco_cost"]] <- data.frame(rep(production_cost_perIndiv, each = Nyears) * t(C_host))
colnames(eco[["eco_product"]]) <- cultivar_names ## useful if Nhost=1
eco[["eco_product"]]$total <- apply(eco[["eco_product"]], 1, sum, na.rm = TRUE)
eco[["eco_cost"]] <- data.frame(rep(planting_cost_perIndiv, each = Nyears) * t(C_host))
colnames(eco[["eco_cost"]]) <- cultivar_names ## useful if Nhost=1
eco[["eco_cost"]]$total <- apply(eco[["eco_cost"]], 1, sum, na.rm = TRUE)
eco[["eco_grossmargin"]] <- eco[["eco_benefit"]] - eco[["eco_cost"]]
eco[["eco_margin"]] <- eco[["eco_product"]] - eco[["eco_cost"]]
output_matrix <- eco[[type]] / (area_host * 1E-4) ## normalization by area in Ha
}
# product <- t(output_matrix[,1:Nhost])
# benefit <- market_value %*% product
# cost <- production_cost_perIndiv %*% C_host
# grossmargin <- benefit - cost
# cost <- planting_cost_perIndiv %*% C_host
# margin <- benefit - cost
if (writeTXT) {
write.table(output_matrix, file = paste(path, "/", type, ".txt", sep = ""), sep = ",")
......@@ -432,28 +438,28 @@ epid_output <- function(types = "all", time_param, Npatho, area, rotation, cropt
main_output <- "AUDPC"
ylab_output <- "Proportion of diseased hosts: (I+R)/K"
round_ylab_output <- 2
}, "gla_abs" = {
main_output <- expression("Absolute green leaf area (GLA"[a] * ")") ## expression('title'[2])
ylab_output <- expression("Equivalent nb of healthy hosts / timestep / m"^2) ## expression('title'^2)
}, "gla" = {
main_output <- expression("Green leaf area (GLA)") ## expression('title'[2])
ylab_output <- expression("Equivalent nb of healthy hosts / time step / m"^2) ## expression('title'^2)
round_ylab_output <- 2
}, "gla_rel" = {
main_output <- expression("Relative green leaf area (GLA"[r] * ")")
ylab_output <- "Proportion of healthy hosts: H/N"
round_ylab_output <- 2
}, "eco_product" = {
main_output <- "Crop production"
}, "eco_yield" = {
main_output <- "Crop yield"
ylab_output <- "Weight (or volume) units / ha"
round_ylab_output <- 0
}, "eco_benefit" = {
main_output <- "Crop benefits"
}, "eco_product" = {
main_output <- "Crop products"
ylab_output <- "Monetary units / ha"
round_ylab_output <- 0
}, "eco_cost" = {
main_output <- "Crop costs"
main_output <- "Operational crop costs"
ylab_output <- "Monetary units / ha"
round_ylab_output <- 0
}, "eco_grossmargin" = {
main_output <- "Gross margin"
}, "eco_margin" = {
main_output <- "Margin"
ylab_output <- "Monetary units / ha"
round_ylab_output <- 0
})
......@@ -579,7 +585,7 @@ switch_patho_to_aggr <- function(index_patho, Ngenes, Nlevels_aggressiveness) {
#' \item R_infection: time to first true infection of a resistant host;
#' \item R_invasion: time when the number of infections of resistant hosts reaches a threshold above which
#' the genotype is unlikely to go extinct.}
#' The value Nyears + 1 timestep is used if the genotype never appeared/infected/invaded.
#' The value Nyears + 1 time step is used if the genotype never appeared/infected/invaded.
#' @return 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).
#' @references Rimbaud L., Papaïx J., Rey J.-F., Barrett L. G. and Thrall P. H. (2018). Assessing the durability and efficiency
......@@ -848,11 +854,12 @@ evol_output <- function(types = "all", time_param, Npoly, cultivars_param, genes
#' @param cultivars_param a list of parameters associated with each host genotype (i.e. cultivars)
#' when cultivated in pure crops:\itemize{
#' \item name = vector of cultivar names,
#' \item max_density = vector of maximum host densities (per square meter) at the end of the cropping season,
#' \item max_density = vector of maximum host densities (per square meter) at the end of the cropping season
#' as if cultivated in pure crops,
#' \item cultivars_genes_list = a list containing, for each host genotype, the indices of carried resistance genes.
#' }
#' @param audpc100S AUDPC of a 100% susceptible landscape, used as a reference.
#' @param keyDates a vector of times (in timesteps) where to draw vertical lines in the AUDPC graphic. Usually
#' @param 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).
#' @param nMapPY an integer specifying the number of epidemic maps per year to generate.
#' @param path path where binary files are located and where the video will be generated.
......
......@@ -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_product" : total crop production (in weight or volume units per ha)
#' \item "eco_cost" : total crop costs (in monetary units per ha)
#' \item "eco_benefit" : total crop benefits (in monetary units per ha)
#' \item "eco_grossmargin" : 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_product" : total crop products (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.
......@@ -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)
),
production_cost_perHa = as.numeric(cultivars$production_cost),
planting_cost_perHa = as.numeric(cultivars$planting_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),
eco_cost = c(0, NA),
eco_yield = c(0, NA),
eco_product = c(0, NA),
eco_benefit = c(0, NA),
eco_grossmargin = c(NA, NA)
eco_margin = c(NA, NA)
)
epid_res <- epid_output(epid_outputs, time_param, Npatho, area, rotation, croptypes_cultivars_prop,
cultivars_param, eco_param,
......
......@@ -48,7 +48,7 @@ simul_params <- setSeed(simul_params, seed = 1)
simul_params@Seed
```
The number of cropping seasons to simulate (e.g. 6 years) and the number of timesteps per
The number of cropping seasons to simulate (e.g. 6 years) and the number of time steps per
cropping season (e.g. 120 days/year) can be set using `setTime()`:
```{r}
simul_params <- setTime(simul_params, Nyears = 6, nTSpY = 120)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment