Skip to content

Commit 82cf553

Browse files
committed
Documentation updates (pkgdown, speciation methods)
1 parent 2922764 commit 82cf553

File tree

9 files changed

+103
-29
lines changed

9 files changed

+103
-29
lines changed

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ S3method(plot,SAR)
44
S3method(print,SAR)
55
export(create_SAR)
66
export(create_SpAR)
7+
export(estimate_BAMM)
78
export(estimate_DR)
89
export(estimate_MS)
910
export(find_areas)
@@ -15,7 +16,6 @@ export(get_presence_absence)
1516
export(get_sources)
1617
export(quick_create_SAR)
1718
export(remove_continents)
18-
export(speciationBAMM)
1919
import(mapdata)
2020
import(maps)
2121
importFrom(stringi,stri_unescape_unicode)

R/estimate_BAMM.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#'
33
#' Use the BAMMtools package (Rabosky et al. 2014) to extract tip speciation
44
#' rates from user-supplied BAMM analysis objects.
5+
#'
56
#' @param label_type Either "epithet" or "binomial" (default): describes the
67
#' type of tip label in the tree used for the BAMM analysis. If "epithet," only
78
#' the species epithet will be used to match speciation rates to tips in the
@@ -15,6 +16,13 @@
1516
#' `BAMMtools::getEventData()` function
1617
#' @return A dataframe that includes speciation rates for each species in the
1718
#' occurrence record dataframe
19+
#' @references
20+
#' - Rabosky, D.L. (2014). Automatic Detection of Key Innovations, Rate Shifts,
21+
#' and Diversity-Dependence on Phylogenetic Trees. PLOS ONE, 9(2): e89543.
22+
#' - Rabosky, D.L., Grundler, M., Anderson, C., Title, P., Shi, J.J.,
23+
#' Brown, J.W., Huang, H., & Larson, J.G. (2014), BAMMtools: an R package for
24+
#' the analysis of evolutionary dynamics on phylogenetic trees. Methods in
25+
#' Ecology and Evolution, 5: 701-707.
1826
#' @examples
1927
#' \dontrun{
2028
#' key <- get_key(query = "Anolis", rank = "genus")
@@ -39,7 +47,7 @@
3947
#' }
4048
#' @export
4149

