Skip to content

Commit

Permalink
few enhancements (#254)
Browse files Browse the repository at this point in the history
- fixed package level Rd file
- removed unnecessary empty first line in examples as this is actually
being rendered
- removed `pkg::` from docs for packages in Depends
- fixed example of `toggle_slider_ui`

---------

Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: unknown <kirar.kartikeya1@gmail.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
4 people committed Mar 18, 2024
1 parent dacc6a7 commit fe05e76
Show file tree
Hide file tree
Showing 18 changed files with 272 additions and 270 deletions.
3 changes: 1 addition & 2 deletions R/teal_goshawk.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
#' The data used for teal.goshawk have some constraints.
#' It must contain the columns `AVISITCD`, `BASE`, `BASE2`, `AVALU`, `LBSTRESC`, `LOQFL`, `CHG2`, and `PCHG2`.
#'
#' @name teal_goshawk
#'
#' @import goshawk
#' @import shiny
#' @import teal
#' @import teal.transform
#' @importFrom ggplot2 ggplot
#' @importFrom rlang .data sym
#' @importFrom teal.transform choices_selected
#'
#' @keywords internal
"_PACKAGE"
37 changes: 20 additions & 17 deletions R/tm_g_gh_boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@
#' @export
#'
#' @examples
#'
#' # Example using ADaM structure analysis dataset.
#' data <- teal_data()
#' data <- within(data, {
#' library(dplyr)
#' library(nestcolor)
#' library(stringr)
#'
#' # use non-exported function from goshawk
#' h_identify_loq_values <- getFromNamespace("h_identify_loq_values", "goshawk")
#'
#' # original ARM value = dose value
#' arm_mapping <- list(
Expand All @@ -60,25 +63,25 @@
#' "C: Combination" = "Combination"
#' )
#' set.seed(1)
#' ADSL <- goshawk::rADSL
#' ADLB <- goshawk::rADLB
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' dplyr::mutate(
#' AVISITCD = dplyr::case_when(
#' mutate(
#' AVISITCD = case_when(
#' AVISIT == "SCREENING" ~ "SCR",
#' AVISIT == "BASELINE" ~ "BL",
#' grepl("WEEK", AVISIT) ~ paste("W", stringr::str_extract(AVISIT, "(?<=(WEEK ))[0-9]+")),
#' grepl("WEEK", AVISIT) ~ paste("W", str_extract(AVISIT, "(?<=(WEEK ))[0-9]+")),
#' TRUE ~ as.character(NA)
#' ),
#' AVISITCDN = dplyr::case_when(
#' AVISITCDN = case_when(
#' AVISITCD == "SCR" ~ -2,
#' AVISITCD == "BL" ~ 0,
#' grepl("W", AVISITCD) ~ as.numeric(gsub("[^0-9]*", "", AVISITCD)),
#' TRUE ~ as.numeric(NA)
#' ),
#' AVISITCD = factor(AVISITCD) %>% reorder(AVISITCDN),
#' TRTORD = dplyr::case_when(
#' TRTORD = case_when(
#' ARMCD == "ARM C" ~ 1,
#' ARMCD == "ARM B" ~ 2,
#' ARMCD == "ARM A" ~ 3
Expand All @@ -90,13 +93,13 @@
#' ANRLO = 50,
#' ANRHI = 75
#' ) %>%
#' dplyr::rowwise() %>%
#' dplyr::group_by(PARAMCD) %>%
#' dplyr::mutate(LBSTRESC = ifelse(
#' rowwise() %>%
#' group_by(PARAMCD) %>%
#' mutate(LBSTRESC = ifelse(
#' USUBJID %in% sample(USUBJID, 1, replace = TRUE),
#' paste("<", round(runif(1, min = 25, max = 30))), LBSTRESC
#' )) %>%
#' dplyr::mutate(LBSTRESC = ifelse(
#' mutate(LBSTRESC = ifelse(
#' USUBJID %in% sample(USUBJID, 1, replace = TRUE),
#' paste(">", round(runif(1, min = 70, max = 75))), LBSTRESC
#' )) %>%
Expand All @@ -108,19 +111,19 @@
#' attr(ADLB[["ANRHI"]], "label") <- "Analysis Normal Range Upper Limit"
#'
#' # add LLOQ and ULOQ variables
#' ALB_LOQS <- goshawk:::h_identify_loq_values(ADLB, "LOQFL")
#' ADLB <- dplyr::left_join(ADLB, ALB_LOQS, by = "PARAM")
#' ALB_LOQS <- h_identify_loq_values(ADLB, "LOQFL")
#' ADLB <- left_join(ADLB, ALB_LOQS, by = "PARAM")
#' })
#'
#' datanames <- c("ADSL", "ADLB")
#' datanames(data) <- datanames
#'
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- teal::init(
#' app <- init(
#' data = data,
#' modules = teal::modules(
#' teal.goshawk::tm_g_gh_boxplot(
#' modules = modules(
#' tm_g_gh_boxplot(
#' label = "Box Plot",
#' dataname = "ADLB",
#' param_var = "PARAMCD",
Expand Down
49 changes: 27 additions & 22 deletions R/tm_g_gh_correlationplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@
#' @author Balazs Toth (tothb2) toth.balazs@gene.com
#'
#' @examples
#'
#' # Example using ADaM structure analysis dataset.
#' data <- teal_data()
#' data <- within(data, {
#' library(dplyr)
#' library(stringr)
#'
#' # use non-exported function from goshawk
#' h_identify_loq_values <- getFromNamespace("h_identify_loq_values", "goshawk")
#'
#' # original ARM value = dose value
#' arm_mapping <- list(
#' "A: Drug X" = "150mg QD",
Expand All @@ -65,11 +70,11 @@
#' shape_manual <- c("N" = 1, "Y" = 2, "NA" = 0)
#'
#' set.seed(1)
#' ADSL <- goshawk::rADSL
#' ADLB <- goshawk::rADLB
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' dplyr::mutate(AVISITCD = dplyr::case_when(
#' mutate(AVISITCD = case_when(
#' AVISIT == "SCREENING" ~ "SCR",
#' AVISIT == "BASELINE" ~ "BL",
#' grepl("WEEK", AVISIT) ~
Expand All @@ -79,48 +84,48 @@
#' substr(
#' AVISIT,
#' start = 6,
#' stop = stringr::str_locate(AVISIT, "DAY") - 1
#' stop = str_locate(AVISIT, "DAY") - 1
#' )
#' )
#' ),
#' TRUE ~ NA_character_
#' )) %>%
#' dplyr::mutate(AVISITCDN = dplyr::case_when(
#' mutate(AVISITCDN = case_when(
#' AVISITCD == "SCR" ~ -2,
#' AVISITCD == "BL" ~ 0,
#' grepl("W", AVISITCD) ~ as.numeric(gsub("[^0-9]*", "", AVISITCD)),
#' TRUE ~ NA_real_
#' )) %>%
#' # use ARMCD values to order treatment in visualization legend
#' dplyr::mutate(TRTORD = ifelse(grepl("C", ARMCD), 1,
#' mutate(TRTORD = ifelse(grepl("C", ARMCD), 1,
#' ifelse(grepl("B", ARMCD), 2,
#' ifelse(grepl("A", ARMCD), 3, NA)
#' )
#' )) %>%
#' dplyr::mutate(ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))])) %>%
#' dplyr::mutate(ARM = factor(ARM) %>%
#' mutate(ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))])) %>%
#' mutate(ARM = factor(ARM) %>%
#' reorder(TRTORD)) %>%
#' dplyr::mutate(
#' ANRHI = dplyr::case_when(
#' mutate(
#' ANRHI = case_when(
#' PARAMCD == "ALT" ~ 60,
#' PARAMCD == "CRP" ~ 70,
#' PARAMCD == "IGA" ~ 80,
#' TRUE ~ NA_real_
#' ),
#' ANRLO = dplyr::case_when(
#' ANRLO = case_when(
#' PARAMCD == "ALT" ~ 20,
#' PARAMCD == "CRP" ~ 30,
#' PARAMCD == "IGA" ~ 40,
#' TRUE ~ NA_real_
#' )
#' ) %>%
#' dplyr::rowwise() %>%
#' dplyr::group_by(PARAMCD) %>%
#' dplyr::mutate(LBSTRESC = ifelse(
#' rowwise() %>%
#' group_by(PARAMCD) %>%
#' mutate(LBSTRESC = ifelse(
#' USUBJID %in% sample(USUBJID, 1, replace = TRUE),
#' paste("<", round(runif(1, min = 25, max = 30))), LBSTRESC
#' )) %>%
#' dplyr::mutate(LBSTRESC = ifelse(
#' mutate(LBSTRESC = ifelse(
#' USUBJID %in% sample(USUBJID, 1, replace = TRUE),
#' paste(">", round(runif(1, min = 70, max = 75))), LBSTRESC
#' )) %>%
Expand All @@ -130,19 +135,19 @@
#' attr(ADLB[["ANRLO"]], "label") <- "Analysis Normal Range Lower Limit"
#'
#' # add LLOQ and ULOQ variables
#' ADLB_LOQS <- goshawk:::h_identify_loq_values(ADLB, "LOQFL")
#' ADLB <- dplyr::left_join(ADLB, ADLB_LOQS, by = "PARAM")
#' ADLB_LOQS <- h_identify_loq_values(ADLB, "LOQFL")
#' ADLB <- left_join(ADLB, ADLB_LOQS, by = "PARAM")
#' })
#'
#' datanames <- c("ADSL", "ADLB")
#' datanames(data) <- datanames
#'
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- teal::init(
#' app <- init(
#' data = data,
#' modules = teal::modules(
#' teal.goshawk::tm_g_gh_correlationplot(
#' modules = modules(
#' tm_g_gh_correlationplot(
#' label = "Correlation Plot",
#' dataname = "ADLB",
#' param_var = "PARAMCD",
Expand Down Expand Up @@ -170,7 +175,7 @@
#' hline_arb_color = c("red", "blue"),
#' hline_vars = c("ANRHI", "ANRLO", "ULOQN", "LLOQN"),
#' hline_vars_colors = c("green", "blue", "purple", "cyan"),
#' hline_vars_label = c("ANRHI Label", "ANRLO Label", "ULOQN Label", "LLOQN Label"),
#' hline_vars_labels = c("ANRHI Label", "ANRLO Label", "ULOQN Label", "LLOQN Label"),
#' vline_vars = c("ANRHI", "ANRLO", "ULOQN", "LLOQN"),
#' vline_vars_colors = c("yellow", "orange", "brown", "gold"),
#' vline_vars_labels = c("ANRHI Label", "ANRLO Label", "ULOQN Label", "LLOQN Label"),
Expand Down
23 changes: 12 additions & 11 deletions R/tm_g_gh_density_distribution_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,37 @@
#' @export
#'
#' @examples
#'
#' # Example using ADaM structure analysis dataset.
#' data <- teal_data()
#' data <- within(data, {
#' library(dplyr)
#' library(stringr)
#'
#' # original ARM value = dose value
#' arm_mapping <- list(
#' "A: Drug X" = "150mg QD",
#' "B: Placebo" = "Placebo",
#' "C: Combination" = "Combination"
#' )
#' ADSL <- goshawk::rADSL
#' ADLB <- goshawk::rADLB
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' dplyr::mutate(
#' AVISITCD = dplyr::case_when(
#' mutate(
#' AVISITCD = case_when(
#' AVISIT == "SCREENING" ~ "SCR",
#' AVISIT == "BASELINE" ~ "BL",
#' grepl("WEEK", AVISIT) ~ paste("W", stringr::str_extract(AVISIT, "(?<=(WEEK ))[0-9]+")),
#' grepl("WEEK", AVISIT) ~ paste("W", str_extract(AVISIT, "(?<=(WEEK ))[0-9]+")),
#' TRUE ~ as.character(NA)
#' ),
#' AVISITCDN = dplyr::case_when(
#' AVISITCDN = case_when(
#' AVISITCD == "SCR" ~ -2,
#' AVISITCD == "BL" ~ 0,
#' grepl("W", AVISITCD) ~ as.numeric(gsub("[^0-9]*", "", AVISITCD)),
#' TRUE ~ as.numeric(NA)
#' ),
#' AVISITCD = factor(AVISITCD) %>% reorder(AVISITCDN),
#' TRTORD = dplyr::case_when(
#' TRTORD = case_when(
#' ARMCD == "ARM C" ~ 1,
#' ARMCD == "ARM B" ~ 2,
#' ARMCD == "ARM A" ~ 3
Expand All @@ -81,10 +82,10 @@
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- teal::init(
#' app <- init(
#' data = data,
#' modules = teal::modules(
#' teal.goshawk::tm_g_gh_density_distribution_plot(
#' modules = modules(
#' tm_g_gh_density_distribution_plot(
#' label = "Density Distribution Plot",
#' dataname = "ADLB",
#' param_var = "PARAMCD",
Expand Down
21 changes: 10 additions & 11 deletions R/tm_g_gh_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#' @export
#'
#' @examples
#'
#' # Example using ADaM structure analysis dataset.
#' data <- teal_data()
#' data <- within(data, {
Expand All @@ -66,25 +65,25 @@
#' "C: Combination" = "Combination"
#' )
#'
#' ADSL <- goshawk::rADSL
#' ADLB <- goshawk::rADLB
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' dplyr::mutate(
#' AVISITCD = dplyr::case_when(
#' mutate(
#' AVISITCD = case_when(
#' AVISIT == "SCREENING" ~ "SCR",
#' AVISIT == "BASELINE" ~ "BL",
#' grepl("WEEK", AVISIT) ~ paste("W", stringr::str_extract(AVISIT, "(?<=(WEEK ))[0-9]+")),
#' grepl("WEEK", AVISIT) ~ paste("W", str_extract(AVISIT, "(?<=(WEEK ))[0-9]+")),
#' TRUE ~ as.character(NA)
#' ),
#' AVISITCDN = dplyr::case_when(
#' AVISITCDN = case_when(
#' AVISITCD == "SCR" ~ -2,
#' AVISITCD == "BL" ~ 0,
#' grepl("W", AVISITCD) ~ as.numeric(gsub("[^0-9]*", "", AVISITCD)),
#' TRUE ~ as.numeric(NA)
#' ),
#' AVISITCD = factor(AVISITCD) %>% reorder(AVISITCDN),
#' TRTORD = dplyr::case_when(
#' TRTORD = case_when(
#' ARMCD == "ARM C" ~ 1,
#' ARMCD == "ARM B" ~ 2,
#' ARMCD == "ARM A" ~ 3
Expand All @@ -102,10 +101,10 @@
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- teal::init(
#' app <- init(
#' data = data,
#' modules = teal::modules(
#' teal.goshawk::tm_g_gh_lineplot(
#' modules = modules(
#' tm_g_gh_lineplot(
#' label = "Line Plot",
#' dataname = "ADLB",
#' param_var = "PARAMCD",
Expand Down
Loading

0 comments on commit fe05e76

Please sign in to comment.