Skip to content

Commit

Permalink
Merge pull request #13 from ahgroup/dev
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
wzbillings authored Nov 15, 2024
2 parents 2fb437e + b8d8f66 commit 29c7fcc
Show file tree
Hide file tree
Showing 13 changed files with 220 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ URL: https://github.com/ahgroup/hgp
BugReports: https://github.com/ahgroup/hgp/issues
Depends:
R (>= 2.10)
Suggests:
Suggests:
dplyr,
forcats,
ggplot2,
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Generated by roxygen2: do not edit by hand

export(format_hai_data)
export(hai_to_log_scale)
export(hai_to_natural_scale)
export(hai_trans)
export(replace_strain_names)
export(theme_ms)
19 changes: 14 additions & 5 deletions R/HAI-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ hai_trans <- function(x, dir = c("log", "natural")) {
} else if (startsWith(tolower(dir)) == "n") {
return(hai_to_natural_scale(x))
} else {
rlang::abort("'dir' should be either 'log' or 'natural'.")
stop("'dir' should be either 'log' or 'natural'.")
}
}

Expand Down Expand Up @@ -85,7 +85,7 @@ format_hai_data <- function(data, post_titer, pre_titer = NULL,
log_out = log_scale) {
# If post_titer is named "y" we'll get a conflict!
if (isTRUE(post_titer == "y")) {
rlang::abort(paste0(
stop(paste0(
"If the post_titer argument is set to 'y' you'll get a ",
"column named conflict with the brms format!"
))
Expand All @@ -99,7 +99,7 @@ format_hai_data <- function(data, post_titer, pre_titer = NULL,
post <- data[[post_titer]]
log_post <- log2(post / 5)
} else {
rlang::abort("'log scale' argument should be TRUE or FALSE.")
stop("'log scale' argument should be TRUE or FALSE.")
}

# Now deal with the pretiter -- everything is the same, but we need to check
Expand Down Expand Up @@ -155,6 +155,9 @@ format_hai_data <- function(data, post_titer, pre_titer = NULL,
#' @return formatted post-titer values.
#'
format_posttiter <- function(log_post, log_out) {
# Fix "no visible binding" R CMD CHK note
lwr <- upr <- y <- y2 <- NULL

# Construct the base table of censoring limits
out <- tibble::tibble(
lwr = log_post,
Expand Down Expand Up @@ -190,7 +193,9 @@ format_posttiter <- function(log_post, log_out) {
#' @param y Vector of log-scale post-vacciation titer values
#' @param x Vector of log-scale pre-vaccination titer values.
#'
#' @return
#' @return A tibble containining three numeric columns: `z`, the log-scale
#' titer increase, `z_l`, the lower bound of `z`, and `z_u`, the upper
#' bound of `z`.
#'
calculate_ti_bounds <- function(y, x) {
ly <- ifelse(y == 0, -Inf, y)
Expand All @@ -215,9 +220,13 @@ calculate_ti_bounds <- function(y, x) {
#' @param log_pre Vector of log-scale pre-vaccination titer values.
#' @param log_out Boolean, TRUE if the outcome should be on the log scale.
#'
#' @return
#' @return A data frame containing the formatted `c`, `y`, and `y2` numeric
#' vectors representing the titer increase in brms censoring notation.
#'
format_titerincrease <- function(log_post, log_pre, log_out) {
# Fix 'no visible binding' R CMD CHK note
z <- z_l <- z_u <- y <- y2 <- NULL

# First calculate the censoring bounds for each observation
censoring_bounds <- calculate_ti_bounds(log_post, log_pre)

Expand Down
2 changes: 1 addition & 1 deletion inst/CITATION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
bibentry(
bibtype = "Manual",
title = "hgp: Handelgroup package",
author = "Billings, Zane and Handel, Andreas",
author = "Billings, Zane",
year = "2023"
)
27 changes: 27 additions & 0 deletions man/calculate_ti_bounds.Rd

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

53 changes: 53 additions & 0 deletions man/format_hai_data.Rd

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

23 changes: 23 additions & 0 deletions man/format_posttiter.Rd

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

26 changes: 26 additions & 0 deletions man/format_titerincrease.Rd

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

19 changes: 19 additions & 0 deletions man/hai_to_log_scale.Rd

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

19 changes: 19 additions & 0 deletions man/hai_to_natural_scale.Rd

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

23 changes: 23 additions & 0 deletions man/hai_trans.Rd

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

8 changes: 8 additions & 0 deletions man/handelgroup_strain_names.Rd

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

3 changes: 2 additions & 1 deletion man/replace_strain_names.Rd

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

0 comments on commit 29c7fcc

Please sign in to comment.