Commit 23b65c6d authored by loup.rimbaud@csiro.au's avatar loup.rimbaud@csiro.au
Browse files

renamed: modeleLandsEPI>modelLandsEPI; plot.evol.QR.R>plotevolQR.R;...

renamed: modeleLandsEPI>modelLandsEPI; plot.evol.QR.R>plotevolQR.R; modele_evol.cpp>model_simul.cpp; modele_evol.hpp>model_simul.hpp; file parameters.txt completely disabled
parents b506b71d 12302c6d
Pipeline #63 failed with stage
in 2 minutes and 48 seconds
......@@ -13,10 +13,9 @@ Author: Loup Rimbaud [aut],
Maintainer: Jean-Francois Rey <jean-francois.rey@inra.fr>
Description: A description
License: GPL (>= 2) | file LICENSE
LazyData: TRUE
BuildVignettes: FALSE
VignetteBuilder: knitr
SystemRequirements: C++11, gsl, gdal
LazyData: true
BuildVignettes: false
SystemRequirements: C++11, gsl, gdal >= 2.0.0
Depends:
methods,
utils,
......@@ -36,10 +35,6 @@ Imports:
splancs,
sf,
RCALI
Suggests:
knitr(>= 1.11),
rmarkdown(>= 0.8.1),
testthat(>= 1.0.0)
Collate:
'invlogit.R'
'logit.R'
......@@ -51,6 +46,6 @@ Collate:
'HLIRdynamics.R'
'demo_landsepi.R'
'landsepi.R'
'plot.evol.QR.R'
'plotevolQR.R'
LinkingTo: Rcpp
RoxygenNote: 6.0.1
......@@ -5,11 +5,11 @@ export(HLIRdynamics)
export(demo_landsepi)
export(invlogit)
export(logit)
export(modeleLandsLPI)
export(modelLandsEPI)
export(multiN)
export(periodic_cov)
export(plot.evol.QR)
export(plot.land)
export(plotevolQR)
export(plotland)
import(MASS)
import(RCALI)
import(Rcpp)
......
# Part of the landsepi R package.
# Copyright (C) 2017 Loup Rimbaud <loup.rimbaud@csiro.au>
# Julien Papaix <julien.papaix@csiro.au>
# Jean-Frnaçois Rey <jean-francois.rey@inra.fr>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,i
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#' @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
......@@ -36,9 +57,11 @@
#' @importFrom grDevices dev.off graphics.off png tiff
#' @include multiN.R periodic_cov.R graphLand.R
#' @examples
#' ## Generate a landscape consisting in a mosaic of fields cultivated with a susceptible cultivar and two resistant cultivars in balanced proportions and high level of spatial aggregation
#' 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)
#' ## Generate a landscape consisting in a mosaic of fields cultivated with a susceptible cultivar
#' ## and two resistant cultivars in balanced proportions and high level of spatial aggregation
#' 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,seed=12345,graphOn=1)
#' @export
AgriLand <- function(landscape,filename="landscapeTEST",propSR,isolSR,propRR,isolRR,strat,Nhote,nYears,Cmax0,Cmax1,seed,graphOn){
set.seed(seed)
......@@ -126,8 +149,8 @@ if (graphOn) {
legend.hab <- c("Susceptible","Resistant 1 + Resistant 2")
if (strat=="PY")
legend.hab <- c("Susceptible","Resistant 1+2")
png(file=paste("landscape.png",sep=""),width=1000,height=1000)
plot.land(landscape, col.hab[habitat1+1], dens.hab[habitat1+1], angle.hab[habitat1+1], col.hab, dens.hab, angle.hab, title.hab, subtitle.hab, legend.hab)
png(filename="landscape.png",width=1000,height=1000)
plotland(landscape, col.hab[habitat1+1], dens.hab[habitat1+1], angle.hab[habitat1+1], col.hab, dens.hab, angle.hab, title.hab, subtitle.hab, legend.hab)
dev.off()
}
return(list(shapefilename=paste0(filename,".gpkg"),layername_hab="habitat",layername_res="results",rotation=as.integer(rotation$habitat),Cmax0=Cmax0,Cmax1=Cmax1,propRR=propRR,strat=strat))
......
# Part of the landsepi R package.
# Copyright (C) 2017 Loup Rimbaud <loup.rimbaud@csiro.au>
# Julien Papaix <julien.papaix@csiro.au>
# Jean-Frnaçois Rey <jean-francois.rey@inra.fr>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,i
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#' @title Generation of model outputs
#' @name HLIRdynamics
#' @description Generate epidemiological and evolutionary outputs from model simulations.
......@@ -433,7 +454,7 @@ if (graphOn==1) {
if (nYears==1) {
## Dynamic of the host (H, L, I, R)
tiff(file=paste(pathRES,"/DYNhost.tiff",sep=""),width=180,height=110,units='mm',compression='lzw',res=300)
tiff(filename=paste(pathRES,"/DYNhost.tiff",sep=""),width=180,height=110,units='mm',compression='lzw',res=300)
par(xpd=NA, mar=c(4,4,0,9))
plot(0,0, type="n", xaxt="n", yaxt="n", bty="n", xlim=c(1,nTS), ylim=c(0,1), ylab="", xlab="")
hab <- habitat[,rotation[1]]
......@@ -451,7 +472,7 @@ if (graphOn==1) {
dev.off()
} else {
## Dynamic of Healthy hosts (H)
tiff(file=paste(pathRES,"/DYNhost_H.tiff",sep=""),width=180,height=110,units='mm',compression='lzw',res=300)
tiff(filename=paste(pathRES,"/DYNhost_H.tiff",sep=""),width=180,height=110,units='mm',compression='lzw',res=300)
par(xpd=NA, mar=c(4,4,0,9))
plot(0,0, type="n", xaxt="n", yaxt="n", bty="n", xlim=c(1,nTS), ylim=c(0,1), ylab="", xlab="")
# for (i in 1:3){
......@@ -475,7 +496,7 @@ if (graphOn==1) {
dev.off()
## Dynamic of Diseased hosts (I+R)
tiff(file=paste(pathRES,"/DYNhost_IR.tiff",sep=""),width=180,height=110,units='mm',compression='lzw',res=300)
tiff(filename=paste(pathRES,"/DYNhost_IR.tiff",sep=""),width=180,height=110,units='mm',compression='lzw',res=300)
par(xpd=NA, mar=c(4,4,0,9))
plot(0,0, type="n", xaxt="n", yaxt="n", bty="n", xlim=c(1,nTS), ylim=c(0,1), ylab="", xlab="")
# for (i in 1:3){
......@@ -518,14 +539,14 @@ if (graphOn==1) {
}
D_freq[trait] <- which(I_aggrProp[[trait]][1,]<0.95)[1] - 1 ## last time-step the 1st pathogen is above 0.95
if (graphOn==1)
plot.evol.QR(pathRES,nIncr,trait,I_aggrProp[[trait]],D_freq[trait],nTS,nYears,nTSpY)
plotevolQR(pathRES,nIncr,trait,I_aggrProp[[trait]],D_freq[trait],nTS,nYears,nTSpY)
}
D_freq[9] <- which(I_pathoProp[Npatho,]>0.05)[1] - 1 ## durability relative to the superpathogen
## Graphic with curves (for qualitative resistance)
if (sum(adapt_vect[1:4])>0) {
COL <- c("#FF5555","#4F94CD","darkolivegreen4","#CD950C","black") ## colors: red, blue, green, orange, black
tiff(file=paste(pathRES,"/EVOLpatho_curve.tiff",sep=""),width=180,height=110,units='mm',compression='lzw',res=300)
tiff(filename=paste(pathRES,"/EVOLpatho_curve.tiff",sep=""),width=180,height=110,units='mm',compression='lzw',res=300)
par(xpd=FALSE, mar=c(4,4,0,9))
idIG <- (1:4)[as.logical(adapt_vect[1:4])]
plot(0,0, type="n", xlim=c(1, nTS), bty="n", las=1, ylim=c(0,1), xaxt="n", xlab="", ylab="Frequency of infective genotypes")
......@@ -571,7 +592,7 @@ if (graphOn==1) {
if (nYears>1) {
## GLA
tiff(file=paste(pathRES, "/GLAabs.tiff",sep=""), width=180, height=110, units='mm', compression='lzw', res=300)
tiff(filename=paste(pathRES, "/GLAabs.tiff",sep=""), width=180, height=110, units='mm', compression='lzw', res=300)
# m <- matrix(c(rep(1,5),2),6,1) # matrix(c(rep(1,5),3,rep(2,5),3),6,2)
# layout(m)
# par(xpd=F, cex=.9,mar=c(5,4.1,4.1,2.1))
......@@ -608,7 +629,7 @@ if (graphOn==1) {
#
dev.off()
tiff(file=paste(pathRES, "/GLArel.tiff",sep=""), width=180, height=110, units='mm', compression='lzw', res=300)
tiff(filename=paste(pathRES, "/GLArel.tiff",sep=""), width=180, height=110, units='mm', compression='lzw', res=300)
par(xpd=NA, cex=.9,mar=c(4,4,0,9))
plot(0, 0, type="l", bty="n", lwd=2, xlim=c(1,nYears), ylim=c(0,1), xaxt="n", yaxt="n"
# , main="Relative green leaf area (GLAr)"
......@@ -628,7 +649,7 @@ if (graphOn==1) {
dev.off()
## AUDPC
tiff(file=paste(pathRES, "/AUDPC.tiff",sep=""), width=180, height=110, units='mm', compression='lzw', res=300)
tiff(filename=paste(pathRES, "/AUDPC.tiff",sep=""), width=180, height=110, units='mm', compression='lzw', res=300)
par(xpd=NA, cex=.9,mar=c(4,4,0,9))
plot(0,0, type="n", bty="n", xlim=c(1, nYears), ylim=c(0, audpc100S), xaxt="n", yaxt="n"
# , main="AUDPC"
......@@ -665,7 +686,7 @@ if (graphOn==1) {
title.H <- "Proportion of healty hosts"
title.IR <- "Proportion of diseased hosts"
invlogitbound <- 6
intvls <- sort(c(0, invlogit(seq(-invlogitbound,invlogitbound,l=nCol-2)), 1), dec=FALSE) ## intervals to define coloration
intvls <- sort(c(0, invlogit(seq(-invlogitbound,invlogitbound,l=nCol-2)), 1), decreasing=FALSE) ## intervals to define coloration
# colMap <- heat.colors(nCol, alpha=.3) ## color for each interval (alpha = transparency)
# plot(1:nCol~rep(0,nCol),col=colMap, pch=15, cex=3)
dens.H <- c(0,8,15)
......@@ -692,10 +713,10 @@ if (graphOn==1) {
intvlsH <- findInterval(propH, intvls)
intvlsIR <- findInterval(propI + propR, intvls)
png(file=paste(pathRES, "/HLIR_",sprintf("%02d",y),"-",sprintf("%03d",d),".png",sep=""),width=2000,height=1000)
png(filename=paste(pathRES, "/HLIR_",sprintf("%02d",y),"-",sprintf("%03d",d),".png",sep=""),width=2000,height=1000)
par(mfrow=c(1,2), cex=2, xpd=NA, mar=c(9.5,5,4,2))
## Map dynamic of healthy hosts
# plot.land(landscape, GREEN[intvlsH], dens.H[hab], angle.H[hab], GREEN, dens.H, angle.H, title.H, subtitle.H, legend.hab, legend.H, "H/K")
# plotland(landscape, GREEN[intvlsH], dens.H[hab], angle.H[hab], GREEN, dens.H, angle.H, title.H, subtitle.H, legend.hab, legend.H, "H/K")
## moving AUDPC
plot(0,0, type="n", bty="n", xlim=c(1, nYears), ylim=c(0, audpc100S), xaxt="n", yaxt="n"
......@@ -721,7 +742,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(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")
plotland(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
......
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#' @title Modele Lands LPI
#' @name modeleLandsLPI
#' @title Model Landscape Epidemiology
#' @name modelLandsEPI
#' @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
......@@ -36,7 +36,7 @@
#' (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)
#' @export
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))
modelLandsEPI <- function(times, landscape, dispersal, inits, val_seed, hostP, epiP, evolP) {
invisible(.Call('landsepi_modelLandsEPI', PACKAGE = 'landsepi', times, landscape, dispersal, inits, val_seed, hostP, epiP, evolP))
}
#library(RCALI) ## function readpoly2
#library(fields) ## function Exponential
#library(MASS) ## function mvnorm
#library(Matrix) ## function nearPD to convert a covariance matrix in a positive-definite matrix
#library(splancs) ## function polymap
#library(rgdal)
#library(raster)
#library(sp)
#library(rgeos)
#library(maptools)
#library(fields)
#library(sf)
# Part of the landsepi R package.
# Copyright (C) 2017 Loup Rimbaud <loup.rimbaud@csiro.au>
# Julien Papaix <julien.papaix@csiro.au>
# Jean-Frnaçois Rey <jean-francois.rey@inra.fr>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,i
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#' Run demo landepi
#' @title demo_landsepi
......@@ -20,6 +29,7 @@
demo_landsepi <- function(){
seed=12345
set.seed(seed)
#outputs
pathRES <- getwd()
graphOn <- 1
......@@ -34,7 +44,9 @@ demo_landsepi <- function(){
nYears <- 5
Cmax0 <- 2
Cmax1 <- 2
data(landscapeTEST)
# hack for cran check
landscapeTEST <- NULL
data(landscapeTEST, envir=environment())
landscape <- AgriLand(landscapeTEST,filename="paysageTEST",propSR,isolSR,propRR,isolRR,strat,Nhote,nYears,Cmax0,Cmax1,seed,graphOn)
#time parameters
......@@ -43,11 +55,11 @@ demo_landsepi <- function(){
paramT <- list(nYears=nYears,nTSpY=nTSpY)#,timesStep=timesStep)
#dispersal
#fichierP <- "/home/julien/Documents/Documents/modelisation/CSIRO_INRA/landsepi/data/TEST_dispP.txt"
#fichierH <- "/home/julien/Documents/Documents/modelisation/CSIRO_INRA/landsepi/data/TEST_dispH.txt"
data(disp)
#dispP <- scan(fichierP,sep=",")
#dispH <- scan(fichierH,sep=",")
# Hack for cran check
dispP <- NULL
dispH <- NULL
data(dispP,envir=environment())
data(dispH, envir=environment())
#host parameters
croisH0 <- 0.10
......@@ -94,7 +106,7 @@ demo_landsepi <- function(){
PI0 <- 5e-4
#run the model!
modeleLandsLPI(paramT,
modelLandsEPI(paramT,
landscape,
dispersal=list(dispP=dispP,dispH=dispH),
inits=list(C_0=C_0, PI0=PI0),
......
# Part of the landsepi R package.
# Copyright (C) 2017 Loup Rimbaud <loup.rimbaud@csiro.au>
# Julien Papaix <julien.papaix@csiro.au>
# Jean-Frnaçois Rey <jean-francois.rey@inra.fr>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,i
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#' @title Plotting the landscape
#' @name plot.land
#' @name plotland
#' @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
......@@ -17,12 +39,13 @@
#' @param YMAX maximal coordinate on vertical axis
#' @examples
#' ## Draw a landscape with various colours
#' data(landscapeTEST)
#' plot.land(landscapeTEST, COL=1:length(landscapeTEST), DENS=rep(0,length(landscapeTEST)), ANGLE=rep(30,length(landscapeTEST)))
#' landscapeTEST
#' plotland(landscapeTEST, COL=1:length(landscapeTEST),
#' DENS=rep(0,length(landscapeTEST)), ANGLE=rep(30,length(landscapeTEST)))
#' @include RcppExports.R logit.R invlogit.R
# @S3method plot land
#' @export
plot.land <- function(landscape, COL=rep(0,length(landscape)), DENS=rep(0,length(landscape)), ANGLE=rep(30,length(landscape))
plotland <- function(landscape, COL=rep(0,length(landscape)), DENS=rep(0,length(landscape)), ANGLE=rep(30,length(landscape))
, COL.LEG=unique(COL), DENS.LEG=unique(DENS), ANGLE.LEG=unique(ANGLE)
, TITLE="", SUBTITLE="", LEGEND1=rep("", length(COL.LEG)), LEGEND2=rep("", length(COL.LEG)), TITLE.LEG2="", XMAX=2000, YMAX=2000) {
par(cex=2, xpd=NA, bg="white", mar=c(5,4,4,2))
......
# Part of the landsepi R package.
# Copyright (C) 2017 Loup Rimbaud <loup.rimbaud@csiro.au>
# Julien Papaix <julien.papaix@csiro.au>
# Jean-Frnaçois Rey <jean-francois.rey@inra.fr>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,i
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#' @title Inverse logit function
#' @name invlogit
#' @description Given a numeric object return the invlogit of the values. Missing values (NAs) are allowed.
......
# Part of the landsepi R package.
# Copyright (C) 2017 Loup Rimbaud <loup.rimbaud@csiro.au>
# Julien Papaix <julien.papaix@csiro.au>
# Jean-Frnaçois Rey <jean-francois.rey@inra.fr>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,
# along with this program; if not, write to the Free Software Foundation, Inc.,i
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#' @encoding UTF-8
#' @title Biological Risk Assessment for epidemology
#' @title Landscape Epidemiology
#' @description A spatio-temporal exposure-hazard model for assessing biological risk and impact.
#' The model is based on stochastic geometry for describing the landscape and the exposed individuals,
#' a dispersal kernel for the dissemination of contaminants and an ecotoxicological equation.
#' @aliases briskaRepi-package briskaRepi
#'
#' @author Loup Rimbaud \email{loup.rimbaud@csiro.au}
#' @author Julien Papaix \email{julien.papaix@inra.fr}
#' @author Loup Rimbaud \email{loup.rimbaud@@csiro.au}
#' @author Julien Papaix \email{julien.papaix@@inra.fr}
#' @author Jean-Francois Rey \email{jean-francois.rey@@inra.fr}
#'
#' Maintainer: Jean-Francois REY \email{jean-francois.rey@@inra.fr}
......
# Part of the landsepi R package.
# Copyright (C) 2017 Loup Rimbaud <loup.rimbaud@csiro.au>
# Julien Papaix <julien.papaix@csiro.au>
# Jean-Frnaçois Rey <jean-francois.rey@inra.fr>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,i
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#' @title Logit function
#' @name logit
#' @description Given a numeric object return the logit of the values. Missing values (NAs) are allowed.
......
# Part of the landsepi R package.
# Copyright (C) 2017 Loup Rimbaud <loup.rimbaud@csiro.au>
# Julien Papaix <julien.papaix@csiro.au>
# Jean-Frnaçois Rey <jean-francois.rey@inra.fr>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,i
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#' @title Allocation of cultivars
#' @name multiN
#' @description Algorithm based on latent Gaussian fields to allocate two different crop cultivars across the simulated landscapes.
......
# Part of the landsepi R package.
# Copyright (C) 2017 Loup Rimbaud <loup.rimbaud@csiro.au>
# Julien Papaix <julien.papaix@csiro.au>
# Jean-Frnaçois Rey <jean-francois.rey@inra.fr>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,i
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#' @title Periodic covariance function
#' @name periodic_cov
#' @description Periodic function used to compute the variance-covariance matrix of the fields of the landscape.
......
#' @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()
}
......@@ -5,7 +5,70 @@
## Configuration
read file "DESCRIPTION" for configuration requirements and required library (linux and R)
## before build and install
## Descriptions
## Authors
* CSIRO [[https://www.csiro.au]]
* INRA [[https://www.inra.fr]]
* Loup Rimbaud [[loup.rimbaud@csiro.au]]
* Julien Papaix [[julien.papaix@inra.fr]]
* Jean-Francois Rey [[jean-francois.rey@inra.fr]]
## License
The package landsepi is under GNU GPL V2.
See LICENSE file.
## R package
### Dependencies
The package for compiling needs g++, gsl dev library and gdal dev library >= 2.0.0 .
Under Linux OS:
```bash
sudo apt-get install g++ libgsl-dev libgdal-dev
```
Under Windows use the zip.
> You can install Rtools and get gdal sources and compile it under Windows.
R packages dependencies :
* Rcpp
* sp
* rgdal
* Matrix
* MASS
* rgeos
* maptools
* fields
* splancs
* sf
* RCALI
To install :
```r
install.packages(c("Rcpp","sp","rgdal","Matrix","MASS","rgeos","maptools","fields","splancs","sf","RCALI"))