Skip to content

Commit

Permalink
fix lint checks + merge from main
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'refs/remotes/origin/1301-feature-request-add-confidence-intervals-for-quantiles-in-surv_time' into 1301-feature-request-add-confidence-intervals-for-quantiles-in-surv_time

# Conflicts:
#	R/survival_time.R
  • Loading branch information
iaugusty committed Sep 9, 2024
2 parents a65114a + d6e8f4b commit 7806a15
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 67 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: tern
Title: Create Common TLGs Used in Clinical Trials
Version: 0.9.5.9020
Date: 2024-09-05
Version: 0.9.5.9021
Date: 2024-09-06
Authors@R: c(
person("Joe", "Zhu", , "[email protected]", role = c("aut", "cre")),
person("Daniel", "Sabanés Bové", , "[email protected]", role = "aut"),
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# tern 0.9.5.9020
# tern 0.9.5.9021
### Enhancements
* Added `errorbar_width` and `linetype` parameters to `g_lineplot`.
* Reworking of `summarize_glm_count()` documentation and all its associated functions to better describe the results and the functions' purpose.
Expand All @@ -20,6 +20,7 @@
### Miscellaneous
* Began deprecation of the confusing functions `summary_formats` and `summary_labels`.
* Enhanced general descriptions of analyze and summarize functions throughout package documentation.
* Finalized deprecation of the `strata` and `cohort_id` arguments to `g_lineplot`.

# tern 0.9.5

Expand Down
4 changes: 0 additions & 4 deletions R/argument_convention.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#' @param conf_level (`proportion`)\cr confidence level of the interval.
#' @param data (`data.frame`)\cr the dataset containing the variables to summarize.
#' @param df (`data.frame`)\cr data set containing all analysis variables.
#' @param draw (`flag`)\cr whether the plot should be drawn.
#' @param groups_lists (named `list` of `list`)\cr optionally contains for each `subgroups` variable a
#' list, which specifies the new group levels via the names and the
#' levels that belong to it in the character vectors that are elements of the list.
Expand All @@ -49,8 +48,6 @@
#' @param nested (`flag`)\cr whether this layout instruction should be applied within the existing layout structure _if
#' possible (`TRUE`, the default) or as a new top-level element (`FALSE`). Ignored if it would nest a split.
#' underneath analyses, which is not allowed.
#' @param newpage (`flag`)\cr whether the plot should be drawn on a new page.
#' Only considered if `draw = TRUE` is used.
#' @param prune_zero_rows (`flag`)\cr whether to prune all zero rows.
#' @param riskdiff (`flag`)\cr whether a risk difference column is present. When set to `TRUE`, [add_riskdiff()] must be
#' used as `split_fun` in the prior column split of the table layout, specifying which columns should be compared.
Expand All @@ -72,7 +69,6 @@
#' @param ylim (`numeric(2)`)\cr vector containing lower and upper limits for the y-axis, respectively.
#' If `NULL` (default), the default scale range is used.
#'
#'
#' @details Although this function just returns `NULL` it has two uses, for
#' the `tern` users it provides a documentation of arguments that are
#' commonly and consistently used in the framework. For the developer it adds a
Expand Down
10 changes: 5 additions & 5 deletions R/g_forest.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,19 @@ g_forest <- function(tbl,
# Deprecated argument warnings
if (lifecycle::is_present(width_row_names)) {
lifecycle::deprecate_warn(
"0.9.3", "g_forest(width_row_names)", "g_forest(lbl_col_padding)",
"0.9.4", "g_forest(width_row_names)", "g_forest(lbl_col_padding)",
details = "The width of the row label column can be adjusted via the `lbl_col_padding` parameter."
)
}
if (lifecycle::is_present(width_forest)) {
lifecycle::deprecate_warn(
"0.9.3", "g_forest(width_forest)", "g_forest(rel_width_forest)",
"0.9.4", "g_forest(width_forest)", "g_forest(rel_width_forest)",
details = "Relative width of the forest plot (as a proportion) can be set via the `rel_width_forest` parameter."
)
}
if (lifecycle::is_present(gp)) {
lifecycle::deprecate_warn(
"0.9.3", "g_forest(gp)", "g_forest(ggtheme)",
"0.9.4", "g_forest(gp)", "g_forest(ggtheme)",
details = paste(
"`g_forest` is now generated as a `ggplot` object.",
"Additional display settings should be supplied via the `ggtheme` parameter."
Expand All @@ -203,13 +203,13 @@ g_forest <- function(tbl,
}
if (lifecycle::is_present(draw)) {
lifecycle::deprecate_warn(
"0.9.3", "g_forest(draw)",
"0.9.4", "g_forest(draw)",
details = "`g_forest` now generates `ggplot` objects. This parameter has no effect."
)
}
if (lifecycle::is_present(newpage)) {
lifecycle::deprecate_warn(
"0.9.3", "g_forest(newpage)",
"0.9.4", "g_forest(newpage)",
details = "`g_forest` now generates `ggplot` objects. This parameter has no effect."
)
}
Expand Down
16 changes: 1 addition & 15 deletions R/g_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,7 @@ h_format_row <- function(x, format, labels = NULL) {
#' @param x (`string`)\cr x-variable name.
#' @param y (`string`)\cr y-variable name.
#' @param group_var (`string` or `NA`)\cr group variable name.
#' @param strata `r lifecycle::badge("deprecated")` use the `group_var` parameter instead.
#' @param subject_var (`string` or `NA`)\cr subject variable name.
#' @param cohort_id `r lifecycle::badge("deprecated")` use the `subject_var` parameter instead.
#' @param facet_var (`string` or `NA`)\cr faceting variable name.
#' @param paramcd (`string` or `NA`)\cr parameter code variable name.
#' @param y_unit (`string` or `NA`)\cr y-axis unit variable name.
Expand All @@ -568,19 +566,7 @@ control_lineplot_vars <- function(x = "AVISIT",
facet_var = NA,
paramcd = "PARAMCD",
y_unit = "AVALU",
subject_var = "USUBJID",
strata = lifecycle::deprecated(),
cohort_id = lifecycle::deprecated()) {
if (lifecycle::is_present(strata)) {
lifecycle::deprecate_warn("0.9.2", "control_lineplot_vars(strata)", "control_lineplot_vars(group_var)")
group_var <- strata
}

if (lifecycle::is_present(cohort_id)) {
lifecycle::deprecate_warn("0.9.2", "control_lineplot_vars(cohort_id)", "control_lineplot_vars(subject_id)")
subject_id <- cohort_id
}

subject_var = "USUBJID") {
checkmate::assert_string(x)
checkmate::assert_string(y)
checkmate::assert_string(group_var, na.ok = TRUE, null.ok = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion R/h_km.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ h_tbl_coxph_pairwise <- function(df,
if ("strat" %in% names(variables)) {
warning(
"Warning: the `strat` element name of the `variables` list argument to `h_tbl_coxph_pairwise() ",
"was deprecated in tern 0.9.3.\n ",
"was deprecated in tern 0.9.4.\n ",
"Please use the name `strata` instead of `strat` in the `variables` argument."
)
variables[["strata"]] <- variables[["strat"]]
Expand Down
4 changes: 2 additions & 2 deletions R/h_response_biomarkers_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ h_rsp_to_logistic_variables <- function(variables, biomarker) {
if ("strat" %in% names(variables)) {
warning(
"Warning: the `strat` element name of the `variables` list argument to `h_rsp_to_logistic_variables() ",
"was deprecated in tern 0.9.3.\n ",
"was deprecated in tern 0.9.4.\n ",
"Please use the name `strata` instead of `strat` in the `variables` argument."
)
variables[["strata"]] <- variables[["strat"]]
Expand Down Expand Up @@ -106,7 +106,7 @@ h_logistic_mult_cont_df <- function(variables,
if ("strat" %in% names(variables)) {
warning(
"Warning: the `strat` element name of the `variables` list argument to `h_logistic_mult_cont_df() ",
"was deprecated in tern 0.9.3.\n ",
"was deprecated in tern 0.9.4.\n ",
"Please use the name `strata` instead of `strat` in the `variables` argument."
)
variables[["strata"]] <- variables[["strat"]]
Expand Down
2 changes: 1 addition & 1 deletion R/h_response_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ h_odds_ratio_subgroups_df <- function(variables,
if ("strat" %in% names(variables)) {
warning(
"Warning: the `strat` element name of the `variables` list argument to `h_odds_ratio_subgroups_df() ",
"was deprecated in tern 0.9.3.\n ",
"was deprecated in tern 0.9.4.\n ",
"Please use the name `strata` instead of `strat` in the `variables` argument."
)
variables[["strata"]] <- variables[["strat"]]
Expand Down
2 changes: 1 addition & 1 deletion R/h_survival_biomarkers_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ h_coxreg_mult_cont_df <- function(variables,
if ("strat" %in% names(variables)) {
warning(
"Warning: the `strat` element name of the `variables` list argument to `h_coxreg_mult_cont_df() ",
"was deprecated in tern 0.9.3.\n ",
"was deprecated in tern 0.9.4.\n ",
"Please use the name `strata` instead of `strat` in the `variables` argument."
)
variables[["strata"]] <- variables[["strat"]]
Expand Down
2 changes: 1 addition & 1 deletion R/h_survival_duration_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ h_coxph_subgroups_df <- function(variables,
if ("strat" %in% names(variables)) {
warning(
"Warning: the `strat` element name of the `variables` list argument to `h_coxph_subgroups_df() ",
"was deprecated in tern 0.9.3.\n ",
"was deprecated in tern 0.9.4.\n ",
"Please use the name `strata` instead of `strat` in the `variables` argument."
)
variables[["strata"]] <- variables[["strat"]]
Expand Down
2 changes: 1 addition & 1 deletion R/response_biomarkers_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ extract_rsp_biomarkers <- function(variables,
if ("strat" %in% names(variables)) {
warning(
"Warning: the `strat` element name of the `variables` list argument to `extract_rsp_biomarkers() ",
"was deprecated in tern 0.9.3.\n ",
"was deprecated in tern 0.9.4.\n ",
"Please use the name `strata` instead of `strat` in the `variables` argument."
)
variables[["strata"]] <- variables[["strat"]]
Expand Down
2 changes: 1 addition & 1 deletion R/response_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ extract_rsp_subgroups <- function(variables,
if ("strat" %in% names(variables)) {
warning(
"Warning: the `strat` element name of the `variables` list argument to `extract_rsp_subgroups() ",
"was deprecated in tern 0.9.3.\n ",
"was deprecated in tern 0.9.4.\n ",
"Please use the name `strata` instead of `strat` in the `variables` argument."
)
variables[["strata"]] <- variables[["strat"]]
Expand Down
2 changes: 1 addition & 1 deletion R/survival_biomarkers_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ extract_survival_biomarkers <- function(variables,
if ("strat" %in% names(variables)) {
warning(
"Warning: the `strat` element name of the `variables` list argument to `extract_survival_biomarkers() ",
"was deprecated in tern 0.9.3.\n ",
"was deprecated in tern 0.9.4.\n ",
"Please use the name `strata` instead of `strat` in the `variables` argument."
)
variables[["strata"]] <- variables[["strat"]]
Expand Down
2 changes: 1 addition & 1 deletion R/survival_coxph_pairwise.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ s_coxph_pairwise <- function(df,
strat = lifecycle::deprecated(),
control = control_coxph()) {
if (lifecycle::is_present(strat)) {
lifecycle::deprecate_warn("0.9.3", "s_coxph_pairwise(strat)", "s_coxph_pairwise(strata)")
lifecycle::deprecate_warn("0.9.4", "s_coxph_pairwise(strat)", "s_coxph_pairwise(strata)")
strata <- strat
}

Expand Down
2 changes: 1 addition & 1 deletion R/survival_duration_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ extract_survival_subgroups <- function(variables,
if ("strat" %in% names(variables)) {
warning(
"Warning: the `strat` element name of the `variables` list argument to `extract_survival_subgroups() ",
"was deprecated in tern 0.9.3.\n ",
"was deprecated in tern 0.9.4.\n ",
"Please use the name `strata` instead of `strat` in the `variables` argument."
)
variables[["strata"]] <- variables[["strat"]]
Expand Down
25 changes: 15 additions & 10 deletions R/survival_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ s_surv_time <- function(df,
srv_qt_ci <- lapply(quantiles, function(x) {
name <- as.character(100 * x)

c(srv_qt_tab_pre[[paste0("quantile.", name)]],
c(
srv_qt_tab_pre[[paste0("quantile.", name)]],
srv_qt_tab_pre[[paste0("lower.", name)]],
srv_qt_tab_pre[[paste0("upper.", name)]])
srv_qt_tab_pre[[paste0("upper.", name)]]
)
})

list(
Expand All @@ -107,7 +109,6 @@ s_surv_time <- function(df,
quantiles_ci_2 = formatters::with_label(
unname(srv_qt_ci[[2]]), paste0(quantiles[2] * 100, "%-ile with ", f_conf_level(conf_level))
)

)
}

Expand Down Expand Up @@ -144,13 +145,17 @@ a_surv_time <- function(df,
rng_censor_upr <- x_stats[["range_censor"]][2]

# Use method-specific defaults
fmts <- c(median_ci = "(xx.x, xx.x)", quantiles = "xx.x, xx.x", range = "xx.x to xx.x",
median_ci_1_line = "xx.x (xx.x - xx.x)",
quantiles_ci_1 = "xx.x (xx.x - xx.x)", quantiles_ci_2 = "xx.x (xx.x - xx.x)")
lbls <- c(median_ci = "95% CI", range = "Range", range_censor = "Range (censored)", range_event = "Range (event)",
median_ci_1_line = "Median 95% CI",
quantiles_ci_1 = "25%-ile with 95% CI",
quantiles_ci_2 = "75%-ile with 95% CI")
fmts <- c(
median_ci = "(xx.x, xx.x)", quantiles = "xx.x, xx.x", range = "xx.x to xx.x",
median_ci_1_line = "xx.x (xx.x - xx.x)",
quantiles_ci_1 = "xx.x (xx.x - xx.x)", quantiles_ci_2 = "xx.x (xx.x - xx.x)"
)
lbls <- c(
median_ci = "95% CI", range = "Range", range_censor = "Range (censored)", range_event = "Range (event)",
median_ci_1_line = "Median 95% CI",
quantiles_ci_1 = "25%-ile with 95% CI",
quantiles_ci_2 = "75%-ile with 95% CI"
)
lbls_custom <- .labels
.formats <- c(.formats, fmts[setdiff(names(fmts), names(.formats))])
.labels <- c(.labels, lbls[setdiff(names(lbls), names(lbls_custom))])
Expand Down
8 changes: 4 additions & 4 deletions R/utils_default_stats_formats_labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,14 @@ labels_use_control <- function(labels_default, control, labels_custom = NULL) {
)
}
if ("quantiles" %in% names(control) && "quantiles_ci_1" %in% names(labels_default) &&
!"quantiles_ci_1" %in% names(labels_custom)) { # nolint
!"quantiles_ci_1" %in% names(labels_custom)) { # nolint
labels_default["quantiles_ci_1"] <- gsub(
"[0-9]+%-ile", paste0(control[["quantiles"]][1] * 100, "%-ile", ""),
labels_default["quantiles_ci_1"]
)
}
if ("quantiles" %in% names(control) && "quantiles_ci_2" %in% names(labels_default) &&
!"quantiles_ci_2" %in% names(labels_custom)) { # nolint
!"quantiles_ci_2" %in% names(labels_custom)) { # nolint
labels_default["quantiles_ci_2"] <- gsub(
"[0-9]+%-ile", paste0(control[["quantiles"]][2] * 100, "%-ile", ""),
labels_default["quantiles_ci_2"]
Expand Down Expand Up @@ -536,7 +536,7 @@ tern_default_labels <- c(
#' @export
summary_formats <- function(type = "numeric", include_pval = FALSE) {
lifecycle::deprecate_warn(
"0.9.5.9005", "summary_formats()",
"0.9.6", "summary_formats()",
details = 'Use get_formats_from_stats(get_stats("analyze_vars_numeric", add_pval = include_pval)) instead'
)
met_grp <- paste0(c("analyze_vars", type), collapse = "_")
Expand All @@ -559,7 +559,7 @@ summary_formats <- function(type = "numeric", include_pval = FALSE) {
#' @export
summary_labels <- function(type = "numeric", include_pval = FALSE) {
lifecycle::deprecate_warn(
"0.9.5.9005", "summary_formats()",
"0.9.6", "summary_formats()",
details = 'Use get_labels_from_stats(get_stats("analyze_vars_numeric", add_pval = include_pval)) instead'
)
met_grp <- paste0(c("analyze_vars", type), collapse = "_")
Expand Down
5 changes: 0 additions & 5 deletions man/argument_convention.Rd

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

8 changes: 1 addition & 7 deletions man/control_lineplot_vars.Rd

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

3 changes: 0 additions & 3 deletions tests/testthat/test-g_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ testthat::test_that("g_lineplot xticks, xlim, and ylim arguments work", {

testthat::test_that("control_lineplot_vars works", {
testthat::expect_silent(control_lineplot_vars(group_var = NA))

# Deprecation warnings work
lifecycle::expect_deprecated(lifecycle::expect_deprecated(control_lineplot_vars(strata = NA, cohort_id = NA)))
})

testthat::test_that("g_lineplot works with no strata (group_var) and allows points when only one strata is provided", {
Expand Down

0 comments on commit 7806a15

Please sign in to comment.