Skip to content

Commit e9ae067

Browse files
committed
Functions that included mixed case are now all lower-case
1 parent 6afd3fd commit e9ae067

28 files changed

+132
-572
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ See tidyverse's guide on [how to create a great issue](https://code-review.tidyv
3131

3232
* Please do not restyle code that has nothing to do with your PR.
3333

34-
* New code should follow the tidyverse [style guide](https://style.tidyverse.org), with one exception: please use camelCase for new function names, or create an alias so that both snake_case and camelCase work for the function call.
34+
* New code should follow the tidyverse [style guide](https://style.tidyverse.org).
3535

3636
* We use [roxygen2](https://cran.r-project.org/package=roxygen2), with [Markdown syntax](https://cran.r-project.org/web/packages/roxygen2/vignettes/rd-formatting.html), for documentation.
3737

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Title: ssarp (Species-/Speciation-Area Relationship Projector)
44
Description: Create Species- and Speciation-Area Relationships for any taxa.
55
Authors@R: person("Kristen", "Martinet", email = "kmartinet@outlook.com", role = c("aut", "cre"))
66
Maintainer: Kristen Martinet <kmartinet@outlook.com>
7-
Version: 0.4.1
7+
Version: 0.5.0
88
URL: https://github.com/kmartinet/ssarp, https://kmartinet.github.io/ssarp/
99
BugReports: https://github.com/kmartinet/ssarp/issues
1010
Imports:

NAMESPACE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ S3method(plot,SAR)
44
S3method(print,SAR)
55
export(create_SAR)
66
export(create_SpAR)
7+
export(create_sar)
8+
export(create_spar)
79
export(estimate_BAMM)
810
export(estimate_DR)
911
export(estimate_MS)
12+
export(estimate_bamm)
13+
export(estimate_dr)
14+
export(estimate_ms)
1015
export(find_areas)
1116
export(find_land)
1217
export(find_pam_areas)

NEWS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
ssarp 0.5.0 (2025-09-16)
2+
=========================
3+
4+
### NEW FEATURES
5+
6+
* The default versions of `create_SAR()`, `create_SpAR()`, `estimate_BAMM()`, `estimate_DR()`, and `estimate_MS()` are now all-lowercase (`create_sar()`, `create_spar()`, `estimate_bamm()`, `estimate_dr()`, and `estimate_ms()`). The original spellings have been added as aliases to the functions (both spellings may be used).
7+
18
ssarp 0.4.1 (2025-09-11)
29
=========================
310

R/create_SAR.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' of species)
66
#'
77
#' If the user would prefer to create their own plot of the
8-
#' `ssarp::create_SAR()` output, the `aggDF` element of the returned list
8+
#' `ssarp::create_sar()` output, the `aggDF` element of the returned list
99
#' includes the raw points from the plot created here. They can be accessed
1010
#' as demonstrated in the Examples section.
1111
#' @param occurrences The dataframe output by `ssarp::find_areas()` (or if
@@ -35,7 +35,7 @@
3535
#' land <- find_land(occurrences = dat)
3636
#' areas <- find_areas(occs = land)
3737
#'
38-
#' seg <- create_SAR(occurrences = areas,
38+
#' seg <- create_sar(occurrences = areas,
3939
#' npsi = 1,
4040
#' visualize = FALSE)
4141
#' plot(seg)
@@ -44,7 +44,7 @@
4444
#' points <- seg$aggDF
4545
#' @export
4646

47-
create_SAR <- function(occurrences, npsi = 1, visualize = FALSE) {
47+
create_sar <- function(occurrences, npsi = 1, visualize = FALSE) {
4848
# Checkmate input validation
4949
checkmate::assertDataFrame(occurrences)
5050
checkmate::assertNumeric(npsi)
@@ -225,3 +225,8 @@ create_SAR <- function(occurrences, npsi = 1, visualize = FALSE) {
225225
return(result)
226226
}
227227
}
228+
229+
# Create alias for create_sar
230+
#' @rdname create_sar
231+
#' @export
232+
create_SAR <- create_sar

R/create_SpAR.R

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
#' log(speciation rate)
66
#'
77
#' If the user would prefer to create their own plot of the
8-
#' `ssarp::create_SpAR()` output, the `aggDF` element of the returned list
8+
#' `ssarp::create_spar()` output, the `aggDF` element of the returned list
99
#' includes the raw points from the plot created here. They can be accessed
1010
#' as demonstrated in the Examples section.
1111
#'
1212
#' More information about the three methods for estimating speciation rate
1313
#' included in `ssarp` can be found in [ssarp's SpAR vignette](https://kmartinet.github.io/ssarp/articles/Create_SpAR.html).
1414
#' @param occurrences The dataframe output by one of ssarp's speciation
15-
#' methods (`ssarp::estimate_BAMM()`, `ssarp::estimate_DR()`,
16-
#' `ssarp::estimate_MS()`), or if using a custom dataframe, ensure that it
15+
#' methods (`ssarp::estimate_bamm()`, `ssarp::estimate_dr()`,
16+
#' `ssarp::estimate_ms()`), or if using a custom dataframe, ensure that it
1717
#' has the following columns: areas, rate
1818
#' @param npsi The maximum number of breakpoints to estimate for model
1919
#' selection. Default: 1
@@ -44,11 +44,11 @@
4444
#' "Patton_Anolis_trimmed.tree",
4545
#' package = "ssarp"))
4646
#'
47-
#' occ_speciation <- estimate_MS(tree = tree,
47+
#' occ_speciation <- estimate_ms(tree = tree,
4848
#' label_type = "epithet",
4949
#' occurrences = areas)
5050
#'
51-
#' seg <- create_SpAR(occurrences = occ_speciation,
51+
#' seg <- create_spar(occurrences = occ_speciation,
5252
#' npsi = 1,
5353
#' visualize = FALSE)
5454
#' plot(seg)
@@ -57,7 +57,7 @@
5757
#' points <- seg$aggDF
5858
#' @export
5959

60-
create_SpAR <- function(occurrences, npsi = 1, visualize = FALSE) {
60+
create_spar <- function(occurrences, npsi = 1, visualize = FALSE) {
6161
# Checkmate input validation
6262
checkmate::assertDataFrame(occurrences)
6363
checkmate::assertNumeric(npsi)
@@ -247,3 +247,8 @@ create_SpAR <- function(occurrences, npsi = 1, visualize = FALSE) {
247247
return(result)
248248
}
249249
}
250+
251+
# Create alias for create_spar
252+
#' @rdname create_spar
253+
#' @export
254+
create_SpAR <- create_spar

R/estimate_BAMM.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@
4747
#'
4848
#' edata <- BAMMtools::getEventData(phy = tree, eventdata = event_data)
4949
#'
50-
#' occ_speciation <- estimate_BAMM(label_type = "epithet",
50+
#' occ_speciation <- estimate_bamm(label_type = "epithet",
5151
#' occurrences = areas ,
5252
#' edata = edata)
5353
#' @export
5454

55-
estimate_BAMM <- function(label_type = "binomial", occurrences, edata) {
55+
estimate_bamm <- function(label_type = "binomial", occurrences, edata) {
5656
# Checkmate input validation
5757
checkmate::assertString(label_type)
5858
checkmate::assertDataFrame(occurrences)
@@ -111,3 +111,8 @@ estimate_BAMM <- function(label_type = "binomial", occurrences, edata) {
111111

112112
return(occurrences)
113113
}
114+
115+
# Create alias for estimate_bamm
116+
#' @rdname estimate_bamm
117+
#' @export
118+
estimate_BAMM <- estimate_bamm

R/estimate_DR.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@
5959
#' "Patton_Anolis_trimmed.tree",
6060
#' package = "ssarp"))
6161
#'
62-
#' occ_speciation <- estimate_DR(tree = tree,
62+
#' occ_speciation <- estimate_dr(tree = tree,
6363
#' label_type = "epithet",
6464
#' occurrences = areas)
6565
#'
6666
#' @export
6767

68-
estimate_DR <- function(tree, label_type = "binomial", occurrences) {
68+
estimate_dr <- function(tree, label_type = "binomial", occurrences) {
6969
# Checkmate input validation
7070
checkmate::assertString(label_type)
7171
checkmate::assertDataFrame(occurrences)
@@ -136,3 +136,8 @@ estimate_DR <- function(tree, label_type = "binomial", occurrences) {
136136

137137
return(sp_occ)
138138
}
139+
140+
# Create alias for estimate_dr
141+
#' @rdname estimate_dr
142+
#' @export
143+
estimate_DR <- estimate_dr

R/estimate_MS.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
#' "Patton_Anolis_trimmed.tree",
3737
#' package = "ssarp"))
3838
#'
39-
#' occ_speciation <- estimate_MS(tree = tree,
39+
#' occ_speciation <- estimate_ms(tree = tree,
4040
#' label_type = "epithet",
4141
#' occurrences = areas)
4242
#'
4343
#' @export
4444

45-
estimate_MS <- function(tree, label_type = "binomial", occurrences) {
45+
estimate_ms <- function(tree, label_type = "binomial", occurrences) {
4646
# Checkmate input validation
4747
checkmate::assertString(label_type)
4848
checkmate::assertDataFrame(occurrences)
@@ -160,3 +160,7 @@ estimate_MS <- function(tree, label_type = "binomial", occurrences) {
160160
return(final_df)
161161
}
162162

163+
# Create alias for estimate_ms
164+
#' @rdname estimate_ms
165+
#' @export
166+
estimate_MS <- estimate_ms

README.Rmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ The "area_dat" dataframe includes records with GPS points that are associated wi
176176

177177
#### Step 4: Create the species-area relationship
178178

179-
Finally, we will generate the SAR using the `ssarp::create_SAR()` function. The `ssarp::create_SAR()` function creates multiple regression objects with breakpoints up to the user-specified “npsi” parameter. For example, if “npsi” is two, `ssarp::create_SAR()` will generate regression objects with zero (linear regression), one, and two breakpoints. The function will then return the regression object with the lowest AIC score. The “npsi” parameter will be set to one in this example. Note that if linear regression (zero breakpoints) is better-supported than segmented regression with one breakpoint, the linear regression will be returned instead.
179+
Finally, we will generate the SAR using the `ssarp::create_sar()` function. The `ssarp::create_sar()` function creates multiple regression objects with breakpoints up to the user-specified “npsi” parameter. For example, if “npsi” is two, `ssarp::create_sar()` will generate regression objects with zero (linear regression), one, and two breakpoints. The function will then return the regression object with the lowest AIC score. The “npsi” parameter will be set to one in this example. Note that if linear regression (zero breakpoints) is better-supported than segmented regression with one breakpoint, the linear regression will be returned instead.
180180

181181
```{r}
182182
183-
create_SAR(occurrences = area_dat, npsi = 1, visualize = TRUE)
183+
create_sar(occurrences = area_dat, npsi = 1, visualize = TRUE)
184184
185185
```
186186
This is the species-area relationship (SAR) for Anolis including island-based occurrences within a polygon around Caribbean islands from the first 10,000 records for the genus in GBIF! The best-fit model was a segmented regression with one breakpoint. The R console will also output statistical information about the model.
@@ -194,15 +194,15 @@ Species-area relationships (SARs) and speciation-area relationships (SpARs) are
194194
1. Use `rgbif` to gather occurrence records, or input your own dataframe of occurrence records.
195195
2. Use `find_land()` with the dataframe obtained in Step 1 to figure out the names of landmasses using the occurrence record GPS points and the [*maps* R package](https://cran.r-project.org/web/packages/maps/index.html). Setting the `fillgaps` parameter to `TRUE` will enable the use of [Photon API](https://photon.komoot.io/) to fill in any missing landmass names left by the *maps* R package.
196196
3. Use `find_areas()` with the dataframe obtained in Step 2 to match the landmass names to a dataset that includes names of most islands on the planet and their areas. If the user would like to use a custom island area dataset instead of the built-in one, the `area_custom` parameter can be set to the name of the custom island area dataframe. If you'd like to only include occurrence records from islands, you can remove continental records by using `remove_continents()` with the dataframe returned by `find_areas()`
197-
4. Use `create_SAR()` with the dataframe obtained in Step 3 to create a species-area relationship plot that reports information important to the associated regression. The `npsi` parameter indicates the maximum number of breakpoints the user would like to compare for model selection. The returned model and plot correspond with the best-fit model.
197+
4. Use `create_sar()` with the dataframe obtained in Step 3 to create a species-area relationship plot that reports information important to the associated regression. The `npsi` parameter indicates the maximum number of breakpoints the user would like to compare for model selection. The returned model and plot correspond with the best-fit model.
198198

199199
### Workflow summary for using data from GBIF and a user-provided phylogenetic tree to create a speciation-area relationship plot
200200

201201
1. Use `rgbif` to gather occurrence records, or input your own dataframe of occurrence records.
202202
2. Use `find_land()` with the dataframe obtained in Step 1 to figure out the names of landmasses using the occurrence record GPS points and the [*maps* R package](https://cran.r-project.org/web/packages/maps/index.html). Setting the `fillgaps` parameter to `TRUE` will enable the use of [Photon API](https://photon.komoot.io/) to fill in any missing landmass names left by the *maps* R package.
203203
3. Use `find_areas()` with the dataframe obtained in Step 2 to match the landmass names to a dataset that includes names of most islands on the planet and their areas. If the user would like to use a custom island area dataset instead of the built-in one, the `area_custom` parameter can be set to the name of the custom island area dataframe. If you'd like to only include occurrence records from islands, you can remove continental records by using `remove_continents()` with the dataframe returned by `find_areas()`
204-
4. Use either `estimate_DR()` or `estimate_MS()` with your own phylogenetic tree that corresponds with the taxa signified in previous steps, a classifier that describes your tip labels (whether the tip labels are simply species epithets or full scientific names), and the dataframe obtained in Step 3 to add tip speciation rates using the DR statistic (Jetz et al. 2012) or the lambda calculation for crown groups from Magallόn and Sanderson (2001) respectively to the occurrence dataframe. The user may also choose to estimate tip speciation rates from a BAMM analysis (Rabosky 2014) by using `estimate_BAMM()` with a classifier that describes your tip labels (whether the tip labels are simply species epithets or full scientific names), the occurrence record dataframe obtained in Step 3, and a `bammdata` object generated by reading the event data file from a BAMM analysis with the *BAMMtools* package (Rabosky et al. 2014).
205-
5. Use `create_SpAR(occ, npsi)` with the dataframe obtained in Step 4 to create a speciation-area relationship plot that reports information important to the associated regression. The `npsi` parameter indicates the maximum number of breakpoints the user would like to compare for model selection. The returned model and plot correspond with the best-fit model.
204+
4. Use either `estimate_dr()` or `estimate_ms()` with your own phylogenetic tree that corresponds with the taxa signified in previous steps, a classifier that describes your tip labels (whether the tip labels are simply species epithets or full scientific names), and the dataframe obtained in Step 3 to add tip speciation rates using the DR statistic (Jetz et al. 2012) or the lambda calculation for crown groups from Magallόn and Sanderson (2001) respectively to the occurrence dataframe. The user may also choose to estimate tip speciation rates from a BAMM analysis (Rabosky 2014) by using `estimate_bamm()` with a classifier that describes your tip labels (whether the tip labels are simply species epithets or full scientific names), the occurrence record dataframe obtained in Step 3, and a `bammdata` object generated by reading the event data file from a BAMM analysis with the *BAMMtools* package (Rabosky et al. 2014).
205+
5. Use `create_spar(occ, npsi)` with the dataframe obtained in Step 4 to create a speciation-area relationship plot that reports information important to the associated regression. The `npsi` parameter indicates the maximum number of breakpoints the user would like to compare for model selection. The returned model and plot correspond with the best-fit model.
206206

207207
### Some helpful notes about well-known text (WKT) representation of geometry
208208
When using `rgbif::occ_search` to gather occurrence records from GBIF, the user can specify a well-known text (WKT) representation of geometry to restrict the geographic location of the returned occurrence records. The `rgbif::occ_search` function requires a counter-clockwise winding order for WKT. I find it helpful to think about WKT polygons in this way: imagine a square around your geographic area of interest and pick one of the corners as a starting point. The order of points in WKT format should follow counter-clockwise from the corner you picked first, and the final entry in the WKT string needs to be the same as the first entry. Additionally, while GPS points are typically represented in "latitude, longitude" format, WKT expects them in "longitude latitude" format with commas separating the points rather than individual longitude and latitude values. WKT polygons can have more specified points than included in this simple square example, and even include polygons nested within others or polygons with holes in the middle.

0 commit comments

Comments
 (0)