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

update goshawk v0.1.17 changes #277

Merged
merged 3 commits into from
Jun 4, 2024
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ URL: https://insightsengineering.github.io/teal.goshawk/,
https://github.com/insightsengineering/teal.goshawk/
BugReports: https://github.com/insightsengineering/teal.goshawk/issues
Depends:
goshawk (>= 0.1.15.9007),
goshawk (>= 0.1.17),
R (>= 3.6),
shiny (>= 1.6.0),
teal (>= 0.14.0.9027),
Expand Down
33 changes: 31 additions & 2 deletions R/tm_g_gh_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#' @param count_threshold minimum count of observations (as listed in the output table) to plot
#' nodes on the graph
#' @param table_font_size controls the font size of values in the table
#' @param dot_size plot dot size.
#' @param plot_relative_height_value numeric value between 500 and 5000 for controlling the starting value
#' of the relative plot height slider
#' @author Wenyi Liu (luiw2) [email protected]
Expand Down Expand Up @@ -155,13 +156,26 @@ tm_g_gh_lineplot <- function(label,
post_output = NULL,
count_threshold = 0,
table_font_size = c(12, 4, 20),
dot_size = c(2, 1, 12),
plot_relative_height_value = 1000) {
message("Initializing tm_g_gh_lineplot")
# Validate string inputs
checkmate::assert_string(label)
checkmate::assert_string(dataname)
checkmate::assert_string(param_var)
checkmate::assert_string(param_var_label)
checkmate::assert_string(stat)

# Validate choices_selected class inputs
checkmate::assert_class(param, "choices_selected")
checkmate::assert_class(xaxis_var, "choices_selected")
checkmate::assert_class(yaxis_var, "choices_selected")
checkmate::assert_class(trt_group, "choices_selected")

# Validate flag inputs
checkmate::assert_flag(rotate_xlab)

# Validate numeric vector inputs
checkmate::assert_numeric(plot_height, len = 3, any.missing = FALSE, finite = TRUE)
checkmate::assert_numeric(plot_height[1], lower = plot_height[2], upper = plot_height[3], .var.name = "plot_height")
checkmate::assert_numeric(plot_width, len = 3, any.missing = FALSE, null.ok = TRUE, finite = TRUE)
Expand All @@ -170,16 +184,23 @@ tm_g_gh_lineplot <- function(label,
lower = plot_width[2], upper = plot_width[3], null.ok = TRUE, .var.name = "plot_width"
)
checkmate::assert_numeric(table_font_size, len = 3, any.missing = FALSE, null.ok = TRUE, finite = TRUE)
checkmate::assert_numeric(dot_size, len = 3)
checkmate::assert_numeric(
table_font_size[1],
lower = table_font_size[2], upper = table_font_size[3],
null.ok = TRUE, .var.name = "table_font_size"
)

checkmate::assert_number(plot_relative_height_value, lower = 500, upper = 5000)

checkmate::assert_number(count_threshold)

# Validate color manual if provided
checkmate::assert_character(color_manual, null.ok = TRUE)
checkmate::assert_character(hline_arb_color)
checkmate::assert_character(hline_arb_label)

# Validate line arguments
validate_line_arb_arg(hline_arb, hline_arb_color, hline_arb_label)

args <- as.list(environment())

module(
Expand Down Expand Up @@ -284,6 +305,12 @@ ui_lineplot <- function(id, ...) {
"Font Size",
a$plot_font_size,
ticks = FALSE
),
teal.widgets::optionalSliderInputValMinMax(
ns("dot_size"),
"Dot Size",
a$dot_size,
ticks = FALSE
)
),
teal.widgets::panel_item(
Expand Down Expand Up @@ -647,6 +674,7 @@ srv_lineplot <- function(id,
# nolint start
ylim <- yrange_slider$state()$value
plot_font_size <- input$plot_font_size
dot_size <- input$dot_size
dodge <- input$dodge
rotate_xlab <- input$rotate_xlab
count_threshold <- `if`(is.na(as.numeric(input$count_threshold)), 0, as.numeric(input$count_threshold))
Expand Down Expand Up @@ -730,6 +758,7 @@ srv_lineplot <- function(id,
rotate_xlab = .(rotate_xlab),
plot_height = .(relative_height), # in g_lineplot this is relative height of plot to table
plot_font_size = .(plot_font_size),
dot_size = .(dot_size),
dodge = .(dodge),
count_threshold = .(count_threshold),
table_font_size = .(table_font_size),
Expand Down
46 changes: 40 additions & 6 deletions R/tm_g_gh_spaghettiplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#' @param plot_height controls plot height.
#' @param plot_width optional, controls plot width.
#' @param font_size control font size for title, `x-axis`, `y-axis` and legend font.
#' @param dot_size plot dot size.
#' @param group_stats control group mean or median overlay.
#' @param hline_arb numeric vector of at most 2 values identifying intercepts for arbitrary horizontal lines.
#' @param hline_arb_color a character vector of at most length of \code{hline_arb}.
Expand Down Expand Up @@ -181,6 +182,7 @@ tm_g_gh_spaghettiplot <- function(label,
plot_height = c(600, 200, 2000),
plot_width = NULL,
font_size = c(12, 8, 20),
dot_size = c(2, 1, 12),
hline_arb = numeric(0),
hline_arb_color = "red",
hline_arb_label = "Horizontal line",
Expand All @@ -190,20 +192,49 @@ tm_g_gh_spaghettiplot <- function(label,
pre_output = NULL,
post_output = NULL) {
message("Initializing tm_g_gh_spaghettiplot")

# Validate string inputs
checkmate::assert_string(label)
checkmate::assert_string(dataname)
checkmate::assert_string(param_var)
checkmate::assert_string(param_var_label)
checkmate::assert_string(idvar)
checkmate::assert_string(group_stats)

# Validate choices_selected class inputs
checkmate::assert_class(param, "choices_selected")
checkmate::assert_class(xaxis_var, "choices_selected")
checkmate::assert_class(yaxis_var, "choices_selected")
checkmate::assert_class(trt_group, "choices_selected")
validate_line_arb_arg(hline_arb, hline_arb_color, hline_arb_label)
validate_line_vars_arg(hline_vars, hline_vars_colors, hline_vars_labels)

# Validate flag inputs
checkmate::assert_flag(rotate_xlab)
checkmate::assert_flag(free_x)

# Validate numeric vector inputs
checkmate::assert_numeric(plot_height, len = 3, any.missing = FALSE, finite = TRUE)
checkmate::assert_numeric(plot_height[1], lower = plot_height[2], upper = plot_height[3], .var.name = "plot_height")
checkmate::assert_numeric(plot_width, len = 3, any.missing = FALSE, null.ok = TRUE, finite = TRUE)
checkmate::assert_numeric(plot_width[1],
lower = plot_width[2], upper = plot_width[3], null.ok = TRUE,
.var.name = "plot_width"
checkmate::assert_numeric(
plot_width[1],
lower = plot_width[2], upper = plot_width[3],
null.ok = TRUE, .var.name = "plot_width"
)
checkmate::assert_flag(free_x)
checkmate::assert_numeric(font_size, len = 3, any.missing = FALSE, finite = TRUE)
checkmate::assert_numeric(dot_size, len = 3, any.missing = FALSE, finite = TRUE)

# Validate color manual if provided
checkmate::assert_character(man_color, null.ok = TRUE)
checkmate::assert_character(color_comb, null.ok = TRUE)
checkmate::assert_character(hline_arb_color)
checkmate::assert_character(hline_arb_label)

# Validate facet columns
checkmate::assert_int(facet_ncol, lower = 1)

# Validate line arguments
validate_line_arb_arg(hline_arb, hline_arb_color, hline_arb_label)
validate_line_vars_arg(hline_vars, hline_vars_colors, hline_vars_labels)

args <- as.list(environment())

Expand Down Expand Up @@ -298,6 +329,7 @@ g_ui_spaghettiplot <- function(id, ...) {
checkboxInput(ns("free_x"), "Free X-Axis Scales", a$free_x),
checkboxInput(ns("rotate_xlab"), "Rotate X-Axis Label", a$rotate_xlab),
teal.widgets::optionalSliderInputValMinMax(ns("font_size"), "Font Size", a$font_size, ticks = FALSE),
teal.widgets::optionalSliderInputValMinMax(ns("dot_size"), "Dot Size", a$dot_size, ticks = FALSE),
teal.widgets::optionalSliderInputValMinMax(
ns("alpha"),
"Line Alpha",
Expand Down Expand Up @@ -408,6 +440,7 @@ srv_g_spaghettiplot <- function(id,
hline_arb_color <- horizontal_line()$line_arb_color
group_stats <- input$group_stats
font_size <- input$font_size
dot_size <- input$dot_size
alpha <- input$alpha
validate(need(input$trt_group, "Please select a treatment variable"))
trt_group <- input$trt_group
Expand Down Expand Up @@ -473,6 +506,7 @@ srv_g_spaghettiplot <- function(id,
xlabel = xlabel,
rotate_xlab = .(rotate_xlab),
font_size = .(font_size),
dot_size = .(dot_size),
alpha = .(alpha),
group_stats = .(group_stats),
hline_vars = .(hline_vars),
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# teal.goshawk

<!-- start badges -->
[![Check 🛠](https://github.com/insightsengineering/teal.goshawk/actions/workflows/check.yaml/badge.svg)](https://insightsengineering.github.io/teal.goshawk/main/unit-test-report/)
kartikeyakirar marked this conversation as resolved.
Show resolved Hide resolved
[![Docs 📚](https://github.com/insightsengineering/teal.goshawk/actions/workflows/docs.yaml/badge.svg)](https://insightsengineering.github.io/teal.goshawk/)
[![Code Coverage 📔](https://raw.githubusercontent.com/insightsengineering/teal.goshawk/_xml_coverage_reports/data/main/badge.svg)](https://insightsengineering.github.io/teal.goshawk/main/coverage-report/)

Expand Down
3 changes: 3 additions & 0 deletions man/tm_g_gh_lineplot.Rd

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

3 changes: 3 additions & 0 deletions man/tm_g_gh_spaghettiplot.Rd

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

4 changes: 2 additions & 2 deletions vignettes/teal-goshawk.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ standards. `teal.goshawk` modules can be used with data other than `ADaM` standa
features of the package will likely not be applicable.

The concepts presented here require knowledge about the core features of `teal`, specifically on how to launch a `teal`
application and how to pass data into it. Therefore, it is highly recommended to refer to the [`README`](https://insightsengineering.github.io/teal/) file and the introductory [`vignette`](https://insightsengineering.github.io/teal/latest-tag/articles/teal.html) of the `teal` package.
application and how to pass data into it. Therefore, it is highly recommended to refer to the [`README`](https://insightsengineering.github.io/teal/latest-tag/) file and the introductory [`vignette`](https://insightsengineering.github.io/teal/latest-tag/articles/index.html) of the `teal` package.

### Main features

Expand Down Expand Up @@ -108,4 +108,4 @@ Refer to the [Get Started](https://insightsengineering.github.io/teal.modules.cl
section of the teal.modules.clinical package that provides additional detail on `teal` concepts as applied in another simple app
example.

Please see additional information under [Articles](https://insightsengineering.github.io/teal.goshawk/latest-tag/articles) for data expectations, requirements and pre/post-processing rationale
Please see additional information under [Articles](https://insightsengineering.github.io/teal.goshawk/latest-tag/articles/index.html) for data expectations, requirements and pre/post-processing rationale
Loading