Skip to content

Commit fcc2d23

Browse files
authored
Merge pull request #138 from rsetienne/develop
v4.0.5
2 parents e607ce8 + 6b6bc26 commit fcc2d23

33 files changed

+915
-233
lines changed

.Rbuildignore

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
^pics$
1313
^\.github$
1414

15-
invoke_IW\.R
16-
test\.R
17-
test\.sh
1815
^\.Rproj\.user$
1916
^\.covrignore$
2017
^LICENSE$

.github/workflows/R-CMD-check.yaml

+4-12
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@
22
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
33
on:
44
push:
5-
branches:
6-
- main
7-
- master
8-
- develop
9-
- DAISIE_IW_B
10-
115
pull_request:
12-
branches:
13-
- main
14-
- master
15-
- develop
6+
schedule:
7+
- cron: "0 0 * * *"
168

179
name: R-CMD-check
1810

@@ -28,8 +20,8 @@ jobs:
2820
config:
2921
- {os: windows-latest, r: 'release'}
3022
- {os: macOS-latest, r: 'release'}
31-
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
32-
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
23+
- {os: ubuntu-latest, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
24+
- {os: ubuntu-latest, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
3325

3426
env:
3527
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true

.github/workflows/test-coverage.yaml

+8-31
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,27 @@
11
on:
22
push:
3-
branches:
4-
- main
5-
- master
6-
- develop
73
pull_request:
8-
branches:
9-
- main
10-
- master
11-
- develop
4+
schedule:
5+
- cron: "0 0 * * *"
126

137
name: test-coverage
148

159
jobs:
1610
test-coverage:
17-
runs-on: ubuntu-20.04
18-
11+
runs-on: ubuntu-latest
1912
env:
2013
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
14+
2115
steps:
2216
- uses: actions/checkout@v2
2317

2418
- uses: r-lib/actions/setup-r@v1
25-
26-
- uses: r-lib/actions/setup-pandoc@v1
27-
28-
- name: Query dependencies
29-
run: |
30-
install.packages('remotes')
31-
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
32-
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
33-
shell: Rscript {0}
34-
35-
- name: Restore R package cache
36-
uses: actions/cache@v2
3719
with:
38-
path: ${{ env.R_LIBS_USER }}
39-
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
40-
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
20+
use-public-rspm: true
4121

42-
- name: Install dependencies
43-
run: |
44-
install.packages(c("remotes"))
45-
remotes::install_deps(dependencies = TRUE)
46-
remotes::install_cran("covr")
47-
shell: Rscript {0}
22+
- uses: r-lib/actions/setup-r-dependencies@v1
23+
with:
24+
extra-packages: covr
4825

4926
- name: Test coverage
5027
run: covr::codecov()

DESCRIPTION

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: DAISIE
22
Type: Package
33
Title: Dynamical Assembly of Islands by Speciation, Immigration and Extinction
4-
Version: 4.0.2
5-
Date: 2021-05-26
4+
Version: 4.0.5
5+
Date: 2021-11-17
66
Depends: R (>= 3.5.0)
77
biocViews:
88
SystemRequirements: C++14
@@ -115,4 +115,4 @@ Encoding: UTF-8
115115
VignetteBuilder: knitr
116116
URL: https://github.com/rsetienne/DAISIE
117117
BugReports: https://github.com/rsetienne/DAISIE/issues
118-
RoxygenNote: 7.1.1
118+
RoxygenNote: 7.1.2

NAMESPACE

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
export(DAISIE_ExpEIN)
44
export(DAISIE_IC)
5+
export(DAISIE_IW_num_threads)
56
export(DAISIE_ML)
67
export(DAISIE_ML_CS)
78
export(DAISIE_ML_IW)
@@ -34,6 +35,7 @@ export(create_CS_version)
3435
export(create_area_pars)
3536
export(create_hyper_pars)
3637
export(create_trait_pars)
38+
export(daisie_odeint_cs)
3739
export(daisie_odeint_iw)
3840
import(Rcpp)
3941
importFrom(doParallel,registerDoParallel)

NEWS.md

+18
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
1+
# DAISIE 4.0.5
2+
3+
**N.B.: MacOS users may experience issues when installing DAISIE, especially when on MacOS Big Sur. If that is you case, please see [here](https://github.com/rsetienne/DAISIE/blob/6da0e3f65680d5f237345ef80935bda7541cf230/doc/DAISIE_macOS.md) for detailed installation instructions.**
4+
5+
* CS model can be fit with C++ code, similarly to the IW model since version v3.2.0. To do so, set `methode` to:
6+
* `"odeint::runge_kutta_cash_karp54"`
7+
* `"odeint::runge_kutta_fehlberg78"` [default]
8+
* `"odeint::runge_kutta_dopri5"`
9+
* `"odeint::bulirsch_stoer"`
10+
11+
without the `odeint::`-prefix, the `deSolve::ode` method is assumed. `deSolve::ode` using `"lsodes"` is still the default, as before. Make sure `CS_version = 0` (default) to use C++ ODEINT numerical integration.
12+
* Better handling of number of threads to use with `DAISIE_IW_num_threads()` for ML estimation of the IW model when more threads are available.
13+
* Fixes to numerical instability in conditional probability calculation in the IW model when the probability of extinction is very close to 1.
14+
* Introduce an approximation when the log conditional likelihood cannot be computed and add message when this is triggered.
15+
116
# DAISIE 4.0.2
17+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4813095.svg)](https://doi.org/10.5281/zenodo.4813095)
218

319
**N.B.: MacOS users may experience issues when installing DAISIE, especially when on MacOS Big Sur. If that is you case, please see [here](https://github.com/rsetienne/DAISIE/blob/6da0e3f65680d5f237345ef80935bda7541cf230/doc/DAISIE_macOS.md) for detailed installation instructions.**
420

521
* Suggest ggtree >= 3.0.0.
622

723
# DAISIE 4.0.1
24+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4813094.svg)](https://doi.org/10.5281/zenodo.4813094)
825

926
**N.B.: MacOS users may experience issues when installing DAISIE, especially when on MacOS Big Sur. If that is you case, please see [here](https://github.com/rsetienne/DAISIE/blob/6da0e3f65680d5f237345ef80935bda7541cf230/doc/DAISIE_macOS.md) for detailed installation instructions.**
1027

1128
* Fix possibility of fitting CS model with IW likelihood on simulated data by setting `CS_version = 0`. Improve `CS_version` documentation.
1229

1330
# DAISIE 4.0.0
31+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4813090.svg)](https://doi.org/10.5281/zenodo.4813090)
1432

1533
**N.B.: MacOS users may experience issues when installing DAISIE, especially when on MacOS Big Sur. If that is you case, please see [here](https://github.com/rsetienne/DAISIE/blob/6da0e3f65680d5f237345ef80935bda7541cf230/doc/DAISIE_macOS.md) for detailed installation instructions.**
1634

R/DAISIE-package.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
#' \item Valente, L., Etienne, R. S., & Garcia-R, J. C. (2019). Deep macroevolutionary impact of humans on New Zealand's unique avifauna. Current Biology 29: 2563-2569. \doi{10.1016/j.cub.2019.06.058}.\cr
1414
#' \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
1515
#' \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
16-
#' } \cr
16+
#' \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
17+
#' \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 2021.07.26.453064. \doi{10.1101/2021.07.26.453064}.\cr
18+
#' }
1719
#' @keywords internal
1820
#' @import Rcpp
1921
#' @useDynLib DAISIE, .registration = TRUE

R/DAISIE_SR_loglik_CS.R

+7-14
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ odeproc <- function(
3131
method = method)
3232
} else
3333
if (times[1] < tshift & times[2] > tshift) {
34-
#y = deSolve::ode(probs,c(times[1],tshift),fun,pars1,rtol = rtol,atol = atol,method = method)
35-
y <- DAISIE_integrate(probs, c(times[1], tshift), fun, pars1, rtol = rtol, atol = atol, method = method)
36-
probs <- y[2, 2:ncol(y)]
37-
#y = deSolve::ode(probs,c(tshift,times[2]),fun,pars2,rtol = rtol,atol = atol,method = method)
34+
probs <- DAISIE_integrate(probs, c(times[1], tshift), fun, pars1, rtol = rtol, atol = atol, method = method)
35+
3836
y <- DAISIE_integrate(probs, c(tshift, times[2]), fun, pars2, rtol = rtol, atol = atol, method = method)
3937
}
4038
return(y)
@@ -147,8 +145,7 @@ DAISIE_SR_loglik_CS_M1 <- DAISIE_SR_loglik <- function(
147145
probs <- rep(0, 2 * lx + 1)
148146
probs[1] <- 1
149147
k1 <- 0
150-
y <- odeproc(probs, brts[1:2], DAISIE_loglik_rhs, c(pars1, k1, ddep), rtol = reltolint, atol = abstolint, method = methode)
151-
probs <- y[2, 2:(2 * lx + 2)]
148+
probs <- odeproc(probs, brts[1:2], DAISIE_loglik_rhs, c(pars1, k1, ddep), rtol = reltolint, atol = abstolint, method = methode)
152149
cp <- checkprobs(lv = 2 * lx, loglik, probs, verbose); loglik <- cp[[1]]; probs <- cp[[2]]
153150
if (stac == 0) {
154151
# for stac = 0, the integration is from the origin of the island until the present
@@ -164,17 +161,15 @@ DAISIE_SR_loglik_CS_M1 <- DAISIE_SR_loglik <- function(
164161
# but there can be missing species
165162
# for stac = 5, we do exactly the same, but we evaluate the probability of an endemic species being present alone.
166163
probs[(lx + 1):(2 * lx)] <- 0
167-
y <- odeproc(probs, brts[2:3], DAISIE_loglik_rhs, c(pars1, k1, ddep), rtol = reltolint, atol = abstolint, method = methode)
168-
probs <- y[2, 2:(2 * lx + 2)]
164+
probs <- odeproc(probs, brts[2:3], DAISIE_loglik_rhs, c(pars1, k1, ddep), rtol = reltolint, atol = abstolint, method = methode)
169165
cp <- checkprobs(lv = 2 * lx, loglik, probs, verbose); loglik <- cp[[1]]; probs <- cp[[2]]
170166
loglik <- loglik + log(probs[(stac == 1) * lx + (stac == 5) + 1 + missnumspec])
171167
} else {
172168
# for stac > 1, but not 5, integration is then from the colonization event until the first branching time (stac = 2 and 3) or the present (stac = 4). We add a set of equations for Q_M,n, the probability that the process is compatible with the data, and speciation has not happened; during this time immigration is not allowed because it would alter the colonization time. After speciation, colonization is allowed again (re-immigration)
173169
# all probabilities of states with the immigrant present are set to zero and all probabilities of states with endemics present are transported to the state with the colonist present waiting for speciation to happen. We also multiply by the (possibly diversity-dependent) immigration rate
174170
if (stac == 6 || stac == 7) {
175171
probs[(lx + 1):(2 * lx)] <- 0
176-
y <- odeproc(probs, brts[2:3], DAISIE_loglik_rhs, c(pars1, k1, ddep), rtol = reltolint, atol = abstolint, method = methode)
177-
probs <- y[2, 2:(2 * lx + 2)]
172+
probs <- odeproc(probs, brts[2:3], DAISIE_loglik_rhs, c(pars1, k1, ddep), rtol = reltolint, atol = abstolint, method = methode)
178173
cp <- checkprobs(lv = 2 * lx, loglik, probs, verbose); loglik <- cp[[1]]; probs <- cp[[2]]
179174
k1 <- 1
180175
}
@@ -184,8 +179,7 @@ DAISIE_SR_loglik_CS_M1 <- DAISIE_SR_loglik <- function(
184179
gamvec[2:(lx + 1)] * probs[(lx + 1):(2 * lx)]
185180
probs[1:(2 * lx)] <- 0
186181
k1 <- 1
187-
y <- odeproc(probs, brts[2:3], DAISIE_loglik_rhs2, c(pars1, k1, ddep), rtol = reltolint, atol = abstolint, method = methode)
188-
probs <- y[2, 2:(3 * lx + 1)]
182+
probs <- odeproc(probs, brts[2:3], DAISIE_loglik_rhs2, c(pars1, k1, ddep), rtol = reltolint, atol = abstolint, method = methode)
189183
cp <- checkprobs2(lx, loglik, probs, verbose); loglik <- cp[[1]]; probs <- cp[[2]]
190184
}
191185
if (stac == 4) {
@@ -215,8 +209,7 @@ DAISIE_SR_loglik_CS_M1 <- DAISIE_SR_loglik <- function(
215209
}
216210
for (k in startk:S1) {
217211
k1 <- k - 1
218-
y <- odeproc(probs, brts[k:(k + 1)], DAISIE_loglik_rhs, c(pars1, k1, ddep), rtol = reltolint, atol = abstolint, method = methode)
219-
probs <- y[2, 2:(2 * lx + 2)]
212+
probs <- odeproc(probs, brts[k:(k + 1)], DAISIE_loglik_rhs, c(pars1, k1, ddep), rtol = reltolint, atol = abstolint, method = methode)
220213
cp <- checkprobs2(lx, loglik, probs, verbose); loglik <- cp[[1]]; probs <- cp[[2]]
221214
if (k < S1) {
222215
# speciation event

0 commit comments

Comments
 (0)