Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version 2.2 #396

Merged
merged 74 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
4f20679
dev/ version
joethorley Oct 21, 2024
7934876
add missing dois
joethorley Nov 20, 2024
89fca04
upadated docs
dunkenwg Dec 2, 2024
19fb347
Merge branch 'bcgov:main' into main
joethorley Dec 3, 2024
d9b3aa0
add small-sample-bias back in
joethorley Dec 3, 2024
f2212fd
update .gitignore
joethorley Dec 3, 2024
fdd30c6
try fixing log-normal math
joethorley Dec 3, 2024
38be175
playing with log-normal dist
joethorley Dec 3, 2024
373bfed
distributions
joethorley Dec 3, 2024
edf1f21
log-normal
joethorley Dec 3, 2024
a2ec4be
merge main
joethorley Dec 5, 2024
e70d2d8
Merge pull request #392 from poissonconsulting/main
joethorley Dec 5, 2024
ba30c68
add xlimits argument to ssd_plot to set x-axis limits (passed to scal…
sebdalgarno Dec 6, 2024
92b12c7
add ssd_label_comma_hc label function to offset hc value (appending \n)
sebdalgarno Dec 7, 2024
95de5d2
add ability in plot_coord_scale to append hc value to xbreaks and off…
sebdalgarno Dec 7, 2024
3186e9b
add hc_value param for plot_coord_scale, update documentation on acce…
sebdalgarno Dec 7, 2024
2c86c6d
document
sebdalgarno Dec 7, 2024
65ad89e
add two new tests for ssd_plot with hc value
sebdalgarno Dec 7, 2024
9975017
update ssd_plot and plot_data snapshots, hc value now included + with…
sebdalgarno Dec 7, 2024
2fbbd76
add ggtext dependency
sebdalgarno Dec 7, 2024
e7fd79e
add text_size and label_size arguments, soft-deprecate size
sebdalgarno Dec 7, 2024
1c63fc5
fix example, add markdown for new line and bold label
sebdalgarno Dec 7, 2024
d92ba25
soft-deprecate size for label_size, add option to change text size, f…
sebdalgarno Dec 7, 2024
9d88dbd
document
sebdalgarno Dec 7, 2024
3f72201
add snap for label and text size, review/update snapshots with bold h…
sebdalgarno Dec 7, 2024
3503606
forgot to add checks for new xlimits arg
sebdalgarno Dec 7, 2024
da95eec
fix xlimits check to allow null
sebdalgarno Dec 7, 2024
e7315de
better documentation for ssd_label_comma_hc
sebdalgarno Dec 7, 2024
f03c89a
add ss_label_comma_hc to _pkgdown.yml index
sebdalgarno Dec 7, 2024
df9fdf6
Added fig alt text, addresses #182
Dec 9, 2024
6ae6245
Merge pull request #394 from beckyfisher/joss-paper-rf
joethorley Dec 10, 2024
757573f
Merge pull request #108 from poissonconsulting/predict_plot
joethorley Dec 10, 2024
f5a837b
Merge pull request #395 from poissonconsulting/main
joethorley Dec 10, 2024
2c5a79a
build site
joethorley Dec 10, 2024
01470fc
add pkgdown::build_reference() for checking.
joethorley Dec 10, 2024
aaa2f87
fix vignette article
joethorley Dec 10, 2024
276187c
update plot.
joethorley Dec 10, 2024
2aed846
add ecotox as alternative source of environmental toxicity data
joethorley Dec 10, 2024
94effc5
add example for scale_fill_ssd() and expand the description for discr…
joethorley Dec 10, 2024
5e294b3
update NEWS to clarify that xx refers to family of functions
joethorley Dec 10, 2024
5f44821
clarify reasons for change to TMB
joethorley Dec 10, 2024
2ea7641
clarify reasons for change to TMB
joethorley Dec 10, 2024
4f36f3d
Merge branch 'joss-paper' of github.com:bcgov/ssdtools into joss-paper
joethorley Dec 10, 2024
bf55c68
update news tmb
joethorley Dec 10, 2024
334d4b8
does not directly affect
joethorley Dec 10, 2024
9cb7603
Readded FAQ vignette
joethorley Dec 10, 2024
6825a15
add description to censor data
joethorley Dec 10, 2024
89e9a34
update paper to clarify relationship between multi_est and ci_method
joethorley Dec 10, 2024
2c06345
remove argument name without context.
joethorley Dec 10, 2024
62f7ca6
update deprecation information
joethorley Dec 10, 2024
c2c7902
fledge: Bump version to 2.2.0
joethorley Dec 10, 2024
2fadc0d
update news file
joethorley Dec 10, 2024
d534336
spelling
joethorley Dec 10, 2024
cdc2d0a
getting ready for release
joethorley Dec 10, 2024
0c56c8d
faqs fig.alt
joethorley Dec 10, 2024
1c0ae4a
update small sample bias pdf
joethorley Dec 10, 2024
7ac705c
simplify text distributions
joethorley Dec 10, 2024
c7c7988
another paper tweak
joethorley Dec 10, 2024
c24c5c8
original
joethorley Dec 10, 2024
591027d
non-parametric
joethorley Dec 10, 2024
f6047c2
ssd_label_comma_hc
joethorley Dec 10, 2024
e24cb92
update data and plot
joethorley Dec 11, 2024
daac36f
Turned off x-axis minor breaks for all plots (for consistency) as HC …
joethorley Dec 11, 2024
15a9c7b
typos
joethorley Dec 12, 2024
cb88bf0
fun to fun_ssd
joethorley Dec 12, 2024
9a94e6f
unnecessary file
joethorley Dec 12, 2024
2c9454d
theme classic
joethorley Dec 12, 2024
f62fe06
Rstudio added ProjectId to proj file.
joethorley Dec 17, 2024
1f0b3ca
added `ssd_dists_shiny()`
joethorley Dec 19, 2024
ac7c21a
add shinyssdtools to wordlist
joethorley Jan 2, 2025
63b9d9b
spelling
joethorley Jan 2, 2025
0c54cab
update description
joethorley Jan 2, 2025
2c52000
update pkgdown url
joethorley Jan 3, 2025
ffb1792
update readme
joethorley Jan 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@
^CRAN-SUBMISSION$
^CODE_OF_CONDUCT\.md$
^vignettes/articles$
^doc$
^Meta$
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
push:
branches: [main, master]
pull_request:
branches: [main, master, dev]
branches: [main, master]

name: R-CMD-check

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/paper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

on:
push:
branches: [main]
branches: [main, joss-paper]
pull_request:
branches: [main, dev]
branches: [main, joss-paper]

name: paper

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [main, master]
pull_request:
branches: [main, master, dev]
branches: [main, master]

name: test-coverage.yaml

Expand Down
13 changes: 5 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@

*.html

/docs/
/inst/docs/
/paper/paper.pdf
/scripts/boron_samples1
/scripts/checks.md
docs
inst/docs
inst/doc
/ignore
/doc/
/Meta/
scripts

/paper/paper.pdf
12 changes: 7 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ssdtools
Title: Species Sensitivity Distributions
Version: 2.1.0.9001
Version: 2.2.0
Authors@R: c(
person("Joe", "Thorley", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-7683-4592")),
Expand All @@ -11,22 +11,24 @@ Authors@R: c(
person("Seb", "Dalgarno", , "[email protected]", role = "ctb",
comment = c(ORCID = "0000-0002-3658-4517")),
person("Kathleen", "McTavish", role = "ctb"),
person("Heather", "Thompson", role = "ctb"),
person("Heather", "Thompson", role = "ctb"),
person("Doug", "Spry", role = "ctb"),
person("Rick", "van Dam", role = "ctb"),
person("Graham", "Batley", role = "ctb"),
person("Tony", "Bigwood", role = "ctb"),
person("Ali", "Azizishirazi", role = "ctb"),
person("Nadine", "Hussein", , "[email protected]", role = "ctb",
comment = c(ORCID = "0000-0003-4470-8361")),
person("Sarah", "Lyons", , "[email protected]", role = "ctb",
comment = c(ORCID = "0000-0002-6745-6796")),
person("Duncan", "Kennedy", , "[email protected]", role = "ctb",
comment = c(ORCID = "0009-0001-4880-5751")),
person("Stephanie", "Hazlitt", role = "ctb"),
person("Hadley", "Wickham", role = "ctb"),
person("Sergio", "Ibarra Espinosa", role = "ctb"),
person("Andy", "Teucher", role = "ctb"),
person("Emilie", "Doussantousse", role = "ctb"),
person("Nan-Hung", "Hsieh", role = "ctb"),
person("Florencia", "D'Andrea", role = "ctb"),
person("Province of British Columbia", role = c("fnd", "cph")),
person("Environment and Climate Change Canada", role = c("fnd", "cph")),
person("Australian Government Department of Climate Change, Energy, the Environment and Water", role = c("fnd", "cph"))
Expand All @@ -38,8 +40,7 @@ Description: Species sensitivity distributions are cumulative probability
fit distributions such as the gamma, log-logistic, log-normal and
log-normal log-normal mixture. Multiple distributions can be averaged
using Akaike Information Criteria. Confidence intervals on hazard
concentrations and proportions are produced by parametric
bootstrapping.
concentrations and proportions are produced by bootstrapping.
License: Apache License (== 2.0) | file LICENSE
URL: https://github.com/bcgov/ssdtools, https://bcgov.github.io/ssdtools/
BugReports: https://github.com/bcgov/ssdtools/issues
Expand All @@ -51,6 +52,7 @@ Imports:
furrr,
generics,
ggplot2,
ggtext,
glue,
goftest,
graphics,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export(ssd_data)
export(ssd_dists)
export(ssd_dists_all)
export(ssd_dists_bcanz)
export(ssd_dists_shiny)
export(ssd_eburrIII3)
export(ssd_ecd)
export(ssd_ecd_data)
Expand All @@ -100,6 +101,7 @@ export(ssd_hp)
export(ssd_hp_bcanz)
export(ssd_is_censored)
export(ssd_label_comma)
export(ssd_label_comma_hc)
export(ssd_licensing_md)
export(ssd_match_moments)
export(ssd_min_pmix)
Expand Down
34 changes: 19 additions & 15 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<!-- NEWS.md is maintained by https://fledge.cynkra.com, contributors should not edit this file -->

# ssdtools 2.1.0.9001

- Fixed equation rendering for vignettes on website.
- Corrected y-axis labels for bimodal plots in distributions vignette from Cumulative Probability to Probability Density.


# ssdtools 2.1.0.9000

- Same as previous version.

# ssdtools 2.2.0

- Added `ssd_label_comma_hc()` function to label numbers with significant digits and comma and offset hazard concentration value if present in breaks.
- Added `ssd_dists_shiny()` to define distributions for use in shiny app.
- For `plot_coord_scale()` function:
- Added `x_limits = NULL` to allow setting of x-axis limits.
- Added `hc_value = NULL` to pass hazard concentration value.
- Restricted `trans` argument to `"identity"`, `"log10"` or "`log`".
- For `ssd_plot()` function:
- Added `text_size` argument.
- Added `theme_classic = FALSE` argument to switch classic theme.
- Soft-deprecated `size` argument for `label_size`.
- Turned off x-axis minor breaks for all plots (for consistency) as HC major break causing multiple minor breaks in `ssd_plot()`.

# ssdtools 2.1.0

- Added `ssd_xxmulti_fitdists()` functions to accept object of class `fitdists`.
- Set `ssd_xxmulti(..., lnorm.weight = 0)` (instead of 1) to avoid incorrect values with `do.call("ssd_xxmulti", c(..., estimates(fits))` if `fits` does not include the log-normal distribution.
- Added `ssd_xxmulti_fitdists()` family of functions (`ssd_rmulti_fitdists()`, `ssd_pmulti_fitdists()` and `ssd_qmulti_fitdists()`) to accept object of class `fitdists`.
- Set `lnorm.weight = 1` instead of `1` in the `ssd_xxmulti()` family of functions (`ssd_rmulti()`, `ssd_pmulti()` and `ssd_qmulti`) to avoid incorrect values with `do.call("ssd_xxmulti", c(..., estimates(fits))` if `fits` does not include the log-normal distribution.


# ssdtools 2.0.0
Expand Down Expand Up @@ -69,7 +72,7 @@ The following functions and arguments were also added:

- `ssd_hp_bcanz()` and `ssd_hp.fitburrlioz()` to get hazard proportions.
- `ssd_pmulti()`, `ssd_qmulti()` and `ssd_rmulti()` for combined mixture distributions.
- `ssd_exx()` functions to get default parameter estimates for distributions.
- `ssd_exx()` family of functions (i.e. `ssd_elnorm()`, `ssd_egamma()` etc) to get default parameter estimates for distributions.
- `ssd_censor_data()` to censor data.
- `npars = c(2L, 5L)` argument to `ssd_dists_bcanz()` to specify the number of parameters.
- `dists = ssd_dists_bcanz()` to `ssd_fit_bcanz()` to allow other packages to modify.
Expand Down Expand Up @@ -155,7 +158,8 @@ ssdtools version 1.0.0 is the first major release of `ssdtools` with some import

## Fitting

An important change to the functionality of `ssd_fit_dists()` was to switch from model fitting using [`fitdistrplus`](https://github.com/lbbe-software/fitdistrplus) to [`TMB`](https://github.com/kaskr/adcomp) which has resulted in improved handling of censored data.
An important change to the functionality of `ssd_fit_dists()` was to switch from model fitting using [`fitdistrplus`](https://github.com/lbbe-software/fitdistrplus) to [`TMB`](https://github.com/kaskr/adcomp) to allow full control over model specification as well as improved handling of censored data.
The change is internal and does not directly affect the user interface.
Although it was hoped that model fitting would be faster this is currently not the case.

As a result of the change the `fitdists` objects returned by `ssd_fit_dists()` from previous versions of `ssdtools` are not compatible with the major release and should be regenerated.
Expand Down Expand Up @@ -251,7 +255,7 @@ The function `ssd_fit_burrlioz()` was added to approximate the behaviour of [Bur
Hazard concentration estimation is performed by `ssd_hc()` (which is wrapped by `predict()`) and hazard protection estimation by `ssd_hp()`.
By default confidence intervals are estimated by parametric bootstrapping.

To reduce the time required for bootstrapping, parallelization was implemented using the [future](https://github.com/HenrikBengtsson/future) package.
To reduce the time required for bootstrapping, parallelization was implemented using the [future](https://github.com/futureverse/future) package.

The following arguments were added to `ssd_hc()` and `ssd_hp()`

Expand Down
8 changes: 2 additions & 6 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

dgompertz_ssd <- function(x, location, shape) {
.Call(`_ssdtools_dgompertz_ssd`, x, location, shape)
}

dgumbel_ssd <- function(x, location, scale) {
.Call(`_ssdtools_dgumbel_ssd`, x, location, scale)
fun_ssd <- function(x) {
.Call(`_ssdtools_fun_ssd`, x)
}

14 changes: 10 additions & 4 deletions R/censor.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
# limitations under the License.

#' Censor Data
#'
#' Censors data to a specified range based on the `censoring` argument.
#' The function is useful for creating test data sets.
#'
#' @inheritParams params
#'
Expand All @@ -27,6 +30,10 @@
ssd_censor_data <- function(data, left = "Conc", ..., right = left, censoring = c(0, Inf)) {
.chk_data(data, left, right)
chk_unused(...)
chk_numeric(censoring)
chk_vector(censoring)
chk_length(censoring, 2L)
chk_not_any_na(censoring)

if (left == right) {
right <- "right"
Expand Down Expand Up @@ -63,11 +70,10 @@ censor_data <- function(data, censoring) {
if (!.is_censored(censoring)) {
return(data)
}
chk_not_any_na(censoring)

data$right[data$left < censoring[1]] <- censoring[1]

data$right[data$left < censoring[1]] <- min(censoring)
data$left[data$left < censoring[1]] <- 0
data$left[data$right > censoring[2]] <- censoring[2]
data$left[data$right > censoring[2]] <- max(censoring)
data$right[data$right > censoring[2]] <- Inf
data
}
Expand Down
2 changes: 0 additions & 2 deletions R/censored.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,4 @@ ssd_is_censored.fitdists <- function(x, ...) {
#' @seealso [`ssd_is_censored()`]
is_censored <- function(x) {
lifecycle::deprecate_stop("0.3.7", "is_censored()", "ssd_is_censored()")
chk_s3_class(x, "fitdists")
ssd_is_censored(x)
}
30 changes: 0 additions & 30 deletions R/d.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,3 @@ any_missing <- function(...) {
x <- unlist(list(...))
any(is.na(x) & !is.nan(x))
}

.ddist <- function(dist, x, ..., log) {
inf <- !is.na(x) & is.infinite(x)
x[inf] <- NA_real_
fun <- paste0("d", dist, "_ssd")
d <- mapply(fun, x, ...)
d[mapply(any_missing, x, ...)] <- NA_real_
d[inf] <- -Inf
if (!log) d <- exp(d)
d
}

ddist <- function(dist, x, ..., log = FALSE, .lgt = FALSE) {
if (!length(x)) {
return(numeric(0))
}

if (!.lgt) {
return(.ddist(dist, x = x, ..., log = log))
}

lte <- !is.na(x) & x <= 0
x[lte] <- NA_real_
d <- .ddist(dist, x = log(x), ..., log = FALSE) / x
d[lte] <- 0
if (log) {
return(log(d))
}
d
}
2 changes: 1 addition & 1 deletion R/devtools-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ release_questions <- function() {
c(
"Have you run `data-raw/data-raw.R`?",
"Have you tested using `ssdtests` package?",
"Have you updated `small-sample-bias.pdf`?",
"Have you run `vignettestatic/small-sample-bias.Rmd`?",
"Have you confirmed all images in .Rmd files have alternative text defined using the `fig.alt` argument?",
"Have you confirmed updated Apache 2.0 license at the top of all code files?",
"Have you confirmed update Creative Commons license for all non-code files?"
Expand Down
15 changes: 15 additions & 0 deletions R/dists.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,18 @@ ssd_dists <- function(bcanz = NULL, tails = NULL, npars = 2:5) {
ssd_dists_all <- function() {
ssd_dists(bcanz = NULL, tails = NULL, npars = 2:5)
}

#' All Shiny Species Sensitivity Distributions
#'
#' Gets a character vector of the names of all the available distributions
#' in the shinyssdtools.
#'
#' @return A unique, sorted character vector of the distributions.
#' @family dists
#' @export
#'
#' @examples
#' ssd_dists_shiny()
ssd_dists_shiny <- function() {
ssd_dists(bcanz = NULL, tails = TRUE, npars = 2:5)
}
33 changes: 10 additions & 23 deletions R/ggplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ ssd_pal <- function() {
}

#' Discrete color-blind scale for SSD Plots
#'
#' The functions were designed for coloring different groups in a plot of SSD data.
#'
#' @param ... Arguments passed to [ggplot2::discrete_scale()].
#' @family ggplot
#' @export
#' @examples
#' # Use the color-blind palette for a SSD plot
#' ssd_plot(ssddata::ccme_boron, boron_pred, shape = "Group", color = "Group") +
#' scale_colour_ssd()
scale_colour_ssd <- function(...) {
Expand All @@ -52,6 +55,12 @@ scale_color_ssd <- function(...) {

#' @describeIn scale_colour_ssd Discrete color-blind scale for SSD Plots
#' @export
#' @examples
#' # Use the color-blind palette for a histogram of concentrations
#' ggplot2::ggplot(ssddata::ccme_boron, ggplot2::aes(x = Species, y = Conc, fill = Group)) +
#' ggplot2::geom_col() +
#' scale_fill_ssd() +
#' ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90, vjust = 0.5, hjust = 1))
scale_fill_ssd <- function(...) {
discrete_scale("fill", palette = ssd_pal(), ...)
}
Expand Down Expand Up @@ -192,16 +201,11 @@ geom_xribbon <- function(mapping = NULL,
#' Species Sensitivity Data Points
#' `r lifecycle::badge('deprecated')`
#'
#' `geom_ssd()` has been deprecated for `geom_ssdpoint()`.
#' Deprecated for `geom_ssdpoint()`.
#'
#' @inheritParams ggplot2::layer
#' @inheritParams ggplot2::geom_point
#' @export
#' @examples
#' \dontrun{
#' ggplot2::ggplot(ssddata::ccme_boron, ggplot2::aes(x = Conc)) +
#' geom_ssd()
#' }
geom_ssd <- function(mapping = NULL,
data = NULL,
stat = "ssdpoint",
Expand All @@ -211,12 +215,6 @@ geom_ssd <- function(mapping = NULL,
show.legend = NA,
inherit.aes = TRUE) {
lifecycle::deprecate_stop("0.3.5", "geom_ssd()", "geom_ssdpoint()")

geom_ssdpoint(
mapping = mapping, data = data, stat = stat,
position = position, na.rm = na.rm, show.legend = show.legend,
inherit.aes = inherit.aes, ...
)
}

#' Plot Species Sensitivity Data
Expand All @@ -229,11 +227,6 @@ geom_ssd <- function(mapping = NULL,
#' @seealso [`geom_ssdpoint()`]
#' @family ggplot2
#' @export
#' @examples
#' \dontrun{
#' ggplot2::ggplot(ssddata::ccme_boron, ggplot2::aes(x = Conc)) +
#' stat_ssd()
#' }
stat_ssd <- function(mapping = NULL,
data = NULL,
geom = "point",
Expand All @@ -243,10 +236,4 @@ stat_ssd <- function(mapping = NULL,
show.legend = NA,
inherit.aes = TRUE) {
lifecycle::deprecate_stop("0.3.5", "stat_ssd()")

layer(
stat = StatSsdpoint, data = data, mapping = mapping, geom = geom,
position = position, show.legend = show.legend, inherit.aes = inherit.aes,
params = list(na.rm = na.rm, ...)
)
}
Loading
Loading