Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set.seed() doesn't always make cpr_rand_test() return identical results when parallelization is on #2

Closed
joelnitta opened this issue Oct 20, 2021 · 2 comments

Comments

@joelnitta
Copy link
Collaborator

joelnitta commented Oct 20, 2021

Results differ only under some circumstances (see # Check equalities in regex below). Not sure why. At 604ed8b

library(canaper)
library(future)

# Sequential, trialswap
plan(sequential)
set.seed(164134)
res_trial_seq_1 <- cpr_rand_test(acacia$comm, acacia$phy, null_model = "trialswap", n_iterations = 100, n_reps = 100)
#> [1] "Dropping tips from the tree because they are not present in the community data:"
#> [1] "Pararchidendron_pruinosum" "Paraserianthes_lophantha" 
#> [3] "saligna"                   "clunies-rossiae"
set.seed(164134)
res_trial_seq_2 <- cpr_rand_test(acacia$comm, acacia$phy, null_model = "trialswap", n_iterations = 100, n_reps = 100)
#> [1] "Dropping tips from the tree because they are not present in the community data:"
#> [1] "Pararchidendron_pruinosum" "Paraserianthes_lophantha" 
#> [3] "saligna"                   "clunies-rossiae"

# Parallel, trialswap, three workers
plan(multisession, workers = 3)
set.seed(164134)
res_trial_par_3work_1 <- cpr_rand_test(acacia$comm, acacia$phy, null_model = "trialswap", n_iterations = 100, n_reps = 100)
#> [1] "Dropping tips from the tree because they are not present in the community data:"
#> [1] "Pararchidendron_pruinosum" "Paraserianthes_lophantha" 
#> [3] "saligna"                   "clunies-rossiae"
set.seed(164134)
res_trial_par_3work_2 <- cpr_rand_test(acacia$comm, acacia$phy, null_model = "trialswap", n_iterations = 100, n_reps = 100)
#> [1] "Dropping tips from the tree because they are not present in the community data:"
#> [1] "Pararchidendron_pruinosum" "Paraserianthes_lophantha" 
#> [3] "saligna"                   "clunies-rossiae"

# Parallel, trialswap, six workers
plan(multisession, workers = 6)
set.seed(164134)
res_trial_par_6work_1 <- cpr_rand_test(acacia$comm, acacia$phy, null_model = "trialswap", n_iterations = 100, n_reps = 100)
#> [1] "Dropping tips from the tree because they are not present in the community data:"
#> [1] "Pararchidendron_pruinosum" "Paraserianthes_lophantha" 
#> [3] "saligna"                   "clunies-rossiae"
set.seed(164134)
res_trial_par_6work_2 <- cpr_rand_test(acacia$comm, acacia$phy, null_model = "trialswap", n_iterations = 100, n_reps = 100)
#> [1] "Dropping tips from the tree because they are not present in the community data:"
#> [1] "Pararchidendron_pruinosum" "Paraserianthes_lophantha" 
#> [3] "saligna"                   "clunies-rossiae"

# Check equalities (should *all* be equal)
isTRUE(all.equal(res_trial_seq_1, res_trial_seq_2))
#> [1] FALSE
isTRUE(all.equal(res_trial_par_3work_1, res_trial_par_3work_2))
#> [1] TRUE
isTRUE(all.equal(res_trial_par_6work_1, res_trial_par_6work_2))
#> [1] TRUE
isTRUE(all.equal(res_trial_par_6work_1, res_trial_seq_1))
#> [1] FALSE
isTRUE(all.equal(res_trial_par_6work_2, res_trial_seq_2))
#> [1] TRUE

# Sequential, independentswap
plan(sequential)
set.seed(164134)
res_indep_seq_1 <- cpr_rand_test(acacia$comm, acacia$phy, null_model = "independentswap", n_iterations = 100, n_reps = 100)
#> [1] "Dropping tips from the tree because they are not present in the community data:"
#> [1] "Pararchidendron_pruinosum" "Paraserianthes_lophantha" 
#> [3] "saligna"                   "clunies-rossiae"
set.seed(164134)
res_indep_seq_2 <- cpr_rand_test(acacia$comm, acacia$phy, null_model = "independentswap", n_iterations = 100, n_reps = 100)
#> [1] "Dropping tips from the tree because they are not present in the community data:"
#> [1] "Pararchidendron_pruinosum" "Paraserianthes_lophantha" 
#> [3] "saligna"                   "clunies-rossiae"

# Parallel, independentswap, three workers
plan(multisession, workers = 3)
set.seed(164134)
res_indep_par_3work_1 <- cpr_rand_test(acacia$comm, acacia$phy, null_model = "independentswap", n_iterations = 100, n_reps = 100)
#> [1] "Dropping tips from the tree because they are not present in the community data:"
#> [1] "Pararchidendron_pruinosum" "Paraserianthes_lophantha" 
#> [3] "saligna"                   "clunies-rossiae"
set.seed(164134)
res_indep_par_3work_2 <- cpr_rand_test(acacia$comm, acacia$phy, null_model = "independentswap", n_iterations = 100, n_reps = 100)
#> [1] "Dropping tips from the tree because they are not present in the community data:"
#> [1] "Pararchidendron_pruinosum" "Paraserianthes_lophantha" 
#> [3] "saligna"                   "clunies-rossiae"

# Parallel, independentswap, six workers
plan(multisession, workers = 6)
set.seed(164134)
res_indep_par_6work_1 <- cpr_rand_test(acacia$comm, acacia$phy, null_model = "independentswap", n_iterations = 100, n_reps = 100)
#> [1] "Dropping tips from the tree because they are not present in the community data:"
#> [1] "Pararchidendron_pruinosum" "Paraserianthes_lophantha" 
#> [3] "saligna"                   "clunies-rossiae"
set.seed(164134)
res_indep_par_6work_2 <- cpr_rand_test(acacia$comm, acacia$phy, null_model = "independentswap", n_iterations = 100, n_reps = 100)
#> [1] "Dropping tips from the tree because they are not present in the community data:"
#> [1] "Pararchidendron_pruinosum" "Paraserianthes_lophantha" 
#> [3] "saligna"                   "clunies-rossiae"

# Check equalities (should *all* be equal)
isTRUE(all.equal(res_indep_seq_1, res_indep_seq_2))
#> [1] TRUE
isTRUE(all.equal(res_indep_par_3work_1, res_indep_par_3work_2))
#> [1] FALSE
isTRUE(all.equal(res_indep_par_6work_1, res_indep_par_6work_2))
#> [1] FALSE
isTRUE(all.equal(res_indep_par_6work_1, res_indep_seq_1))
#> [1] FALSE
isTRUE(all.equal(res_indep_par_6work_2, res_indep_seq_2))
#> [1] TRUE

Created on 2021-10-20 by the reprex package (v2.0.0)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.1.0 (2021-05-18)
#>  os       macOS Catalina 10.15.7      
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Asia/Tokyo                  
#>  date     2021-10-20                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version    date       lib source        
#>  abind          1.4-5      2016-07-21 [1] CRAN (R 4.1.0)
#>  ape            5.5        2021-04-25 [1] CRAN (R 4.1.0)
#>  assertr        2.8        2021-01-25 [1] CRAN (R 4.1.0)
#>  assertthat     0.2.1      2019-03-21 [1] CRAN (R 4.1.0)
#>  backports      1.2.1      2020-12-09 [1] CRAN (R 4.1.0)
#>  betapart       1.5.4      2021-04-11 [1] CRAN (R 4.1.0)
#>  canaper      * 0.0.0.9000 2021-10-20 [1] local         
#>  cli            3.0.1      2021-07-17 [1] CRAN (R 4.1.0)
#>  cluster        2.1.2      2021-04-17 [1] CRAN (R 4.1.0)
#>  clustMixType   0.2-15     2021-08-18 [1] CRAN (R 4.1.0)
#>  codetools      0.2-18     2020-11-04 [1] CRAN (R 4.1.0)
#>  colorspace     2.0-2      2021-06-24 [1] CRAN (R 4.1.0)
#>  crayon         1.4.1      2021-02-08 [1] CRAN (R 4.1.0)
#>  DBI            1.1.1      2021-01-15 [1] CRAN (R 4.1.0)
#>  digest         0.6.28     2021-09-23 [1] CRAN (R 4.1.0)
#>  dismo          1.3-5      2021-10-11 [1] CRAN (R 4.1.0)
#>  doSNOW         1.0.19     2020-10-16 [1] CRAN (R 4.1.0)
#>  dplyr          1.0.7      2021-06-18 [1] CRAN (R 4.1.0)
#>  ellipsis       0.3.2      2021-04-29 [1] CRAN (R 4.1.0)
#>  evaluate       0.14       2019-05-28 [1] CRAN (R 4.1.0)
#>  fansi          0.5.0      2021-05-25 [1] CRAN (R 4.1.0)
#>  fastmap        1.1.0      2021-01-25 [1] CRAN (R 4.1.0)
#>  fastmatch      1.1-3      2021-07-23 [1] CRAN (R 4.1.0)
#>  foreach        1.5.1      2020-10-15 [1] CRAN (R 4.1.0)
#>  fs             1.5.0      2020-07-31 [1] CRAN (R 4.1.0)
#>  furrr          0.2.3      2021-06-25 [1] CRAN (R 4.1.0)
#>  future       * 1.22.1     2021-08-25 [1] CRAN (R 4.1.0)
#>  generics       0.1.0      2020-10-31 [1] CRAN (R 4.1.0)
#>  geometry       0.4.5      2019-12-04 [1] CRAN (R 4.1.0)
#>  globals        0.14.0     2020-11-22 [1] CRAN (R 4.1.0)
#>  glue           1.4.2      2020-08-27 [1] CRAN (R 4.1.0)
#>  highr          0.9        2021-04-16 [1] CRAN (R 4.1.0)
#>  htmltools      0.5.2      2021-08-25 [1] CRAN (R 4.1.0)
#>  igraph         1.2.7      2021-10-15 [1] CRAN (R 4.1.0)
#>  iterators      1.0.13     2020-10-15 [1] CRAN (R 4.1.0)
#>  itertools      0.1-3      2014-03-12 [1] CRAN (R 4.1.0)
#>  knitr          1.36       2021-09-29 [1] CRAN (R 4.1.0)
#>  lattice        0.20-44    2021-05-02 [1] CRAN (R 4.1.0)
#>  lifecycle      1.0.1      2021-09-24 [1] CRAN (R 4.1.0)
#>  listenv        0.8.0      2019-12-05 [1] CRAN (R 4.1.0)
#>  magic          1.5-9      2018-09-17 [1] CRAN (R 4.1.0)
#>  magrittr       2.0.1      2020-11-17 [1] CRAN (R 4.1.0)
#>  MASS           7.3-54     2021-05-03 [1] CRAN (R 4.1.0)
#>  Matrix         1.3-4      2021-06-01 [1] CRAN (R 4.1.0)
#>  mgcv           1.8-36     2021-06-01 [1] CRAN (R 4.1.0)
#>  nlme           3.1-152    2021-02-04 [1] CRAN (R 4.1.0)
#>  parallelly     1.28.1     2021-09-09 [1] CRAN (R 4.1.0)
#>  permute        0.9-5      2019-03-12 [1] CRAN (R 4.1.0)
#>  phangorn       2.7.1      2021-07-13 [1] CRAN (R 4.1.0)
#>  phyloregion    1.0.6      2021-05-01 [1] CRAN (R 4.1.0)
#>  picante        1.8.2      2020-06-10 [1] CRAN (R 4.1.0)
#>  pillar         1.6.4      2021-10-18 [1] CRAN (R 4.1.0)
#>  pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.1.0)
#>  progressr      0.9.0      2021-09-24 [1] CRAN (R 4.1.0)
#>  purrr        * 0.3.4      2020-04-17 [1] CRAN (R 4.1.0)
#>  quadprog       1.5-8      2019-11-20 [1] CRAN (R 4.1.0)
#>  R.cache        0.15.0     2021-04-30 [1] CRAN (R 4.1.0)
#>  R.methodsS3    1.8.1      2020-08-26 [1] CRAN (R 4.1.0)
#>  R.oo           1.24.0     2020-08-26 [1] CRAN (R 4.1.0)
#>  R.utils        2.10.1     2020-08-26 [1] CRAN (R 4.1.0)
#>  R6             2.5.1      2021-08-19 [1] CRAN (R 4.1.0)
#>  randomForest   4.6-14     2018-03-25 [1] CRAN (R 4.1.0)
#>  raster         3.5-2      2021-10-11 [1] CRAN (R 4.1.0)
#>  rcdd           1.4        2021-10-19 [1] CRAN (R 4.1.0)
#>  RColorBrewer   1.1-2      2014-12-07 [1] CRAN (R 4.1.0)
#>  Rcpp           1.0.7      2021-07-07 [1] CRAN (R 4.1.0)
#>  reprex         2.0.0      2021-04-02 [1] CRAN (R 4.1.0)
#>  rgeos          0.5-8      2021-09-22 [1] CRAN (R 4.1.0)
#>  rlang          0.4.12     2021-10-18 [1] CRAN (R 4.1.0)
#>  rmarkdown      2.11       2021-09-14 [1] CRAN (R 4.1.0)
#>  rstudioapi     0.13       2020-11-12 [1] CRAN (R 4.1.0)
#>  sessioninfo    1.1.1      2018-11-05 [1] CRAN (R 4.1.0)
#>  snow           0.4-3      2018-09-14 [1] CRAN (R 4.1.0)
#>  sp             1.4-5      2021-01-10 [1] CRAN (R 4.1.0)
#>  stringi        1.7.5      2021-10-04 [1] CRAN (R 4.1.0)
#>  stringr        1.4.0      2019-02-10 [1] CRAN (R 4.1.0)
#>  styler         1.6.2      2021-09-23 [1] CRAN (R 4.1.0)
#>  terra          1.4-11     2021-10-11 [1] CRAN (R 4.1.0)
#>  tibble         3.1.5      2021-09-30 [1] CRAN (R 4.1.0)
#>  tidyselect     1.1.1      2021-04-30 [1] CRAN (R 4.1.0)
#>  utf8           1.2.2      2021-07-24 [1] CRAN (R 4.1.0)
#>  vctrs          0.3.8      2021-04-29 [1] CRAN (R 4.1.0)
#>  vegan          2.5-7      2020-11-28 [1] CRAN (R 4.1.0)
#>  withr          2.4.2      2021-04-18 [1] CRAN (R 4.1.0)
#>  xfun           0.27       2021-10-18 [1] CRAN (R 4.1.0)
#>  yaml           2.2.1      2020-02-01 [1] CRAN (R 4.1.0)
#> 
#> [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library
joelnitta added a commit that referenced this issue Oct 20, 2021
Otherwise parallelization test fails (results not same as sequential)

See issue #2
@joelnitta
Copy link
Collaborator Author

Update 1: The back-end for generating random communities has changed from picante to vegan, and the back-end for parallelization from furrr to future.apply, but a similar problem persists.

Update 2: there is now a work-around for this, but not a good solution yet.

The work-around is to first perform a "warmup" of cpr_rand_test() using similar settings to the "real" call. It seems other values can also be used (e.g., seq_res_0 <- cpr_rand_test(phylocom$comm, phylocom$phy, null_model = "r00", n_iterations = 1, n_reps = 1, quiet = TRUE)).

At a217b2e

Examples:

  1. set.seed() doesn't work as expected, sequential mode
library(canaper)
library(testthat)

# Sequential, 1st try
set.seed(12345)
seq_res_1 <- cpr_rand_test(biod_example$comm, biod_example$phy, null_model = "curveball", n_iterations = 10, n_reps = 10)
set.seed(67890)
seq_res_2 <- cpr_rand_test(biod_example$comm, biod_example$phy, null_model = "curveball", n_iterations = 10, n_reps = 10)
set.seed(12345)
seq_res_3 <- cpr_rand_test(biod_example$comm, biod_example$phy, null_model = "curveball", n_iterations = 10, n_reps = 10)

expect_true(isTRUE(all.equal(seq_res_1, seq_res_3)))
#> Error: isTRUE(all.equal(seq_res_1, seq_res_3)) is not TRUE
#> 
#> `actual`:   FALSE
#> `expected`: TRUE
expect_false(isTRUE(all.equal(seq_res_1, seq_res_2)))
  1. set.seed() works after adding "dummy" run (seq_res_0) in sequential mode
library(canaper)
library(testthat)

# Sequential, 2nd try
# add extra run before others
seq_res_0 <- cpr_rand_test(biod_example$comm, biod_example$phy, null_model = "curveball", n_iterations = 10, n_reps = 10)
set.seed(12345)
seq_res_1 <- cpr_rand_test(biod_example$comm, biod_example$phy, null_model = "curveball", n_iterations = 10, n_reps = 10)
set.seed(67890)
seq_res_2 <- cpr_rand_test(biod_example$comm, biod_example$phy, null_model = "curveball", n_iterations = 10, n_reps = 10)
set.seed(12345)
seq_res_3 <- cpr_rand_test(biod_example$comm, biod_example$phy, null_model = "curveball", n_iterations = 10, n_reps = 10)

expect_true(isTRUE(all.equal(seq_res_1, seq_res_3)))
expect_false(isTRUE(all.equal(seq_res_1, seq_res_2)))
  1. set.seed() doesn't work as expected, parallel mode
library(canaper)
library(testthat)

# Parallel, first try
future::plan(future::multisession, workers = 3)
set.seed(12345)
par_res_1 <- cpr_rand_test(biod_example$comm, biod_example$phy, null_model = "curveball", n_iterations = 10, n_reps = 10)
set.seed(67890)
par_res_2 <- cpr_rand_test(biod_example$comm, biod_example$phy, null_model = "curveball", n_iterations = 10, n_reps = 10)
set.seed(12345)
par_res_3 <- cpr_rand_test(biod_example$comm, biod_example$phy, null_model = "curveball", n_iterations = 10, n_reps = 10)

expect_true(isTRUE(all.equal(par_res_1, par_res_3)))
#> Error: isTRUE(all.equal(par_res_1, par_res_3)) is not TRUE
#> 
#> `actual`:   FALSE
#> `expected`: TRUE
expect_false(isTRUE(all.equal(par_res_1, par_res_2)))
  1. set.seed() works after adding "dummy" run (seq_res_0) in parallel mode
library(canaper)
library(testthat)

# Parallel, 2nd try: Set future resolution to parallelized, with 3 workers
future::plan(future::multisession, workers = 3)
# add extra run before others
par_res_0 <- cpr_rand_test(phylocom$comm, phylocom$phy, null_model = "curveball", n_iterations = 10, n_reps = 10, quiet = TRUE)
set.seed(12345)
par_res_1 <- cpr_rand_test(biod_example$comm, biod_example$phy, null_model = "curveball", n_iterations = 10, n_reps = 10)
set.seed(67890)
par_res_2 <- cpr_rand_test(biod_example$comm, biod_example$phy, null_model = "curveball", n_iterations = 10, n_reps = 10)
set.seed(12345)
par_res_3 <- cpr_rand_test(biod_example$comm, biod_example$phy, null_model = "curveball", n_iterations = 10, n_reps = 10)

# can also reproduce results from sequential run
future::plan(future::sequential)
set.seed(12345)
seq_res_1 <- cpr_rand_test(biod_example$comm, biod_example$phy, null_model = "curveball", n_iterations = 10, n_reps = 10)

expect_true(isTRUE(all.equal(par_res_1, par_res_3)))
expect_false(isTRUE(all.equal(par_res_1, par_res_2)))
expect_true(isTRUE(all.equal(seq_res_1, par_res_1)))

Created on 2021-10-26 by the reprex package (v2.0.0)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.1.1 (2021-08-10)
#>  os       macOS Catalina 10.15.7      
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Asia/Tokyo                  
#>  date     2021-10-26                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version    date       lib source        
#>  abind          1.4-5      2016-07-21 [1] CRAN (R 4.1.0)
#>  ape            5.5        2021-04-25 [1] CRAN (R 4.1.0)
#>  assertr        2.8        2021-01-25 [1] CRAN (R 4.1.0)
#>  assertthat     0.2.1      2019-03-21 [1] CRAN (R 4.1.0)
#>  backports      1.2.1      2020-12-09 [1] CRAN (R 4.1.0)
#>  betapart       1.5.4      2021-04-11 [1] CRAN (R 4.1.0)
#>  canaper      * 0.0.0.9000 2021-10-26 [1] local         
#>  cli            3.0.1      2021-07-17 [1] CRAN (R 4.1.0)
#>  cluster        2.1.2      2021-04-17 [1] CRAN (R 4.1.1)
#>  clustMixType   0.2-15     2021-08-18 [1] CRAN (R 4.1.0)
#>  codetools      0.2-18     2020-11-04 [1] CRAN (R 4.1.1)
#>  colorspace     2.0-2      2021-06-24 [1] CRAN (R 4.1.0)
#>  crayon         1.4.1      2021-02-08 [1] CRAN (R 4.1.0)
#>  DBI            1.1.1      2021-01-15 [1] CRAN (R 4.1.0)
#>  digest         0.6.28     2021-09-23 [1] CRAN (R 4.1.0)
#>  dismo          1.3-5      2021-10-11 [1] CRAN (R 4.1.0)
#>  doSNOW         1.0.19     2020-10-16 [1] CRAN (R 4.1.0)
#>  dplyr          1.0.7      2021-06-18 [1] CRAN (R 4.1.0)
#>  ellipsis       0.3.2      2021-04-29 [1] CRAN (R 4.1.0)
#>  evaluate       0.14       2019-05-28 [1] CRAN (R 4.1.0)
#>  fansi          0.5.0      2021-05-25 [1] CRAN (R 4.1.0)
#>  fastmap        1.1.0      2021-01-25 [1] CRAN (R 4.1.0)
#>  fastmatch      1.1-3      2021-07-23 [1] CRAN (R 4.1.0)
#>  foreach        1.5.1      2020-10-15 [1] CRAN (R 4.1.0)
#>  fs             1.5.0      2020-07-31 [1] CRAN (R 4.1.0)
#>  future         1.22.1     2021-08-25 [1] CRAN (R 4.1.0)
#>  future.apply   1.8.1      2021-08-10 [1] CRAN (R 4.1.0)
#>  generics       0.1.0      2020-10-31 [1] CRAN (R 4.1.0)
#>  geometry       0.4.5      2019-12-04 [1] CRAN (R 4.1.0)
#>  globals        0.14.0     2020-11-22 [1] CRAN (R 4.1.0)
#>  glue           1.4.2      2020-08-27 [1] CRAN (R 4.1.0)
#>  highr          0.9        2021-04-16 [1] CRAN (R 4.1.0)
#>  htmltools      0.5.2      2021-08-25 [1] CRAN (R 4.1.0)
#>  igraph         1.2.7      2021-10-15 [1] CRAN (R 4.1.0)
#>  iterators      1.0.13     2020-10-15 [1] CRAN (R 4.1.0)
#>  itertools      0.1-3      2014-03-12 [1] CRAN (R 4.1.0)
#>  knitr          1.36       2021-09-29 [1] CRAN (R 4.1.0)
#>  lattice        0.20-44    2021-05-02 [1] CRAN (R 4.1.1)
#>  lifecycle      1.0.1      2021-09-24 [1] CRAN (R 4.1.0)
#>  listenv        0.8.0      2019-12-05 [1] CRAN (R 4.1.0)
#>  magic          1.5-9      2018-09-17 [1] CRAN (R 4.1.0)
#>  magrittr       2.0.1      2020-11-17 [1] CRAN (R 4.1.0)
#>  MASS           7.3-54     2021-05-03 [1] CRAN (R 4.1.1)
#>  Matrix         1.3-4      2021-06-01 [1] CRAN (R 4.1.1)
#>  mgcv           1.8-36     2021-06-01 [1] CRAN (R 4.1.1)
#>  nlme           3.1-152    2021-02-04 [1] CRAN (R 4.1.1)
#>  parallelly     1.28.1     2021-09-09 [1] CRAN (R 4.1.0)
#>  permute        0.9-5      2019-03-12 [1] CRAN (R 4.1.0)
#>  phangorn       2.7.1      2021-07-13 [1] CRAN (R 4.1.0)
#>  phyloregion    1.0.6      2021-05-01 [1] CRAN (R 4.1.0)
#>  picante        1.8.2      2020-06-10 [1] CRAN (R 4.1.0)
#>  pillar         1.6.4      2021-10-18 [1] CRAN (R 4.1.0)
#>  pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.1.0)
#>  progressr      0.9.0      2021-09-24 [1] CRAN (R 4.1.0)
#>  purrr          0.3.4      2020-04-17 [1] CRAN (R 4.1.0)
#>  quadprog       1.5-8      2019-11-20 [1] CRAN (R 4.1.0)
#>  R.cache        0.15.0     2021-04-30 [1] CRAN (R 4.1.0)
#>  R.methodsS3    1.8.1      2020-08-26 [1] CRAN (R 4.1.0)
#>  R.oo           1.24.0     2020-08-26 [1] CRAN (R 4.1.0)
#>  R.utils        2.10.1     2020-08-26 [1] CRAN (R 4.1.0)
#>  R6             2.5.1      2021-08-19 [1] CRAN (R 4.1.0)
#>  randomForest   4.6-14     2018-03-25 [1] CRAN (R 4.1.0)
#>  raster         3.5-2      2021-10-11 [1] CRAN (R 4.1.0)
#>  rcdd           1.4        2021-10-19 [1] CRAN (R 4.1.0)
#>  RColorBrewer   1.1-2      2014-12-07 [1] CRAN (R 4.1.0)
#>  Rcpp           1.0.7      2021-07-07 [1] CRAN (R 4.1.0)
#>  reprex         2.0.0      2021-04-02 [1] CRAN (R 4.1.0)
#>  rgeos          0.5-8      2021-09-22 [1] CRAN (R 4.1.0)
#>  rlang          0.4.12     2021-10-18 [1] CRAN (R 4.1.0)
#>  rmarkdown      2.11       2021-09-14 [1] CRAN (R 4.1.0)
#>  rstudioapi     0.13       2020-11-12 [1] CRAN (R 4.1.0)
#>  sessioninfo    1.1.1      2018-11-05 [1] CRAN (R 4.1.0)
#>  snow           0.4-3      2018-09-14 [1] CRAN (R 4.1.0)
#>  sp             1.4-5      2021-01-10 [1] CRAN (R 4.1.0)
#>  stringi        1.7.5      2021-10-04 [1] CRAN (R 4.1.0)
#>  stringr        1.4.0      2019-02-10 [1] CRAN (R 4.1.0)
#>  styler         1.6.2      2021-09-23 [1] CRAN (R 4.1.0)
#>  terra          1.4-11     2021-10-11 [1] CRAN (R 4.1.0)
#>  testthat     * 3.1.0      2021-10-04 [1] CRAN (R 4.1.0)
#>  tibble         3.1.5      2021-09-30 [1] CRAN (R 4.1.0)
#>  tidyselect     1.1.1      2021-04-30 [1] CRAN (R 4.1.0)
#>  utf8           1.2.2      2021-07-24 [1] CRAN (R 4.1.0)
#>  vctrs          0.3.8      2021-04-29 [1] CRAN (R 4.1.0)
#>  vegan          2.5-7      2020-11-28 [1] CRAN (R 4.1.0)
#>  waldo          0.3.1      2021-09-14 [1] CRAN (R 4.1.0)
#>  withr          2.4.2      2021-04-18 [1] CRAN (R 4.1.0)
#>  xfun           0.27       2021-10-18 [1] CRAN (R 4.1.0)
#>  yaml           2.2.1      2020-02-01 [1] CRAN (R 4.1.0)
#> 
#> [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library

@joelnitta
Copy link
Collaborator Author

The solution, as described here, is to avoid using {phyloregion}, which includes {betapart} as a dependency, which in turn includes {snow} as a dependency in SUGGESTS, which uses the random number generator upon loading.

Since it is in SUGGESTS, the RNG usage doesn't happen until the phyloregion function gets called and loads it.

So even though {snow} is never actually used it gets loaded and resets the RNG. Work-around is to avoid loading it by not using the packages that includes it in SUGGESTS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant