-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from MindTheGap-ERC/dev
Dev
- Loading branch information
Showing
19 changed files
with
274 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,17 @@ Version: 0.0.0.9000 | |
Authors@R: | ||
person("Niklas", "Hohmann", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0003-1559-1838")) | ||
Description: Models for stratigraphic paleobiology, including niche modeling and age-depth modeling. | ||
Description: The fossil record is a joint expression of ecological, taphonomic, | ||
evolutionary, and stratigraphic processes (Holland and Patzkowsky, 2012). | ||
This package allowing to simulate biological processes in the time domain | ||
(e.g., trait evolution, fossil abundance), and examine how their expression | ||
in the rock record (stratigraphic domain) is influenced based on | ||
age-depth models, ecological niche models, and taphonomic effects. | ||
Functions simulating common processes used in modeling trait evolution or | ||
event type data such as first/last occurrences are provided and can be used | ||
standalone or as part of a pipeline. The package comes with example | ||
data sets and tutorials in several vignettes, which can be used as a | ||
template to set up one's own simulation. | ||
License: Apache License (>= 2) | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(apply_niche_pref) | ||
export(apply_niche) | ||
export(apply_taphonomy) | ||
export(cnd) | ||
export(bounded_niche) | ||
export(ornstein_uhlenbeck) | ||
export(p3) | ||
export(p3_var_rate) | ||
export(random_walk) | ||
export(rej_samp) | ||
export(snd_niche) | ||
export(stasis) | ||
export(thin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
bounded_niche = function(g_min, g_max){ | ||
#' @export | ||
#' | ||
#' @title define niche from boundaries | ||
#' | ||
#' @param g_min lowest value of the gradient the taxon can tolerate | ||
#' @param g_max highest value of the gradient the taxon can tolerate | ||
#' | ||
#' @seealso [snd_niche()] for an alternative niche model, [apply_niche()] for the function that uses the function returned | ||
#' | ||
#' @returns a function describing the niche for usage with `apply_niche`. The function returns 1 if the taxon is within its niche (the gradient is between `g_min` and `g_max`), and 0 otherwise | ||
#' | ||
#' @description | ||
#' Defines a simple niche model where the niche defined is given by a lower limit (`g_min`) and an upper limie (`g_max`) of a gradient the taxon can tolerate | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' x = seq(0, 10, by = 0.2) | ||
#' f = bounded_niche(2,5) | ||
#' plot(x, f(x), type = "l", | ||
#' xlab = "Gradient", ylab = "Observation probability", | ||
#' main = "Observation probability of taxon") | ||
#' | ||
#' # see also | ||
#' vignette("event_data") | ||
#' # for details how to use this functionality | ||
#' } | ||
#' | ||
if (g_max <= g_min){ | ||
stop("inconsistent boundaries, inputs must be ordered.") | ||
} | ||
f = function(x){ | ||
y = rep(0, length(x)) | ||
y[x <= g_max & x >= g_min ] = 1 | ||
return(y) | ||
} | ||
return(f) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
snd_niche = function(opt, tol, prob_modifier = 1, cutoff_val = NULL){ | ||
#' | ||
#' @export | ||
#' | ||
#' @title simple niche model | ||
#' | ||
#' @param opt optimum value, gradient value where collection probability is highest | ||
#' @param tol tolerance to changes in gradient. For large values, collection probability drops off slower away from `opt` | ||
#' @param prob_modifier collection probability modifier, collection probability at `opt`. | ||
#' @param cutoff_val NULL or a number. If a number, all collection probabilities at gradient values below `cutoff_value` are set to 0. This can for example be used to model exclusively marine species when the gradient is water depth (see examples). | ||
#' | ||
#' @returns a function for usage with `apply_niche`. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' # using water depth as niche | ||
#' wd = seq(-3, 40, by = 0.5) | ||
#' f = snd_niche(opt = 10, tol = 5) | ||
#' | ||
#' plot(wd, f(wd), xlab = "Water depth", ylab = "Prob. of collection") | ||
#' # set cutoff value at to 0 to model non-terrestrial species. | ||
#' f = snd_niche(opt = 10, tol = 5, cutoff_val = 0) | ||
#' plot(wd, f(wd), xlab = "Water depth", ylab = "Prob. of collection") | ||
#' | ||
#' # see also | ||
#' vignette("event_data") | ||
#' #for examples how to use it for niche modeling | ||
#' } | ||
#' | ||
#' | ||
#' @seealso [apply_niche()] for usage of the returned function, [bounded_niche()] for another niche model | ||
#' @description | ||
#' Defines niche model based in the "Probability of collection" model by Holland and Patzkowsky (1999). | ||
#' The collection probability follows the shape of a bell curve across a gradient, where `opt` determines the peak (mean) of the bell curve, and `tol` the standard deviation. "snd" stands for "scaled normal distribution", as the collection probability has the shape of the probability density of the normal distribution. | ||
#' @references * Holland, Steven M. and Patzkowsky, Mark E. 1999. "Models for simulating the fossil record." Geology. https://doi.org/10.1130/0091-7613(1999)027%3C0491:MFSTFR%3E2.3.CO;2 | ||
|
||
fa = function(x){ | ||
f_inv = stats::dnorm(opt, opt, tol) | ||
y = pmin(prob_modifier/f_inv * stats::dnorm(x, opt, tol), rep(1, length(x))) | ||
if (!is.null(cutoff_val)){ | ||
y[x<= cutoff_val] = rep(0, length(y[x<=cutoff_val])) | ||
} | ||
return(y) | ||
} | ||
|
||
return(fa) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.