Skip to content

Commit

Permalink
version 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood authored and cran-robot committed Jan 23, 2023
1 parent 454e4a1 commit f9d562a
Show file tree
Hide file tree
Showing 37 changed files with 676 additions and 221 deletions.
15 changes: 8 additions & 7 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Type: Package
Package: GillespieSSA2
Title: Gillespie's Stochastic Simulation Algorithm for Impatient People
Version: 0.2.10
Version: 0.3.0
Authors@R:
c(person(given = "Robrecht",
family = "Cannoodt",
Expand All @@ -19,10 +19,11 @@ Description: A fast, scalable, and versatile framework for
'GillespieSSA' package originally written by Mario Pineda-Krch.
Benefits of this package include major speed improvements (>100x),
easier to understand documentation, and many unit tests that try to
ensure the package works as intended. Cannoodt and Saelens et al. (2020)
<doi:10.1101/2020.02.06.936971>.
ensure the package works as intended. Cannoodt and Saelens et al. (2021)
<doi:10.1038/s41467-021-24152-2>.
License: GPL (>= 3)
URL: https://github.com/rcannood/GillespieSSA2
URL: https://rcannood.github.io/GillespieSSA2/,
https://github.com/rcannood/GillespieSSA2
BugReports: https://github.com/rcannood/GillespieSSA2/issues
Depends: R (>= 3.3)
Imports: assertthat, dplyr, dynutils, Matrix, methods, purrr, Rcpp (>=
Expand All @@ -32,11 +33,11 @@ Suggests: covr, ggplot2, GillespieSSA, knitr, rmarkdown, testthat (>=
LinkingTo: Rcpp
VignetteBuilder: knitr
Encoding: UTF-8
RoxygenNote: 7.2.1
RoxygenNote: 7.2.2
NeedsCompilation: yes
Packaged: 2022-09-23 04:47:00 UTC; rcannood
Packaged: 2023-01-23 11:54:50 UTC; rcannood
Author: Robrecht Cannoodt [aut, cre] (<https://orcid.org/0000-0003-3641-729X>),
Wouter Saelens [aut] (<https://orcid.org/0000-0002-7114-6248>)
Maintainer: Robrecht Cannoodt <rcannood@gmail.com>
Repository: CRAN
Date/Publication: 2022-09-23 05:10:02 UTC
Date/Publication: 2023-01-23 19:20:02 UTC
71 changes: 36 additions & 35 deletions MD5
@@ -1,8 +1,8 @@
8f41f7ed7564072d184398b8df01e33f *DESCRIPTION
f5b91b1afcb0b78ae9ce0e7e0211df0e *DESCRIPTION
824738d9e64b71dcdc15f3dd4cc9f7d1 *NAMESPACE
cdab9254174b7ab070aae254d47255da *NEWS.md
1e3e6a778c631805a00b4a95bee91489 *NEWS.md
8fcca8419edb8e5f6f05edb5a9ab164a *R/RcppExports.R
f6176e06683b11288eceee32f584ece1 *R/compile_reactions.R
0ed41f9926ca751fccec5c436dcd684b *R/compile_reactions.R
8187cadc939326b491c14d43b5db902a *R/ode_em.R
ca7f7bed69c58ffba28e99dad5f38116 *R/package.R
29c88d8ada2ce642e79c72cd95c598d2 *R/port_reactions.R
Expand All @@ -14,42 +14,43 @@ b7b8f91d2169ae81380dc6a6688cb423 *R/ssa_exact.R
6beb908b6b6ab7e726e4bacd15e24912 *R/ssa_plot.R
c3d7b66d3367069b461cf25f600ce460 *R/ssa_simulation.R
66591901b38888eb1284b979e2529d42 *R/zzz.R
479d3620835fc9428dee21a939f69557 *README.md
57fe49e601422a308c7278572afd7958 *build/partial.rdb
c84c168dedf5b1c8faf9a649b97eb3fa *build/vignette.rds
b9802047792b5effc3164ec8de783e78 *inst/CITATION
e4bbcec29a5058f41f9fbcbb0cef3300 *README.md
5090baddae7c87baed092cb997ee3904 *build/partial.rdb
9828b259bd842cddd67e9761b5d6c75a *build/vignette.rds
ecb8ffdc199e5746c40aa89c230e8392 *inst/CITATION
e9ceee3ba1b05393de18fcb29fd2641f *inst/REFERENCES.bib
6259d0e8d0745ae7b3f91fa929136220 *inst/doc/an_introduction.R
eb938dd5bf4359137d770768c897dc3c *inst/doc/an_introduction.Rmd
8b559f741849b52fa845421f6e5cfce9 *inst/doc/an_introduction.html
63ef22e6a0039b2945d861543c679219 *inst/doc/an_introduction.html
3f33398e5a745c5868294073192ded1c *inst/doc/converting_from_GillespieSSA.R
47746770110cc68b84b66f35fae83c1a *inst/doc/converting_from_GillespieSSA.Rmd
5f2e6ceef5ed0207e6294a403d14f92e *inst/doc/converting_from_GillespieSSA.html
06d931fa3c1e7ae93b28b05a1ca42971 *inst/doc/converting_from_GillespieSSA.html
ea28ca14a02f3042f16a7ec1c9ffd3d7 *inst/doc/decaying_dimer.R
6f47b4e254ec886cea970c410da995f3 *inst/doc/decaying_dimer.Rmd
59b561a34f14c4d76ef299345e410f21 *inst/doc/decaying_dimer.html
3329ff40ef14aa33e12a9ed366628147 *inst/doc/decaying_dimer.Rmd
130ed795246215a85b36992c63a98841 *inst/doc/decaying_dimer.html
e4fad73432106caa5cc6cee9cc6d0119 *inst/doc/epi_chain.R
a7cd8a2160162c9a6b066c0a692e1a03 *inst/doc/epi_chain.Rmd
58c6983388b58f17b904a5596b025d7e *inst/doc/epi_chain.html
c3d18bcf07a9c49f57ccf7353bb0a2fa *inst/doc/epi_chain.Rmd
ad0b95cd51c26d1feb1d3eb84feb874e *inst/doc/epi_chain.html
df35701ec3d5431e46380cb634f5285e *inst/doc/linear_chain.R
d241625929888c6741be09391f7a13c2 *inst/doc/linear_chain.Rmd
73651c1f119506af149b19148d68e90a *inst/doc/linear_chain.html
af349ed16a74ef418faa92bbdb498625 *inst/doc/linear_chain.Rmd
26509b2070048ee008fb57f113bd91f9 *inst/doc/linear_chain.html
731cb4f07f219d66c90e6513c8b2e303 *inst/doc/logistic_growth.R
4b965e551fa7ccde34c25ba7068bfbdc *inst/doc/logistic_growth.Rmd
f9467b02c32a93112677f88e7e4f3dac *inst/doc/logistic_growth.html
493793d47eb8247d39df273be706eccb *inst/doc/logistic_growth.Rmd
dffef6c0776034f6f27f4d688d347e57 *inst/doc/logistic_growth.html
72d80133111eaf60d5e7cd959263eba7 *inst/doc/lotka_predator_prey.R
9326f9bfc31d687d3be5c322cebec6f6 *inst/doc/lotka_predator_prey.Rmd
35138cad9823b64a7dbdd38fc72c5695 *inst/doc/lotka_predator_prey.html
db3edc8b691fdb9f8db8bdad5a6cdb94 *inst/doc/lotka_predator_prey.Rmd
2b9a16ee0c744a7e328b30eb19fd10c5 *inst/doc/lotka_predator_prey.html
982d701ae77f8067874109debaa33ecc *inst/doc/radioactive_decay.R
1f81b1df3982b49719d59f1f528df279 *inst/doc/radioactive_decay.Rmd
6cf32a38a88d61214b7875b302c1baf6 *inst/doc/radioactive_decay.html
06f03813daab33cb5be1be20f3ae72c7 *inst/doc/radioactive_decay.Rmd
67e3928ce7b468d2b3cec787d64072a8 *inst/doc/radioactive_decay.html
bf14a1fdda72e32ea87067d94e7e0a69 *inst/doc/rm_predator_prey.R
6117cd70a102e574eb32c91b68c51008 *inst/doc/rm_predator_prey.Rmd
17cfb003b7f01e03f06087951bd92e01 *inst/doc/rm_predator_prey.html
b205f1267c3e46ef29ac3577c510f064 *inst/doc/rm_predator_prey.Rmd
4771057a985b3ff10193c35144828304 *inst/doc/rm_predator_prey.html
6273d82ad27b9c6b81720a65c12680da *inst/doc/sir.R
e7391b08c6fab835d293a636a3690c89 *inst/doc/sir.Rmd
8a02528c77784cb5bdb928b9b35ee607 *inst/doc/sir.html
6019e10b7401171ea419cb73ef122358 *inst/doc/sir.Rmd
37ad68c09bcba1e91d17f1e057239a16 *inst/doc/sir.html
1d412520a0f0af2c8d4943ea186d2be5 *man/GillespieSSA2.Rd
fac9373cca89eee02113c13c7955aa37 *man/compile_reactions.Rd
c527a114f82a847f0e1d7338e9049848 *man/compile_reactions.Rd
fd4c47d761c9f639c188d297da449d64 *man/figures/dependencies.png
47b54f1c878c06fc218c268b82d13ef4 *man/ode_em.Rd
c96b29826ec798db4de2bbb74affcea1 *man/plot_ssa.Rd
Expand All @@ -74,7 +75,7 @@ bde4cd198553f4f2f2bb64ade0b2f79e *src/utils.h
1f805c4be7c74e9df39994f09c36fa25 *tests/testthat.R
b42108b1f1173cd9d808546e2add30a1 *tests/testthat/helper-test_propensity.R
3f38c64eff5561aafca0ad2172b8874e *tests/testthat/helper-test_ssa_step.R
9598bac6aa535675370ee8e7fabeb5fe *tests/testthat/test-compile_reactions.R
70fbaee4190043af5443297db532a120 *tests/testthat/test-compile_reactions.R
abb0748b010db2641b963047e151e6dc *tests/testthat/test-ode_em.R
ed1ac27aaa28558d05f8ba4ee2327c4e *tests/testthat/test-reaction.R
a941cab6602f231a3f2a9d5077f81265 *tests/testthat/test-ssa.R
Expand All @@ -83,11 +84,11 @@ a941cab6602f231a3f2a9d5077f81265 *tests/testthat/test-ssa.R
95e9d9020887f6a76fcf9cf6471f3667 *tests/testthat/test-ssa_exact.R
eb938dd5bf4359137d770768c897dc3c *vignettes/an_introduction.Rmd
47746770110cc68b84b66f35fae83c1a *vignettes/converting_from_GillespieSSA.Rmd
6f47b4e254ec886cea970c410da995f3 *vignettes/decaying_dimer.Rmd
a7cd8a2160162c9a6b066c0a692e1a03 *vignettes/epi_chain.Rmd
d241625929888c6741be09391f7a13c2 *vignettes/linear_chain.Rmd
4b965e551fa7ccde34c25ba7068bfbdc *vignettes/logistic_growth.Rmd
9326f9bfc31d687d3be5c322cebec6f6 *vignettes/lotka_predator_prey.Rmd
1f81b1df3982b49719d59f1f528df279 *vignettes/radioactive_decay.Rmd
6117cd70a102e574eb32c91b68c51008 *vignettes/rm_predator_prey.Rmd
e7391b08c6fab835d293a636a3690c89 *vignettes/sir.Rmd
3329ff40ef14aa33e12a9ed366628147 *vignettes/decaying_dimer.Rmd
c3d18bcf07a9c49f57ccf7353bb0a2fa *vignettes/epi_chain.Rmd
af349ed16a74ef418faa92bbdb498625 *vignettes/linear_chain.Rmd
493793d47eb8247d39df273be706eccb *vignettes/logistic_growth.Rmd
db3edc8b691fdb9f8db8bdad5a6cdb94 *vignettes/lotka_predator_prey.Rmd
06f03813daab33cb5be1be20f3ae72c7 *vignettes/radioactive_decay.Rmd
b205f1267c3e46ef29ac3577c510f064 *vignettes/rm_predator_prey.Rmd
6019e10b7401171ea419cb73ef122358 *vignettes/sir.Rmd
7 changes: 7 additions & 0 deletions NEWS.md
@@ -1,3 +1,10 @@
# GillespieSSA2 0.3.0

* MINOR CHANGE: Add `debug` parameter to print out propensity functions before compiling.

* MINOR CHANGE: Add spaces between terms in the reaction propensity C++ code to
avoid pasting together important key words (e.g. `if` and `else`).

# GillespieSSA2 0.2.10

* MINOR CHANGE: Turn array of propensity functions into vector of propensity functions.
Expand Down
20 changes: 14 additions & 6 deletions R/compile_reactions.R
Expand Up @@ -10,6 +10,7 @@
#' @param hardcode_params `[logical]` Whether or not to hardcode the values of `params` in the compilation of the propensity functions.
#' Setting this to `TRUE` will result in a minor sacrifice in accuracy for a minor increase in performance.
#' @param fun_by `[integer]` Combine this number of propensity functions into one function.
#' @param debug `[logical]` Whether to print the resulting C++ code before compiling.
#'
#' @return A list of objects solely to be used by [ssa()].
#'
Expand Down Expand Up @@ -66,7 +67,8 @@ compile_reactions <- function(
params,
buffer_ids = NULL,
hardcode_params = FALSE,
fun_by = 10000L
fun_by = 10000L,
debug = FALSE
) {
assert_that(is.list(reactions))
walk(seq_along(reactions), function(i) {
Expand Down Expand Up @@ -108,19 +110,21 @@ compile_reactions <- function(
# add reaction ids assignments to propensity functions
propensity_funs <- map_chr(reactions, "propensity")
for (i in seq_along(propensity_funs)) {
propensity_funs[[i]] <- gsub("(.*;)?([^;]*)", paste0("\\1", reaction_ids[[i]], " = \\2"), propensity_funs[[i]])
propensity_funs[[i]] <- gsub("(.*; *)?([^;]*)", paste0("\\1", reaction_ids[[i]], " = \\2"), propensity_funs[[i]])
}

# preprocess propensity functions
variable_names <- propensity_funs %>% str_extract_all("[A-Za-z_0-9]* *=") %>% map(function(x) str_replace_all(x, "[ =]", ""))
reaction_ids <- variable_names %>% map_chr(last)

buffer_usages <- map_int(variable_names, length) - 1
buffer_size <- sum(buffer_usages)

if (is.null(buffer_ids)) {
buffer_ids <- variable_names %>% unlist() %>% discard(~ . %in% reaction_ids)
buffer_ids <- variable_names %>%
unlist() %>%
discard(~ . %in% reaction_ids) %>%
unique()
}
buffer_size <- length(buffer_ids)

# split propensity functions into words and non-words
prop_split <-
Expand Down Expand Up @@ -159,7 +163,8 @@ compile_reactions <- function(

# get indices of semi colons
prop_lines <-
paste0(prop_split, collapse = "") %>%
paste0(prop_split, collapse = " ") %>%
str_replace_all(" *; *", ";") %>%
str_split(";") %>%
first() %>%
discard(~ . == "")
Expand All @@ -183,6 +188,9 @@ compile_reactions <- function(
rcpp_function_code_blocks,
"}\n"
)
if (debug) {
cat(rcpp_codes)
}

# create temporary dir for compilation
tmpdir <- dynutils::safe_tempdir("gillespie")
Expand Down
45 changes: 34 additions & 11 deletions README.md
Expand Up @@ -16,8 +16,9 @@ Status](https://app.codecov.io/gh/rcannood/GillespieSSA2/branch/master/graph/bad

**GillespieSSA2** is a fast, scalable, and versatile framework for
simulating large systems with Gillespie’s Stochastic Simulation
Algorithm (SSA). This package is the spiritual successor to the
GillespieSSA package originally written by Mario Pineda-Krch.
Algorithm (SSA) (Cannoodt et al. 2021). This package is the spiritual
successor to the GillespieSSA package originally written by Mario
Pineda-Krch (Pineda-Krch 2008).

GillespieSSA2 has the following added benefits:

Expand Down Expand Up @@ -59,20 +60,42 @@ The following example models are available:
`vignette("an_introduction", package="GillespieSSA2")`
- Converting from GillespieSSA to GillespieSSA2:
`vignette("converting_from_GillespieSSA", package="GillespieSSA2")`
- Decaying-Dimerization Reaction Set (Gillespie, 2001):
- Decaying-Dimerization Reaction Set:
`vignette("decaying_dimer", package="GillespieSSA2")`
- SIRS metapopulation model (Pineda-Krch, 2008):
- SIRS metapopulation model:
`vignette("epi_chain", package="GillespieSSA2")`
- Linear Chain System (Cao et al., 2004):
- Linear Chain System:
`vignette("linear_chain", package="GillespieSSA2")`
- Pearl-Verhulst Logistic Growth model (Kot, 2001):
- Pearl-Verhulst Logistic Growth model:
`vignette("logistic_growth", package="GillespieSSA2")`
- Lotka Predator-Prey model (Gillespie, 1977; Kot, 2001):
- Lotka Predator-Prey model:
`vignette("lotka_predator_prey", package="GillespieSSA2")`
- Radioactive Decay model (Gillespie, 1977):
- Radioactive Decay model:
`vignette("radioactive_decay", package="GillespieSSA2")`
- Rosenzweig-MacArthur Predator-Prey model (Pineda-Krch et al.,
2007):
- Rosenzweig-MacArthur Predator-Prey model:
`vignette("rm_predator_prey", package="GillespieSSA2")`
- Kermack-McKendrick SIR model (Brown & Rothery, 1993):
- Kermack-McKendrick SIR model:
`vignette("sir", package="GillespieSSA2")`

## References

<div id="refs" class="references csl-bib-body hanging-indent">

<div id="ref-Cannoodt2021" class="csl-entry">

Cannoodt, Robrecht, Wouter Saelens, Louise Deconinck, and Yvan Saeys.
2021. “Spearheading Future Omics Analyses Using Dyngen, a Multi-Modal
Simulator of Single Cells.” *Nature Communications* 12 (1).
<https://doi.org/10.1038/s41467-021-24152-2>.

</div>

<div id="ref-PinedaKrch2008" class="csl-entry">

Pineda-Krch, Mario. 2008. “GillespieSSA: Implementing the Stochastic
Simulation Algorithm in r.” *Journal of Statistical Software* 25 (12).
<https://doi.org/10.18637/jss.v025.i12>.

</div>

</div>
Binary file modified build/partial.rdb
Binary file not shown.
Binary file modified build/vignette.rds
Binary file not shown.
12 changes: 5 additions & 7 deletions inst/CITATION
Expand Up @@ -8,11 +8,9 @@ citEntry(
person("Louise", "Deconinck"),
person("Yvan", "Saeys")
),
title = "dyngen: a multi-modal simulator for spearheading new single-cell omics analyses",
journal = "bioRxiv",
year = "2020",
month = "2",
doi = "10.1101/2020.02.06.936971",
url = "https://www.biorxiv.org/content/10.1101/2020.02.06.936971v2",
textVersion = "dyngen: a multi-modal simulator for spearheading new single-cell omics analyses. Robrecht Cannoodt, Wouter Saelens, Louise Deconinck, Yvan Saeys. bioRxiv 2020.02.06.936971; doi: https://doi.org/10.1101/2020.02.06.936971."
title = "Spearheading future omics analyses using dyngen, a multi-modal simulator of single cells",
journal = "Nature Communications",
year = "2021",
doi = "10.1038/s41467-021-24152-2",
textVersion = "Spearheading future omics analyses using dyngen, a multi-modal simulator of single cells. Robrecht Cannoodt, Wouter Saelens, Louise Deconinck, Yvan Saeys. Nat Commun 12, 3942 (2021); doi: https://doi.org/10.1038/s41467-021-24152-2."
)

0 comments on commit f9d562a

Please sign in to comment.