Skip to content

Commit

Permalink
Merge branch 'main' into 1301-feature-request-add-confidence-interval…
Browse files Browse the repository at this point in the history
…s-for-quantiles-in-surv_time
  • Loading branch information
shajoezhu authored Nov 1, 2024
2 parents 2f38a34 + 65a09b8 commit 2a2a2a5
Show file tree
Hide file tree
Showing 12 changed files with 634 additions and 314 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ jobs:
secrets:
REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
with:
deps-installation-method: setup-r-dependencies
lookup-refs: |
insightsengineering/nestcolor
insightsengineering/rtables
insightsengineering/formatters
additional-env-vars: |
_R_CHECK_CRAN_INCOMING_REMOTE_=false
additional-r-cmd-check-params: --as-cran
Expand All @@ -46,6 +51,11 @@ jobs:
secrets:
REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
with:
deps-installation-method: setup-r-dependencies
lookup-refs: |
insightsengineering/nestcolor
insightsengineering/rtables
insightsengineering/formatters
additional-env-vars: |
_R_CHECK_CRAN_INCOMING_REMOTE_=false
NOT_CRAN=true
Expand All @@ -69,6 +79,11 @@ jobs:
secrets:
REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
with:
deps-installation-method: setup-r-dependencies
lookup-refs: |
insightsengineering/nestcolor
insightsengineering/rtables
insightsengineering/formatters
additional-env-vars: |
NOT_CRAN=true
linter:
Expand All @@ -81,6 +96,11 @@ jobs:
secrets:
REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
with:
deps-installation-method: setup-r-dependencies
lookup-refs: |
insightsengineering/nestcolor
insightsengineering/rtables
insightsengineering/formatters
auto-update: true
gitleaks:
name: gitleaks 💧
Expand Down
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.6.9010
Date: 2024-10-25
Version: 0.9.6.9012
Date: 2024-11-01
Authors@R: c(
person("Joe", "Zhu", , "[email protected]", role = c("aut", "cre")),
person("Daniel", "Sabanés Bové", , "[email protected]", role = "aut"),
Expand Down
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# tern 0.9.6.9010
# tern 0.9.6.9012

### Enhancements
* Added the `denom` parameter to `s_count_cumulative()`, `s_count_missed_doses()`, and `s_count_occurrences_by_grade()`.
* Added `"N_row"` as an optional input to `denom` in `s_count_occurrences()`.
* Refactored `a_count_occurrences_by_grade()` to no longer use `make_afun()`.

### Enhancements
* Added `rel_height_plot` parameter to `g_lineplot()` to control the line plot height relative to annotation table height.
* Updated the `table_font_size` parameter of `g_lineplot()` to control the size of all text in the annotation table, including labels.
* Added `as_list` parameter to `g_lineplot()` to allow users to return the line plot and annotation table elements as a list instead of stacked for more complex customization.

### Bug Fixes
* Fixed bug in `a_summary()` causing non-unique `row_name` values to occur when multiple statistics are selected for count variables.

Expand Down
38 changes: 32 additions & 6 deletions R/g_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description `r lifecycle::badge("stable")`
#'
#' Line plot with the optional table.
#' Line plot with optional table.
#'
#' @inheritParams argument_convention
#' @param alt_counts_df (`data.frame` or `NULL`)\cr data set that will be used (only)
Expand Down Expand Up @@ -72,6 +72,11 @@
#' @param col (`character`)\cr color(s). See `?ggplot2::aes_colour_fill_alpha` for example values.
#' @param linetype (`character`)\cr line type(s). See `?ggplot2::aes_linetype_size_shape` for example values.
#' @param errorbar_width (`numeric(1)`)\cr width of the error bars.
#' @param rel_height_plot (`proportion`)\cr proportion of total figure height to allocate to the line plot.
#' Relative height of annotation table is then `1 - rel_height_plot`. If `table = NULL`, this parameter is ignored.
#' @param as_list (`flag`)\cr whether the two `ggplot` objects should be returned as a list when `table` is not `NULL`.
#' If `TRUE`, a named list with two elements, `plot` and `table`, will be returned. If `FALSE` (default) the
#' annotation table is printed below the plot via [cowplot::plot_grid()].
#'
#' @return A `ggplot` line plot (and statistics table if applicable).
#'
Expand Down Expand Up @@ -162,7 +167,9 @@ g_lineplot <- function(df,
errorbar_width = 0.45,
newpage = lifecycle::deprecated(),
col = NULL,
linetype = NULL) {
linetype = NULL,
rel_height_plot = 0.5,
as_list = FALSE) {
checkmate::assert_character(variables, any.missing = TRUE)
checkmate::assert_character(mid, null.ok = TRUE)
checkmate::assert_character(interval, null.ok = TRUE)
Expand All @@ -174,6 +181,8 @@ g_lineplot <- function(df,
checkmate::assert_number(errorbar_width, lower = 0)
checkmate::assert_string(title, null.ok = TRUE)
checkmate::assert_string(subtitle, null.ok = TRUE)
assert_proportion_value(rel_height_plot)
checkmate::assert_logical(as_list)

if (!is.null(table)) {
table_format <- get_formats_from_stats(table)
Expand Down Expand Up @@ -462,9 +471,15 @@ g_lineplot <- function(df,
axis.ticks = ggplot2::element_blank(),
axis.title = ggplot2::element_blank(),
axis.text.x = ggplot2::element_blank(),
axis.text.y = ggplot2::element_text(margin = ggplot2::margin(t = 0, r = 0, b = 0, l = 5)),
axis.text.y = ggplot2::element_text(
size = table_font_size * ggplot2::.pt,
margin = ggplot2::margin(t = 0, r = 0, b = 0, l = 5)
),
strip.text = ggplot2::element_text(hjust = 0),
strip.text.x = ggplot2::element_text(margin = ggplot2::margin(1.5, 0, 1.5, 0, "pt")),
strip.text.x = ggplot2::element_text(
size = table_font_size * ggplot2::.pt,
margin = ggplot2::margin(1.5, 0, 1.5, 0, "pt")
),
strip.background = ggplot2::element_rect(fill = "grey95", color = NA),
legend.position = "none"
)
Expand All @@ -473,8 +488,19 @@ g_lineplot <- function(df,
tbl <- tbl + ggplot2::facet_wrap(facets = group_var, ncol = 1)
}

# align plot and table
cowplot::plot_grid(p, tbl, ncol = 1, align = "v", axis = "tblr")
if (!as_list) {
# align plot and table
cowplot::plot_grid(
p,
tbl,
ncol = 1,
align = "v",
axis = "tblr",
rel_heights = c(rel_height_plot, 1 - rel_height_plot)
)
} else {
list(plot = p, table = tbl)
}
} else {
p
}
Expand Down
13 changes: 11 additions & 2 deletions man/g_lineplot.Rd

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

60 changes: 0 additions & 60 deletions staged_dependencies.yaml

This file was deleted.

24 changes: 12 additions & 12 deletions tests/testthat/_snaps/g_lineplot/g_lineplot_cohorts.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions tests/testthat/_snaps/g_lineplot/g_lineplot_factor_levels.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2a2a2a5

Please sign in to comment.