Skip to content

Commit

Permalink
two updates
Browse files Browse the repository at this point in the history
- remove rare negative abundances during stability calculations
- add a safety check to the run simulation function
  • Loading branch information
opetchey committed Jun 24, 2021
1 parent f511387 commit 47841c1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion R/get_stability_measures.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ get_stability_measures <- function(ss_object) {
temp <- ss_object %>%
#rbind(ss_object) %>%
mutate(direction = ifelse(init_varying == min_iniN, "up", "down")) %>%
filter(across(these, ~ .x >-0.001)) %>% ## there are rarely negative abundances greater than -0.001. This line and the na.omit removes them
tidyr::gather(key = "Species", value = Quantity, these) %>%
dplyr::select(-starts_with("initial_N_"), -init_varying) %>%
tidyr::spread(key = direction, value=Quantity, drop=T)
tidyr::spread(key = direction, value=Quantity, drop=T) %>%
na.omit() ## 31000 to 30969


## then get the stability measures
res <- temp %>%
dplyr::group_by(Species) %>%
Expand Down
1 change: 1 addition & 0 deletions R/run_simulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ run_simulation <- function(dynamic_model = default_dynamic_model,
solver_method = "radau")
{

if(sim_sample_interval > sim_duration) stop("Simulation sample interval is greater than simualution duration... it should be shorter.")

times <- seq(0,
sim_duration,
Expand Down
Binary file modified vignettes/data/partial_reproduction/stab_res.RDS
Binary file not shown.

0 comments on commit 47841c1

Please sign in to comment.