42-
speciationBAMM <- function(label_type = "binomial", occurrences, edata) {
50+
estimate_BAMM <- function(label_type = "binomial", occurrences, edata) {
4351
# Checkmate input validation
4452
checkmate::assertString(label_type)
4553
checkmate::assertDataFrame(occurrences)

R/estimate_DR.R

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#' Get speciation rates using the DR statistic (Jetz et al. 2012)
22
#'
3-
#' Use methodology from Sun and Folk (2020) to calculate the DR statistic for
4-
#' each tip of a given tree and output a dataframe for use in SSARP's
5-
#' speciation-area relationship pipeline. This method also removes any species
6-
#' rows without rates (this is most likely to occur when the tree does not have
7-
#' all of the species included in the occurrence record dataframe). The tree
8-
#' read in the examples below is modified from Patton et al. (2021).
3+
#' DR stands for “diversification rate,” but it is ultimately a better
4+
#' estimation of speciation rate than net diversification (Belmaker and Jetz
5+
#' 2015; Quintero and Jetz 2018) and returns results similar to BAMM’s tip
6+
#' speciation rate estimations (Title and Rabosky 2019).
7+
#'
8+
#' This function uses methodology from Sun and Folk (2020) to calculate the DR
9+
#' statistic for each tip of a given tree and output a dataframe for use in
10+
#' SSARP's speciation-area relationship pipeline. This method also removes any
11+
#' species rows without rates (this is most likely to occur when the tree does
12+
#' not have all of the species included in the occurrence record dataframe).
13+
#' The tree read in the examples below is modified from Patton et al. (2021).
914
#' @param tree The dated phylogenetic tree that corresponds with the taxa to be
1015
#' included in a speciation-area relationship
1116
#' @param label_type Either "epithet" or "binomial" (default): describes the
@@ -20,15 +25,23 @@
2025
#' @return A dataframe that includes speciation rates for each species in the
2126
#' occurrence record dataframe
2227
#' @references
28+
#' - Belmaker, J., & Jetz, W. (2015). Relative roles of ecological and
29+
#' energetic constraints, diversification rates and region history on global
30+
#' species richness gradients. Ecology Letters, 18: 563–571.
2331
#' - Jetz, W., Thomas, G.H, Joy, J.B., Harmann, K., & Mooers, A.O. (2012). The
2432
#' global diversity of birds in space and time. Nature, 491: 444-448.
2533
#' - Patton, A.H., Harmon, L.J., del Rosario Castañeda, M.,
2634
#' Frank, H.K., Donihue, C.M., Herrel, A., & Losos, J.B. (2021). When adaptive
2735
#' radiations collide: Different evolutionary trajectories between and within
2836
#' island and mainland lizard clades. PNAS, 118(42): e2024451118.
37+
#' - Quintero, I., & Jetz, W. (2018). Global elevational diversity and
38+
#' diversification of birds. Nature, 555, 246–250.
2939
#' - Sun, M. & Folk, R.A. (2020). Cactusolo/rosid_NCOMMS-19-37964-T: Code and
3040
#' data for rosid_NCOMMS-19-37964 (Version V.1.0). Zenodo.
3141
#' http://doi.org/10.5281/zenodo.3843441
42+
#' - Title P.O. & Rabosky D.L. (2019). Tip rates, phylogenies and
43+
#' diversification: What are we estimating, and how good are the estimates?
44+
#' Methods in Ecology and Evolution. 10: 821–834.
3245
#' @examples
3346
#' # The GBIF key for the Anolis genus is 8782549
3447
#' # Obtained with: key <- get_key(query = "Anolis", rank = "genus")

R/estimate_MS.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#' there are columns titled "Genus", "Species", and "areas"
1717
#' @return A dataframe that includes speciation rates for each island in the
1818
#' user-provided occurrence record dataframe.
19-
#' #' @references
19+
#' @references
2020
#' - Magallόn, S. & Sanderson, M.J. (2001). Absolute Diversification Rates in
2121
#' Angiosperm Clades. Evolution, 55(9): 1762-1780.
2222
#' @examples

_pkgdown.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,31 @@ navbar:
1414
href: articles/Create_SAR.html
1515
- text: Create Speciation-Area Relationship
1616
href: articles/Create_SpAR.html
17+
18+
reference:
19+
- title: Prepare Occurrence Records
20+
contents:
21+
- find_land
22+
- find_areas
23+
- remove_continents
24+
25+
- title: Estimate Speciation Rates
26+
contents:
27+
- estimate_DR
28+
- estimate_MS
29+
- estimate_BAMM
30+
31+
- title: Create Relationships
32+
contents:
33+
- create_SAR
34+
- create_SpAR
35+
- quick_create_SAR
36+
37+
- title: Other Utilities
38+
contents:
39+
- get_island_areas
40+
- get_presence_absence
41+
- get_sources
42+
- plot
43+
- print
44+
Lines changed: 13 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/estimate_DR.Rd

Lines changed: 20 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/estimate_MS.Rd

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-estimate_BAMM.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,23 @@ occ_mat <- as.matrix(occ_simple)
8686

8787
test_that("Inputting a matrix instead of a dataframe for occurrence records
8888
will cause an error", {
89-
expect_error(speciationBAMM(label_type = "epithet",
89+
expect_error(estimate_BAMM(label_type = "epithet",
9090
occurrences = occ_mat, edata = edata_test))
9191
})
9292

9393
test_that("Inputting a non-string for the label type will cause an error", {
94-
expect_error(speciationBAMM(label_type = 1,
94+
expect_error(estimate_BAMM(label_type = 1,
9595
occurrences = occ_simple, edata = edata_test))
9696
})
9797

98-
test_that("The speciationBAMM function returns a dataframe (epithet labels)", {
99-
expect_s3_class(speciationBAMM(label_type = "epithet",
98+
test_that("The estimate_BAMM function returns a dataframe (epithet labels)", {
99+
expect_s3_class(estimate_BAMM(label_type = "epithet",
100100
occurrences = occ_simple,
101101
edata = edata_test), "data.frame")
102102
})
103103

104-
test_that("The speciationBAMM function returns a dataframe (binomial labels)", {
105-
expect_s3_class(speciationBAMM(label_type = "binomial",
104+
test_that("The estimate_BAMM function returns a dataframe (binomial labels)", {
105+
expect_s3_class(estimate_BAMM(label_type = "binomial",
106106
occurrences = occ_simple,
107107
edata = edata_test), "data.frame")
108108
})

0 commit comments

Comments
 (0)