library(driftSim) knitr::opts_chunk$set(echo = TRUE, fig.width=7,fig.height=6, message=FALSE, results=FALSE,warning=FALSE)
This documentation is currently incomplete. All current users of the package should be able to use the package from the other vignettes and documentation. Specific use cases will be added as an when they are requested. Below are just some specific tips for issues/queries that users might run into.
It is easy to get the simulation running using the set of example parameters provided with the package.
library(driftSim) ## Example parameter values attached to the package: ## 1. flags (flags for simulation output saving) ## 2. hostpars - vector of parameters related to host population. See ?exampleParameters ## 3. viruspars - vector of parameters related to virus population. See ?exampleParameters ## 4. deltaVMat - matrix of gradients describing how binding avidity changes within a ## particular host in a single day. See ?calculate_deltaV_matrix attach(exampleParameters) sim_duration <- 365 ## Duration of simulation in days version <- 1 scenario_descriptions(1) ## Which version of the simulation to run (1-4) output <- run_simulation(flags=flags, hostpars=hostpars, viruspars=viruspars, deltaVMat=deltaVMat, iniKs=NULL,start=0,end=365,input_files="",output_files=c("SIR.csv","","","","",""), VERBOSE=TRUE,scenario=version) sir <- read.table("SIR.csv",header=FALSE,sep=",") plot_SIR(sir)
There are 4 different scenarios that can be run, specified by the scenario
argument. By specifying the scenario from 1-4, the user can turn on or off particular mechanisms relating to binding avidity adaptation and antigenic drift. Descriptions can be found using the scenario_descriptions
function:
hostpars
argument, specifically hostpars["iniBind"]
. Note that this is the version to use with fixed antigenic distance by setting viruspars["probMut"] <- 0
viruspars["VtoD"]
). The parameter viruspars["kc"]
specifies how quickly binding avidity adapts, and the matrix produced by calculate_deltaV_matrix
generates the amount of change different values of binding avidity and host immunity. See the bottom of the following vignette for more detailviruspars["probMut"]
is above 0viruspars["VtoD"]
The input flags can be confusing - it might not be quite clear what they each do. Descriptions of these are below, along with use cases for the host input flags. Please refer to ?exampleParameters
to get an idea of what these flags look like.
output_files[1]
. If using this, ensure that you have specified the output file location to avoid unexpected results.output_files[2]
is correctoutput_files[3]
. Refer to the summary of model output files for more detailoutput_files[4]
. Refer to the summary of model output files for more detailiniKs
argument. This flag ultimately calls generateHotsKDist_2
, which is shown below:## Generate a uniform distribution of 1000 j values (referred to as $k$ in the code) from 0 to 9 iniKs <- floor(runif(1000,0, 10)) ## How many individuals do we want in the new simulation? N <- 10000 ## From the same distribution of iniKs, draw N j values (referred to as $k$ in the code) startingKs <- generateHostKDist_2(iniKs,N)
It is important to note that the function (and iniKs
in run_simulation
) expects a vector of values, not frequencies. The frequency distribution will be generated within the function. It's unlikely that the user will be specifing iniKs
manually - the intention is to use the hostK
column of the hosts.csv
output of a previous run, as described in the section 5 of the model output files. For example, using the "basic usage" example above:
hostK_file <- read.csv("hosts.csv") iniKs <- hostK_file$hostK flags["input_flag_generated"] <- TRUE output <- run_simulation(flags=flags, hostpars=hostpars, viruspars=viruspars, deltaVMat=deltaVMat, iniKs=iniKs, start=0,end=365,input_files="",output_files=c("SIR.csv","","","","",""), VERBOSE=TRUE,scenario=version)
input_files[1]
argument to read in a file. This essentially does the same job, but bypasses the need for the user the read in the host file and extract the $j$ values (referred to as $k$ in the code). This flag asks the simulation to run the function generateHostKDist
.output_files[5]
. The frequency at which this distribution is saved is given by hostpars["saveFreq"]
. Refer to the summary of model output filesAdd the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.