Skip to content

Commit

Permalink
Merge pull request #21 from thijsjanzen/master
Browse files Browse the repository at this point in the history
Fix CRAN issues
  • Loading branch information
slequime committed Feb 9, 2024
2 parents 64e7960 + 6c38aa9 commit 6bdb85d
Show file tree
Hide file tree
Showing 23 changed files with 203 additions and 92 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
^README.md$
^CRAN-RELEASE$
^\.github$
^doc$
^Meta$
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,5 @@ docs/reference/SingleNone.html
docs/reference/updateHostCount.html
docs/reference/updateTableState.html
docs/reference/writeInfected.html
/doc/
/Meta/
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: nosoi
Type: Package
Title: A Forward Agent-Based Transmission Chain Simulator
Version: 1.1.1
Version: 1.1.2
Authors@R: c(person("Sebastian", "Lequime", email = "sebastian.lequime@gmail.com",
role = c("aut", "cre"), comment = c(ORCID = "0000-0002-3140-0651")),
person("Paul", "Bastide", email = "paul.bastide@umontpellier.fr",
Expand All @@ -11,13 +11,15 @@ Authors@R: c(person("Sebastian", "Lequime", email = "sebastian.lequime@gmail.com
person("Philippe", "Lemey", email = "philippe.lemey@kuleuven.be",
role = "aut", comment = c(ORCID = "0000-0003-2826-5353")),
person("Guy", "Baele", email = "guy.baele@kuleuven.be",
role = "aut", comment = c(ORCID = "0000-0002-1915-7732")))
role = "aut", comment = c(ORCID = "0000-0002-1915-7732")),
person("Thijs", "Janzen", email = "t.janzen@rug.nl",
role = "ctb", comment = c(ORCID = "0000-0002-4162-1140")))
Description: The aim of 'nosoi' (pronounced no.si) is to provide a flexible agent-based stochastic transmission chain/epidemic simulator (Lequime et al. Methods in Ecology and Evolution 11:1002-1007). It is named after the daimones of plague, sickness and disease that escaped Pandora's jar in the Greek mythology. 'nosoi' is able to take into account the influence of multiple variable on the transmission process (e.g. dual-host systems (such as arboviruses), within-host viral dynamics, transportation, population structure), alone or taken together, to create complex but relatively intuitive epidemiological simulations.
URL: https://github.com/slequime/nosoi
Language: en-US
License: GPL-3
Encoding: UTF-8
RoxygenNote: 7.1.1
RoxygenNote: 7.2.3
biocViews:
Depends:
data.table (>= 1.12.0),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# nosoi 1.1.2
* Minor fixes and corrections (documentation, vignettes)

# nosoi 1.1.1
* `tidyverse` no longer in 'Suggests'.
* Updating website
Expand Down
3 changes: 1 addition & 2 deletions R/nosoiSim.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ nosoiSim <- function(type="single", popStructure="none", ...){
#' @description
#' Creates a \code{nosoiSim} object.
#'
#' @param pres.time current time of the simulation
#' @param total.time total time of the simulation
#' @param type population structure (one of "single or "dual)
#' @param pop.A an object of class \code{nosoiSimOne} for population A
#' @param pop.B an object of class \code{nosoiSimOne} for population B
Expand All @@ -139,7 +139,6 @@ nosoiSimConstructor <- function(total.time,
class(res) <- "nosoiSim"

return(res)

}

##
Expand Down
11 changes: 5 additions & 6 deletions R/nosoi_sanityChecks-Messages.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
CoreSanityChecks <- function(length.sim, max.infected, init.individuals) {
if (is.na(length.sim) || length.sim <= 1) stop("You must specify a length (in time units) for your simulation (bigger than 1).")
if (is.na(max.infected) || max.infected <= 1) stop("You must specify a maximum number of infected hosts (bigger than 1).")
if (is.na(init.individuals) || init.individuals < 1 || !init.individuals%%1==0) stop("The transmission chain should be started by 1 or more (integer) individuals.")
if (is.na(init.individuals) || init.individuals < 1 || !init.individuals %%1 == 0) stop("The transmission chain should be started by 1 or more (integer) individuals.")
}

#' @title Checks if a function is properly formatted
Expand All @@ -29,7 +29,6 @@ CoreSanityChecks <- function(length.sim, max.infected, init.individuals) {
#' @param timeDep is the function differential according to absolute time? (TRUE/FALSE)
#' @param diff is the function differential according to state/env.variable? (TRUE/FALSE)
#' @param hostCount is the function differential according to host count? (TRUE/FALSE)
#' @param structure is the function to be used in a structured population? (TRUE/FALSE)
#' @param continuous is the function to be used in a continuous space? (TRUE/FALSE)
#' @param stateNames name of the states (vector) in case of discrete structure.
#'
Expand All @@ -49,15 +48,15 @@ FunctionSanityChecks <- function(pFunc, name, param.pFunc, timeDep, diff, hostCo
|| (diff == TRUE && timeDep == FALSE && hostCount == FALSE && length(formalArgs(pFunc)) > 2)
|| (diff == TRUE && timeDep == FALSE && hostCount == TRUE && length(formalArgs(pFunc)) > 3)
|| (diff == FALSE && timeDep == TRUE && length(formalArgs(pFunc)) > 2)
|| (diff == TRUE && timeDep==TRUE && hostCount == FALSE && length(formalArgs(pFunc)) > 3)
|| (diff == TRUE && timeDep==TRUE && hostCount == TRUE && length(formalArgs(pFunc)) > 4)) {
|| (diff == TRUE && timeDep == TRUE && hostCount == FALSE && length(formalArgs(pFunc)) > 3)
|| (diff == TRUE && timeDep == TRUE && hostCount == TRUE && length(formalArgs(pFunc)) > 4)) {
if (!is.list(param.pFunc) && is.na(param.pFunc)) {
stop("There is a probleme with your function ", name, ": you should provide a parameter list named param.", name, ".")
}

if (is.list(param.pFunc)) {
pFunc.param <- formalArgs(pFunc)[-1]
if(! all(names(param.pFunc) %in% pFunc.param)) stop("Parameter name in param.", name, " should match the name used in ", name, ".")
if(!all(names(param.pFunc) %in% pFunc.param)) stop("Parameter name in param.", name, " should match the name used in ", name, ".")
}
}

Expand Down Expand Up @@ -111,7 +110,7 @@ MatrixSanityChecks <- function(structure.matrix, init.structure, none.at.start=N
##

RasterSanityChecks <- function(structure.raster, init.structure, none.at.start=NULL) {
if(!class(structure.raster) == "RasterLayer") stop("structure.raster must be a raster (class RasterLayer).")
if(!inherits(structure.raster, "RasterLayer")) stop("structure.raster must be a raster (class RasterLayer).")

if(is.null(none.at.start)){
start.env <- raster::extract(structure.raster,cbind(init.structure[1],init.structure[2]))
Expand Down
11 changes: 7 additions & 4 deletions R/nosoi_tablesManagment.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#' @param hosts.ID unique ID for the new host
#' @param infected.by unique ID of host that transmits to the new one
#' @param infected.in state in which the host was infected
#' @param current.in state in which the host currently is
#' @param time.is time in the simulation, when the infection takes place
#' @param ParamHost list of individual based parameters.
#' @param current.environmental.value current environmental value
Expand All @@ -22,10 +21,14 @@
#' @keywords internal

newLine <- function(hosts.ID,
infected.by, infected.in,
infected.by,
infected.in,
time.is,
ParamHost, current.environmental.value = NULL, current.cell.number.raster = NULL,
current.count.A = integer(0), current.count.B = integer(0)) {
ParamHost,
current.environmental.value = NULL,
current.cell.number.raster = NULL,
current.count.A = integer(0),
current.count.B = integer(0)) {

if (length(infected.in) == 1) {
if (is.na(infected.in)) infected.in <- NULL
Expand Down
4 changes: 2 additions & 2 deletions R/nosoi_utilityFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#'
#' @return list of parsed quantities:
#' \itemize{
#' \item{"vect"}{Vectorized version of the function.}
#' \item{"vectArgs"}{Vector of arguments for the vectorized function.}
#' \item "vect" Vectorized version of the function.
#' \item "vectArgs" Vector of arguments for the vectorized function.
#' }
#'
#' @keywords internal
Expand Down
10 changes: 6 additions & 4 deletions R/output_treeGenerator.r
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
#' )
#'
#' ## Make sure all needed packages are here
#' if (requireNamespace("ape", quietly = TRUE)
#' || requireNamespace("tidytree", quietly = TRUE)
#' || requireNamespace("treeio", quietly = TRUE)) {
#' if (requireNamespace("ape", quietly = TRUE) &&
#' requireNamespace("tidytree", quietly = TRUE) &&
#' requireNamespace("treeio", quietly = TRUE)) {
#' library(ape)
#' library(tidytree)
#' library(treeio)
Expand Down Expand Up @@ -84,7 +84,9 @@
#' @export getTransmissionTree

getTransmissionTree <- function(nosoiInf) {
if (!requireNamespace("ape", quietly = TRUE) || !requireNamespace("tidytree", quietly = TRUE) || !requireNamespace("treeio", quietly = TRUE)) {
if (!(requireNamespace("ape", quietly = TRUE) &&
requireNamespace("tidytree", quietly = TRUE) &&
requireNamespace("treeio", quietly = TRUE))) {
stop("Packages 'ape', 'tidytree' and 'treeio' are needed for transmission tree generation.",
call. = FALSE)
}
Expand Down
1 change: 0 additions & 1 deletion R/single-none.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
#'test.nosoi
#'}
#' @export singleNone

singleNone <- function(length.sim,
max.infected,
init.individuals,
Expand Down
2 changes: 0 additions & 2 deletions man/FunctionSanityChecks.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/getTransmissionTree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions man/newLine.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/nosoiSimConstructor.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/parseFunction.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/sampleTransmissionTree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/sampleTransmissionTreeFromExiting.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nosoi.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
8 changes: 5 additions & 3 deletions tests/testthat/testSingleNone.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ test_that("Transmission is coherent with single introduction, constant pExit and
expect_equal(clusters(g, "weak")$no, 1)
expect_equal(diameter(g, directed=F, weights=NA), 12)

dynOld <- getDynamicOld(test.nosoiA)
dynNew <- getDynamic(test.nosoiA)
expect_equal(dynOld, dynNew)
if (requireNamespace("dplyr")) {
dynOld <- getDynamicOld(test.nosoiA)
dynNew <- getDynamic(test.nosoiA)
expect_equal(dynOld, dynNew)
}

## Output
expect_output(print(test.nosoiA), "a single host with no structure")
Expand Down
6 changes: 4 additions & 2 deletions vignettes/continuous.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ test.raster <- focal(focal(test.raster, w=matrix(1, 5, 5), mean), w=matrix(1, 5,
test.raster_df <- as.data.frame(test.raster, xy = TRUE)
if (!requireNamespace("ggplot2", quietly = TRUE) || !requireNamespace("viridis", quietly = TRUE)) {
if (!(requireNamespace("ggplot2", quietly = TRUE) &&
requireNamespace("viridis", quietly = TRUE))) {
message("Packages 'ggplot2' and 'viridis' are needed for plotting this figure.")
} else {
library(ggplot2)
Expand Down Expand Up @@ -189,7 +190,8 @@ move.test2$type = "Not attracted by raster"
move.test.all = rbindlist(list(move.test,move.test2))
if (!requireNamespace("ggplot2", quietly = TRUE) || !requireNamespace("viridis", quietly = TRUE)) {
if (!(requireNamespace("ggplot2", quietly = TRUE) &&
requireNamespace("viridis", quietly = TRUE))) {
message("Packages 'ggplot2' and 'viridis' are needed for plotting this figure.")
} else {
ggplot() +
Expand Down

0 comments on commit 6bdb85d

Please sign in to comment.