Skip to content

Commit

Permalink
remove teal.devel (#130)
Browse files Browse the repository at this point in the history
* green locally

* prefix chunks calls

* fix styler/lints

* styler

* remove teal.transform from dependencies

[skip audit]
[skip gitleaks]
[skip pii-check]
[skip bioccheck]
[skip r-cmd]
[skip spelling]
[skip licenses]
[skip linter]
[skip style]
[skip docs]
[skip validation]
[skip release]
[skip roxygen]
[skip links]
[skip coverage]
[skip version]
  • Loading branch information
gogonzo authored Mar 16, 2022
1 parent 634b202 commit 4917554
Show file tree
Hide file tree
Showing 18 changed files with 200 additions and 193 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
^man-roxygen$
^Meta$
^outputdir$
^\.pre-commit-config\.yaml$
^scratch$
^stubs$
^temp$
Expand Down
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Imports:
methods,
shinyjs,
stats,
teal.devel (>= 0.2.13),
teal.code,
teal.widgets,
tidyr (>= 1.0.0),
utils
Suggests:
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import(methods, except = show)
import(shiny)
import(stats, except = c(filter, lag))
import(teal)
import(teal.devel)
import(tidyr)
import(utils)
importFrom(colourpicker,colourInput)
Expand Down
1 change: 0 additions & 1 deletion R/teal_goshawk.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#' @import shiny
#' @rawNamespace import(stats, except = c(filter, lag))
#' @import teal
#' @import teal.devel
#' @import tidyr
#' @keywords internal
NULL
49 changes: 24 additions & 25 deletions R/tm_g_gh_boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@
#' @param dot_size plot dot size.
#' @param alpha numeric vector to define transparency of plotted points.
#'
#' @inheritParams teal.devel::standard_layout
#' @inheritParams teal.widgets::standard_layout
#'
#' @import DescTools
#' @import utils
#' @import dplyr
#' @import goshawk
#' @import teal
#' @import teal.devel
#'
#' @author Jeff Tomlinson (tomlinsj) [email protected]
#' @author Balazs Toth (tothb2) [email protected]
Expand Down Expand Up @@ -272,10 +271,10 @@ ui_g_boxplot <- function(id, ...) {
ns <- NS(id)
a <- list(...)

standard_layout(
teal.widgets::standard_layout(
output = div(
fluidRow(
plot_with_settings_ui(id = ns("boxplot"))
teal.widgets::plot_with_settings_ui(id = ns("boxplot"))
),
fluidRow(column(
width = 12,
Expand All @@ -292,7 +291,7 @@ ui_g_boxplot <- function(id, ...) {
),
encoding = div(
templ_ui_dataname(a$dataname),
optionalSelectInput(
teal.widgets::optionalSelectInput(
ns("trt_group"),
label = "Select Treatment Variable",
choices = a$trt_group$choices,
Expand All @@ -309,7 +308,7 @@ ui_g_boxplot <- function(id, ...) {
ychoices = a$yaxis_var$choices,
yselected = a$yaxis_var$selected
),
optionalSelectInput(
teal.widgets::optionalSelectInput(
ns("facet_var"),
label = "Facet by",
choices = a$facet_var$choices,
Expand All @@ -318,7 +317,7 @@ ui_g_boxplot <- function(id, ...) {
),
templ_ui_constraint(ns, label = "Data Constraint"), # required by constr_anl_chunks
if (length(a$hline_vars) > 0) {
optionalSelectInput(
teal.widgets::optionalSelectInput(
ns("hline_vars"),
label = "Add Horizontal Range Line(s):",
choices = a$hline_vars,
Expand All @@ -327,8 +326,8 @@ ui_g_boxplot <- function(id, ...) {
)
},
ui_arbitrary_lines(id = ns("hline_arb"), a$hline_arb, a$hline_arb_label, a$hline_arb_color),
panel_group(
panel_item(
teal.widgets::panel_group(
teal.widgets::panel_item(
title = "Plot Aesthetic Settings",
toggle_slider_ui(
ns("yrange_scale"),
Expand All @@ -341,11 +340,11 @@ ui_g_boxplot <- function(id, ...) {
checkboxInput(ns("loq_legend"), "Display LoQ Legend", a$loq_legend),
checkboxInput(ns("rotate_xlab"), "Rotate X-axis Label", a$rotate_xlab)
),
panel_item(
teal.widgets::panel_item(
title = "Plot settings",
optionalSliderInputValMinMax(ns("font_size"), "Font Size", a$font_size, ticks = FALSE),
optionalSliderInputValMinMax(ns("dot_size"), "Dot Size", a$dot_size, ticks = FALSE),
optionalSliderInputValMinMax(ns("alpha"), "Dot Alpha", a$alpha, ticks = FALSE)
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"), "Dot Alpha", a$alpha, ticks = FALSE)
)
)
),
Expand All @@ -369,7 +368,7 @@ srv_g_boxplot <- function(id,
hline_vars_colors,
hline_vars_labels) {
moduleServer(id, function(input, output, session) {
init_chunks()
teal.code::init_chunks()

# reused in all modules
anl_chunks <- constr_anl_chunks(
Expand Down Expand Up @@ -447,7 +446,7 @@ srv_g_boxplot <- function(id,
sprintf("You can not choose %s as x-axis variable for treatment variable %s.", xaxis, trt_group)
))

chunks_push(
teal.code::chunks_push(
chunks = private_chunks,
id = "boxplot",
expression = bquote({
Expand Down Expand Up @@ -478,7 +477,7 @@ srv_g_boxplot <- function(id,
})
)

chunks_safe_eval(private_chunks)
teal.code::chunks_safe_eval(private_chunks)

private_chunks
})
Expand All @@ -491,7 +490,7 @@ srv_g_boxplot <- function(id,
font_size <- input$font_size
trt_group <- input$trt_group

chunks_push(
teal.code::chunks_push(
chunks = private_chunks,
id = "table",
expression = bquote({
Expand All @@ -506,31 +505,31 @@ srv_g_boxplot <- function(id,
})
)

chunks_safe_eval(private_chunks)
teal.code::chunks_safe_eval(private_chunks)
private_chunks
})

main_code <- reactive({
private_chunks <- create_table()
chunks_push(
teal.code::chunks_push(
chunks = private_chunks,
id = "output",
expression = quote(print(p))
)

chunks_safe_eval(private_chunks)
teal.code::chunks_safe_eval(private_chunks)

chunks_reset()
chunks_push_chunks(private_chunks)
teal.code::chunks_reset()
teal.code::chunks_push_chunks(private_chunks)

private_chunks
})

plot_r <- reactive({
chunks_get_var("p", main_code())
teal.code::chunks_get_var("p", main_code())
})

boxplot_data <- plot_with_settings_srv(
boxplot_data <- teal.widgets::plot_with_settings_srv(
id = "boxplot",
plot_r = plot_r,
height = plot_height,
Expand All @@ -539,7 +538,7 @@ srv_g_boxplot <- function(id,
)

output$table_ui <- DT::renderDataTable({
tbl <- chunks_get_var("tbl", main_code())
tbl <- teal.code::chunks_get_var("tbl", main_code())

numeric_cols <- setdiff(names(select_if(tbl, is.numeric)), "n")

Expand Down
75 changes: 39 additions & 36 deletions R/tm_g_gh_correlationplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description Scatter Plot Teal Module For Biomarker Analysis
#'
#' @inheritParams teal.devel::standard_layout
#' @inheritParams teal.widgets::standard_layout
#' @param label menu item label of the module in the teal app.
#' @param dataname analysis data passed to the data argument of teal init. E.g. ADaM structured laboratory data frame
#' \code{ADLB}.
Expand Down Expand Up @@ -76,16 +76,16 @@
#' AVISIT == "SCREENING" ~ "SCR",
#' AVISIT == "BASELINE" ~ "BL",
#' grepl("WEEK", AVISIT) ~
#' paste(
#' "W",
#' trimws(
#' substr(
#' AVISIT,
#' start = 6,
#' stop = stringr::str_locate(AVISIT, "DAY") - 1
#' paste(
#' "W",
#' trimws(
#' substr(
#' AVISIT,
#' start = 6,
#' stop = stringr::str_locate(AVISIT, "DAY") - 1
#' )
#' )
#' )
#' ),
#' ),
#' TRUE ~ NA_character_
#' )) %>%
#' mutate(AVISITCDN = case_when(
Expand Down Expand Up @@ -334,11 +334,11 @@ ui_g_correlationplot <- function(id, ...) {
ns <- NS(id)
a <- list(...)

standard_layout(
teal.widgets::standard_layout(
output = templ_ui_output_datatable(ns),
encoding = div(
templ_ui_dataname(a$dataname),
optionalSelectInput(
teal.widgets::optionalSelectInput(
ns("trt_group"),
label = "Select Treatment Variable",
choices = a$trt_group$choices,
Expand All @@ -354,7 +354,7 @@ ui_g_correlationplot <- function(id, ...) {
),
templ_ui_constraint(ns, "X-Axis Data Constraint"), # required by constr_anl_chunks
if (length(a$hline_vars) > 0) {
optionalSelectInput(
teal.widgets::optionalSelectInput(
ns("hline_vars"),
label = "Add Horizontal Range Line(s):",
choices = a$hline_vars,
Expand All @@ -364,7 +364,7 @@ ui_g_correlationplot <- function(id, ...) {
},
ui_arbitrary_lines(id = ns("hline_arb"), a$hline_arb, a$hline_arb_label, a$hline_arb_color),
if (length(a$vline_vars) > 0) {
optionalSelectInput(
teal.widgets::optionalSelectInput(
ns("vline_vars"),
label = "Add Vertical Range Line(s):",
choices = a$vline_vars,
Expand All @@ -379,8 +379,8 @@ ui_g_correlationplot <- function(id, ...) {
a$vline_arb_color,
title = "Arbitrary Vertical Lines:"
),
panel_group(
panel_item(
teal.widgets::panel_group(
teal.widgets::panel_item(
title = "Plot Aesthetic Settings",
toggle_slider_ui(
ns("xrange_scale"),
Expand All @@ -399,11 +399,14 @@ ui_g_correlationplot <- function(id, ...) {
checkboxInput(ns("loq_legend"), "Display LoQ Legend", a$loq_legend),
checkboxInput(ns("rotate_xlab"), "Rotate X-axis Label", a$rotate_xlab)
),
panel_item(
teal.widgets::panel_item(
title = "Plot settings",
optionalSliderInputValMinMax(ns("font_size"), "Font Size", a$font_size, ticks = FALSE),
optionalSliderInputValMinMax(ns("dot_size"), "Dot Size", a$dot_size, ticks = FALSE),
optionalSliderInputValMinMax(ns("reg_text_size"), "Regression Annotations Size", a$reg_text_size,
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("reg_text_size"),
"Regression Annotations Size",
a$reg_text_size,
ticks = FALSE
)
)
Expand Down Expand Up @@ -431,7 +434,7 @@ srv_g_correlationplot <- function(id,
vline_vars_colors,
vline_vars_labels) {
moduleServer(id, function(input, output, session) {
init_chunks()
teal.code::init_chunks()
# filter selected biomarkers
anl_param <- reactive({
validate(need(input$trt_group, "Please select a Treatment Variable"))
Expand Down Expand Up @@ -531,10 +534,10 @@ srv_g_correlationplot <- function(id,

# analysis
private_chunks <- chunks$new()
chunks_reset(as.environment(setNames(list(ANL_FILTERED), dataset_var)), private_chunks)
teal.code::chunks_reset(as.environment(setNames(list(ANL_FILTERED), dataset_var)), private_chunks)

# filter biomarker
chunks_push(
teal.code::chunks_push(
chunks = private_chunks,
id = "filter_biomarker",
expression = bquote({
Expand All @@ -543,7 +546,7 @@ srv_g_correlationplot <- function(id,
})
)

ANL <- chunks_safe_eval(private_chunks) # nolint
ANL <- teal.code::chunks_safe_eval(private_chunks) # nolint
validate_has_data(ANL, 1)

return(list(ANL = ANL, chunks = private_chunks))
Expand Down Expand Up @@ -640,7 +643,7 @@ srv_g_correlationplot <- function(id,
trt_group <- input$trt_group
line_vars <- unique(c(input$hline_vars, input$vline_vars))

chunks_push(
teal.code::chunks_push(
chunks = private_chunks,
id = "plot_data_transpose",
expression = bquote({
Expand Down Expand Up @@ -713,25 +716,25 @@ srv_g_correlationplot <- function(id,
})
)

ANL_TRANSPOSED <- chunks_safe_eval(private_chunks) # nolint
chunks_push_new_line(private_chunks)
ANL_TRANSPOSED <- teal.code::chunks_safe_eval(private_chunks) # nolint
teal.code::chunks_push_new_line(private_chunks)

validate(need(nrow(ANL_TRANSPOSED) > 0, "Plot Data No Observations Left"))
validate_has_variable(data = ANL_TRANSPOSED, varname = c(xvar(), yvar(), xloqfl(), yloqfl()))

chunks_push(
teal.code::chunks_push(
chunks = private_chunks,
id = "ANL_attributes",
expression =
bquote(attr(ANL_TRANSPOSED[[.(trt_group)]], "label") <- attr(ANL[[.(trt_group)]], "label")) # nolint
)
chunks_push_new_line(private_chunks)
teal.code::chunks_push_new_line(private_chunks)

return(list(ANL_TRANSPOSED = ANL_TRANSPOSED, chunks = private_chunks))
})

plot_labels <- reactive({
ANL <- chunks_get_var(var = "ANL", anl_constraint()$chunks) # nolint
ANL <- teal.code::chunks_get_var(var = "ANL", anl_constraint()$chunks) # nolint

xparam <- ANL$PARAM[ANL[[param_var]] == input$xaxis_param][1]
yparam <- ANL$PARAM[ANL[[param_var]] == input$yaxis_param][1]
Expand Down Expand Up @@ -802,7 +805,7 @@ srv_g_correlationplot <- function(id,
validate(need(input$trt_group, "Please select a treatment variable"))
trt_group <- input$trt_group

chunks_push(
teal.code::chunks_push(
chunks = private_chunks,
id = "scatterplot",
expression = bquote({
Expand Down Expand Up @@ -851,16 +854,16 @@ srv_g_correlationplot <- function(id,
})
)

chunks_safe_eval(private_chunks)
teal.code::chunks_safe_eval(private_chunks)

# promote chunks to be visible in the sessionData by other modules
chunks_reset()
chunks_push_chunks(private_chunks)
chunks_get_var("p")
teal.code::chunks_reset()
teal.code::chunks_push_chunks(private_chunks)
teal.code::chunks_get_var("p")
})


plot_data <- plot_with_settings_srv(
plot_data <- teal.widgets::plot_with_settings_srv(
id = "plot",
plot_r = plot_r,
height = plot_height,
Expand Down
Loading

0 comments on commit 4917554

Please sign in to comment.