Skip to content

Commit

Permalink
Merge pull request #152 from rsetienne/develop
Browse files Browse the repository at this point in the history
V4.3.0
  • Loading branch information
rsetienne authored Jan 26, 2023
2 parents 58ecf4a + 362a3a5 commit d0ed3df
Show file tree
Hide file tree
Showing 51 changed files with 1,661 additions and 1,083 deletions.
76 changes: 19 additions & 57 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"

name: R-CMD-check

Expand All @@ -14,73 +12,37 @@ jobs:

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

if: "contains(github.event.head_commit.message, '[run ci]') || (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop')"

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-pandoc@v1

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
if (.Platform$OS.type == "unix") remotes::install_cran("doMC")
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
extra-packages: any::rcmdcheck, doMC=?ignore
needs: check

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
- uses: r-lib/actions/check-r-package@v2
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
upload-snapshots: true
36 changes: 29 additions & 7 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, '[run ci]') || (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop')"

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: covr
extra-packages: any::covr
needs: coverage

- name: Test coverage
run: covr::codecov()
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
17 changes: 9 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: DAISIE
Type: Package
Title: Dynamical Assembly of Islands by Speciation, Immigration and Extinction
Version: 4.2.1
Date: 2022-06-08
Version: 4.3.0
Date: 2023-12-26
Depends: R (>= 3.5.0)
biocViews:
SystemRequirements: C++14
Expand All @@ -11,7 +11,7 @@ Imports:
graphics,
stats,
utils,
DDD (>= 4.4),
DDD (>= 5.0),
subplex,
Matrix,
tensor,
Expand All @@ -21,11 +21,11 @@ Imports:
doParallel,
magrittr,
parallel,
Rcpp (>= 1.0.5)
Rcpp (>= 1.0.10)
LinkingTo:
Rcpp,
RcppEigen,
BH
BH (>= 1.81.0-1)
Suggests:
covr,
testthat (>= 2.1.0),
Expand Down Expand Up @@ -67,7 +67,7 @@ Authors@R: c(
email = "j.w.l.lambert@rug.nl",
comment = c(ORCID = "0000-0001-5218-3046")),
person(given = "Pedro",
family = "Neves",
family = "Santos Neves",
role = c("aut"),
email = "p.m.santos.neves@rug.nl",
comment = c(ORCID = "0000-0003-2561-4677")),
Expand All @@ -84,7 +84,8 @@ Authors@R: c(
person(given = "Hanno",
family = "Hildenbrandt",
email = "h.hildenbrandt@rug.nl",
role = c("aut")),
role = c("aut"),
comment = c(ORCID = "0000-0002-6784-1037")),
person(given = "Torsten",
family = "Hauffe",
email = "torsten.hauffe@gmail.com",
Expand Down Expand Up @@ -115,4 +116,4 @@ Encoding: UTF-8
VignetteBuilder: knitr
URL: https://github.com/rsetienne/DAISIE
BugReports: https://github.com/rsetienne/DAISIE/issues
RoxygenNote: 7.2.0
RoxygenNote: 7.2.3
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export(DAISIE_SR_loglik_CS)
export(DAISIE_SR_loglik_all)
export(DAISIE_abm_factor)
export(DAISIE_convertprobdist)
export(DAISIE_count_species)
export(DAISIE_dataprep)
export(DAISIE_loglik_CS)
export(DAISIE_loglik_IW)
Expand All @@ -32,12 +33,14 @@ export(DAISIE_sim_cr_shift)
export(DAISIE_sim_relaxed_rate)
export(DAISIE_sim_time_dep)
export(DAISIE_sim_trait_dep)
export(DAISIE_sim_trait_dep_2K)
export(are_area_pars)
export(create_CS_version)
export(create_area_pars)
export(create_hyper_pars)
export(create_pars)
export(create_trait_pars)
export(create_trait_pars_2K)
export(daisie_odeint_cs)
export(daisie_odeint_iw)
import(Rcpp)
Expand Down
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# DAISIE 4.3.0

* Due to recent changes in CRAN policy that result in warnings due to the use of Rcpp related packages that link to libraries that use `sprintf` ('Rcpp' and 'BH'), 'DAISIE' now requires Rcpp v(>= 1.0.10) and BH v(>= 1.81.0-1). See https://github.com/RcppCore/Rcpp/pull/1236 and https://github.com/eddelbuettel/bh/pull/90 respectively. Also require package 'DDD' v(>= 5.0.0).
* Add code for the trait-dependent simulations considering two carrying capacities for each trait state.
* Improvements to the relaxed rate model fitting procedure.
* Add `DAISIE_count_species()` to count the number of species in a datalist or simulated data.
* Simply printing code by wrapping multiple instances into `print_parameters_and_loglik()`.
* Overall documentation improvements and updated references.
* Bug fix in `DAISIE_sim_cr_iw()`, which wrongly computed number of species at present. #147
* Improve the likelihood calculation. Fixed incorrect likelihood present for type 2 case CS model inference if the values of lambda were high, in the C++ implementation.
* Overhaul GHA workflows to be more up to date and more conservative when to run. Feature branches require the tag
[run ci] be added to the commit message to run.

# DAISIE 4.2.1

* Bug fixes in `DAISIE_loglik_CS()`on the likelihood code for the continental sampling (probability of initial presence on the island).
Expand Down
4 changes: 2 additions & 2 deletions R/DAISIE-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#' \item Valente, L., Phillimore, A. B., Melo, M., Warren, B. H., Clegg, S. M., Havenstein, K., & Etienne, R. S. (2020). A simple dynamic model explains the diversity of island birds worldwide. Nature 579: 92-96. \doi{10.1038/s41586-020-2022-5}.\cr
#' \item Hauffe, T., Delicado, D., Etienne, R.S., & Valente, L. (2020). Lake expansion elevates equilibrium diversity via increasing colonization. Journal of Biogeography 47: 1849–1860. \doi{10.1111/jbi.13914}.\cr
#' \item Valente, L., Kristensen, N., Phillimore, A. B., & Etienne, R. S. (2021). Report of programming bugs in the DAISIE R package: consequences and correction. EcoEvoRxiv. \doi{10.32942/osf.io/w5ntf}.\cr
#' \item Santos Neves, P., Lambert, J. W., Valente, L., & Etienne, R. S. (2021).The robustness of a simple dynamic model of island biodiversity to geological and eustatic change. bioRxiv. \doi{10.1101/2021.07.26.453064}.\cr
#' \item Santos Neves, P., Lambert, J. W., Valente, L., & Etienne, R. S. (2022). The robustness of a simple dynamic model of island biodiversity to geological and sea-level change. Journal of Biogeography. \doi{10.1111/jbi.14519}.\cr
#' \item Lambert, J. W., Santos Neves, P., Bilderbeek, R. L. C., Valente, L., Etienne, R. S. (2022). The effect of mainland dynamics on data and parameter estimates in island biogeography. bioRxiv. \doi{10.1101/2022.01.13.476210}.\cr
#' \item Xie, S., Valente, L., Etienne, R. S. (2022). A simple island biodiversity model is robust to trait dependence in diversification and colonization rates. biRrxiv. \doi{10.1101/2022.01.01.474685}.\cr
#' \item Xie, S., Valente, L., Etienne, R. S. (2023). Can we ignore trait-dependent colonization and diversification in island biogeography? Evolution. \doi{10.1093/evolut/qpad006}.\cr
#' }
#' @keywords internal
#' @import Rcpp
Expand Down
56 changes: 21 additions & 35 deletions R/DAISIE_ML1.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ DAISIE_loglik_all_choosepar <- function(trparsopt,
abstolint = 1E-16,
reltolint = 1E-10) {
all_no_shift <- 6:10
non_oceanic_option <- FALSE
if (max(idparsopt,-Inf) <= 6 &&
max(idparsfix,-Inf) <= 6 &&
(6 %in% idparsopt || 6 %in% idparsfix)) {
idparsnoshift <- 7:11
all_no_shift <- 7:11
non_oceanic_option <- TRUE
}
if (sum(idparsnoshift %in% (all_no_shift)) != 5) {
trpars1 <- rep(0, 11)
Expand Down Expand Up @@ -45,7 +47,7 @@ DAISIE_loglik_all_choosepar <- function(trparsopt,
pars1[idparsnoshift] <- pars1[idparsnoshift - 5]
}
}
if (min(pars1) < 0) {
if (min(pars1) < 0 | (pars1[6] > 1 && non_oceanic_option == TRUE)) {
loglik <- -Inf
} else {
loglik <- DAISIE_loglik_all(
Expand Down Expand Up @@ -240,13 +242,19 @@ DAISIE_ML1 <- function(
idpars <- sort(c(idparsopt, idparsfix, idparsnoshift, idparseq))

missnumspec <- unlist(lapply(datalist, function(list) {list$missing_species})) # nolint
if (sum(missnumspec) > (res - 1)) {
if (max(missnumspec) > (res - 1)) {
cat(
"The number of missing species is too large relative to the
resolution of the ODE.\n")
return(out2err)
}

if (max(missnumspec) > res/10) {
warning(
"The number of missing species is quite low relative to the
resolution of the ODE.\n")
}

if ((length(idpars) != max(idpars))) {
cat("The parameters to be optimized and/or fixed are incoherent.\n")
return(out2err)
Expand Down Expand Up @@ -391,20 +399,8 @@ DAISIE_ML1 <- function(
df = length(initparsopt),
conv = unlist(out$conv)
)
s1 <- sprintf(
"Maximum likelihood parameter estimates:\n lambda_c: %f\n mu: %f\n K: %f\n gamma: %f\n lambda_a: %f\n lambda_c2: %f\n mu2: %f\n K2: %f\n gamma2: %f\n lambda_a2: %f\n prop_type2: %f",
MLpars1[1],
MLpars1[2],
MLpars1[3],
MLpars1[4],
MLpars1[5],
MLpars1[6],
MLpars1[7],
MLpars1[8],
MLpars1[9],
MLpars1[10],
MLpars1[11]
)
pars_to_print <- MLpars1[1:11]
parnames <- c('lambda^c','mu','K','gamma','lambda^a','lambda^c2','mu2','K2','gamma2','lambda^a2','prop_type2')
} else if (all(all_no_shift == 7:11)) {
out2 <- data.frame(
lambda_c = MLpars1[1],
Expand All @@ -417,15 +413,8 @@ DAISIE_ML1 <- function(
df = length(initparsopt),
conv = unlist(out$conv)
)
s1 <- sprintf(
"Maximum likelihood parameter estimates:\n lambda_c: %f\n mu: %f\n K: %f\n gamma: %f\n lambda_a: %f\n prob_init_pres: %f",
MLpars1[1],
MLpars1[2],
MLpars1[3],
MLpars1[4],
MLpars1[5],
MLpars1[6]
)
pars_to_print <- MLpars1[1:6]
parnames <- c('lambda^c','mu','K','gamma','lambda^a','prob_init_pres')
} else {
out2 <- data.frame(
lambda_c = MLpars1[1],
Expand All @@ -437,17 +426,14 @@ DAISIE_ML1 <- function(
df = length(initparsopt),
conv = unlist(out$conv)
)
s1 <- sprintf(
"Maximum likelihood parameter estimates:\n lambda_c: %f\n mu: %f\n K: %f\n gamma: %f\n lambda_a: %f\n",
MLpars1[1],
MLpars1[2],
MLpars1[3],
MLpars1[4],
MLpars1[5]
)
pars_to_print <- MLpars1[1:5]
parnames <- c('lambda^c','mu','K','gamma','lambda^a')
}
s2 <- sprintf("Maximum loglikelihood: %f", ML)
cat("\n", s1, "\n", s2, "\n")
print_parameters_and_loglik(pars = pars_to_print,
loglik = ML,
verbose = TRUE,
parnames = parnames,
type = 'island_ML')
if (eqmodel > 0) {
M <- calcMN(datalist, MLpars1)
ExpEIN <- DAISIE_ExpEIN(datalist[[1]]$island_age, MLpars1, M) # nolint start
Expand Down
Loading

0 comments on commit d0ed3df

Please sign in to comment.