Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# admiralneuro (development version)

## Updates of Existing Functions

- Improved test coverage in `compute_centiloid()` function when invalid tracer combination is provided. The
function also now only accepts positive SUVR values. (#106)
Comment thread
jwang-lilly marked this conversation as resolved.

## New features

- The function `compute_upsit_percentile()` calculates percentiles based on age, sex, and UPSIT scores. (# 95)
Expand All @@ -15,6 +20,7 @@
## Various

- Moved test SDTM datasets `dm_neuro`, `nv_neuro`, `suppnv_neuro` and `ag_neuro` from `{admiralneuro}` to `{pharmaversesdtm}`. (#92)

- Updated the kapa.ai `data-modal-search-placeholder` to "Ask me a question about {admiralneuro} or the {admiral} ecosystem..." (#119)

# admiralneuro 0.1.0
Expand Down
13 changes: 11 additions & 2 deletions R/compute_centiloid.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#'
#' @param suvr SUVR value
#'
#' A numeric value is expected.
#' A positive numeric value is expected.
#'
#' @permitted [num_scalar]
#'
Expand Down Expand Up @@ -136,6 +136,15 @@ compute_centiloid <- function(
custom_slope = NULL,
custom_intercept = NULL
) {
if (any(suvr <= 0, na.rm = TRUE)) {
cli::cli_abort(
paste(
"{.arg suvr} must be a positive numeric value.",
"Found non-positive values: {.val {suvr[suvr <= 0]}}."
)
)
}

# Check custom_slope and custom_intercept
has_custom_slope <- !is.null(custom_slope)
has_custom_intercept <- !is.null(custom_intercept)
Expand All @@ -150,7 +159,7 @@ compute_centiloid <- function(
if (use_custom_params) {
assert_numeric_vector(custom_slope, length = 1)
assert_numeric_vector(custom_intercept, length = 1)
assert_numeric_vector(suvr, length = 1)
assert_numeric_vector(suvr)

# Use custom parameters
slope <- custom_slope
Expand Down
2 changes: 1 addition & 1 deletion man/compute_centiloid.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions tests/testthat/_snaps/compute_centiloid.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,18 @@

Argument `custom_intercept` must be a numeric vector, but it is a string.

# Test 15 compute_centiloid() throws the expected error message when non-valid combination for conversion formula is used

No standard conversion formula available for:
* tracer = "18F-Florbetapir"
* pipeline = "AVID FBB SUVR PIPELINE"
* ref_region = "Whole Cerebellum"

# Test 16 compute_centiloid throws error for non-positive SUVR values

`suvr` must be a positive numeric value. Found non-positive values: 0.

---

`suvr` must be a positive numeric value. Found non-positive values: -1.5.

33 changes: 33 additions & 0 deletions tests/testthat/test-compute_centiloid.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,36 @@ test_that("Test 14: Custom parameters non numeric inputs trigger error", {
)
)
})

test_that("Test 15 compute_centiloid() throws the expected error message when non-valid combination for conversion formula is used", { # nolint
expect_snapshot_error(
compute_centiloid(
tracer = "18F-Florbetapir",
pipeline = "AVID FBB SUVR PIPELINE",
ref_region = "Whole Cerebellum",
suvr = 1.25
)
)
})

test_that("Test 16 compute_centiloid throws error for non-positive SUVR values", {
# Test with zero
expect_snapshot_error(
compute_centiloid(
tracer = "18F-Florbetapir",
pipeline = "AVID FBP SUVR PIPELINE",
ref_region = "Whole Cerebellum",
suvr = 0
)
)

# Test with negative value
expect_snapshot_error(
compute_centiloid(
tracer = "18F-Florbetapir",
pipeline = "AVID FBP SUVR PIPELINE",
ref_region = "Whole Cerebellum",
suvr = -1.5
)
)
})