From 599af37cb1f1951e15b7a27a26ddc0c7517e9177 Mon Sep 17 00:00:00 2001 From: BFalquet Date: Thu, 22 Aug 2024 15:29:24 +0200 Subject: [PATCH 1/5] add library --- R/adtteSpec.R | 1 + man/h_km_mae_to_adtte.Rd | 1 + 2 files changed, 2 insertions(+) diff --git a/R/adtteSpec.R b/R/adtteSpec.R index 11f0784a..146bbd76 100644 --- a/R/adtteSpec.R +++ b/R/adtteSpec.R @@ -16,6 +16,7 @@ #' #' @export #' @examples +#' library(dplyr) #' mae <- hermes::multi_assay_experiment #' adtte <- teal.modules.hermes::rADTTE %>% #' dplyr::mutate(CNSR = as.logical(CNSR)) diff --git a/man/h_km_mae_to_adtte.Rd b/man/h_km_mae_to_adtte.Rd index 92ebf0df..e80d32dd 100644 --- a/man/h_km_mae_to_adtte.Rd +++ b/man/h_km_mae_to_adtte.Rd @@ -43,6 +43,7 @@ The final gene column names can start with a different string than the original gene IDs (or labels), in particular white space and colons are removed. } \examples{ +library(dplyr) mae <- hermes::multi_assay_experiment adtte <- teal.modules.hermes::rADTTE \%>\% dplyr::mutate(CNSR = as.logical(CNSR)) From ab3dc52e56e56374411011673633659843d6a909 Mon Sep 17 00:00:00 2001 From: BFalquet Date: Tue, 27 Aug 2024 15:26:06 +0200 Subject: [PATCH 2/5] add tealdata prefix --- R/forestplot.R | 2 +- man/tm_g_forest_tte.Rd | 154 ----------------------------------------- 2 files changed, 1 insertion(+), 155 deletions(-) diff --git a/R/forestplot.R b/R/forestplot.R index fd013fb9..52a74d3f 100644 --- a/R/forestplot.R +++ b/R/forestplot.R @@ -19,7 +19,7 @@ #' }) #' datanames <- c("ADTTE", "MAE") #' datanames(data) <- datanames -#' join_keys(data)["ADTTE", "ADTTE"] <- c("STUDYID", "USUBJID", "PARAMCD") +#' teal.data::join_keys(data)["ADTTE", "ADTTE"] <- c("STUDYID", "USUBJID", "PARAMCD") #' #' app <- init( #' data = data, diff --git a/man/tm_g_forest_tte.Rd b/man/tm_g_forest_tte.Rd index 556368cf..e69de29b 100644 --- a/man/tm_g_forest_tte.Rd +++ b/man/tm_g_forest_tte.Rd @@ -1,154 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/forestplot.R -\name{tm_g_forest_tte} -\alias{tm_g_forest_tte} -\alias{ui_g_forest_tte} -\alias{srv_g_forest_tte} -\alias{sample_tm_g_forest_tte} -\title{Teal Module for Survival Forest Plot} -\usage{ -tm_g_forest_tte( - label, - adtte_name, - mae_name, - adtte_vars = list(aval = "AVAL", is_event = "is_event", paramcd = "PARAMCD", usubjid = - "USUBJID", avalu = "AVALU"), - exclude_assays = "counts", - summary_funs = list(Mean = colMeans, Median = matrixStats::colMedians, Max = - matrixStats::colMaxs), - pre_output = NULL, - post_output = NULL, - plot_height = c(600L, 200L, 2000L), - plot_width = c(1360L, 500L, 2000L), - .test = FALSE -) - -ui_g_forest_tte( - id, - adtte_name, - mae_name, - summary_funs, - pre_output, - post_output, - .test = FALSE -) - -srv_g_forest_tte( - id, - data, - filter_panel_api, - reporter, - adtte_name, - mae_name, - adtte_vars, - exclude_assays, - summary_funs, - plot_height, - plot_width, - .test = FALSE -) - -sample_tm_g_forest_tte(.test = FALSE) -} -\arguments{ -\item{label}{(\code{string})\cr -menu item label of the module in the teal app.} - -\item{adtte_name}{(\code{string})\cr -name of the \code{ADTTE} dataset.} - -\item{mae_name}{(\code{string})\cr -name of the MAE data used in the teal module.} - -\item{adtte_vars}{(named \code{list} of \code{string})\cr -names of the variables to use in the \code{ADTTE} dataset. It should comprise elements: -\itemize{ -\item \code{aval}: the numeric time-to-event variable. -\item \code{avalu}: the variable holding the unit of \code{aval}. -\item \code{is_event}: the logical event variable. It needs to be \code{TRUE} -when there was an observed event, and \code{FALSE} if the time is censored without -observed event. -\item \code{paramcd}: the character or factor parameter code variable, defining the -type of time-to-event for selection in the module. -\item \code{usubjid}: the subject ID variable. -}} - -\item{exclude_assays}{(\code{character})\cr -names of the assays which should not be included in choices in the teal module.} - -\item{summary_funs}{(named \code{list} of functions or \code{NULL})\cr functions which can be used -in the the gene signatures. For modules that support also multiple genes without -summary, \code{NULL} can be included to not summarize the genes but provide all of them.} - -\item{pre_output}{(\code{shiny.tag} or \code{NULL})\cr -placed before the output to put the output into context (for example a title).} - -\item{post_output}{(\code{shiny.tag} or \code{NULL})\cr -placed after the output to put the output into context (for example the \code{\link[shiny:helpText]{shiny::helpText()}} -elements can be useful).} - -\item{plot_height}{(\code{list})\cr list of integers to set the default, minimum, -and maximum plot height.} - -\item{plot_width}{(\code{list})\cr list of integers to set the default, minimum, -and maximum plot width.} - -\item{.test}{(\code{flag})\cr whether to display the internal structure of the plot for testing purposes.} - -\item{id}{(\code{string}) the shiny module id.} - -\item{data}{(\code{reactive})\cr -\verb{reactive()} holding all the data sets provided -during app initialization after going through the filters.} - -\item{filter_panel_api}{(\code{FilterPanelAPI})\cr object describing the actual filter panel API.} - -\item{reporter}{(\code{Reporter}) object} -} -\value{ -Shiny module to be used in the teal app. -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} - -This module provides an interactive survival forest plot. -} -\section{Functions}{ -\itemize{ -\item \code{ui_g_forest_tte()}: sets up the user interface. - -\item \code{srv_g_forest_tte()}: sets up the server with reactive graph. - -\item \code{sample_tm_g_forest_tte()}: sample module function. - -}} -\examples{ -data <- teal_data() -data <- within(data, { - ADTTE <- teal.modules.hermes::rADTTE \%>\% - dplyr::mutate(is_event = .data$CNSR == 0) - MAE <- hermes::multi_assay_experiment -}) -datanames <- c("ADTTE", "MAE") -datanames(data) <- datanames -join_keys(data)["ADTTE", "ADTTE"] <- c("STUDYID", "USUBJID", "PARAMCD") - -app <- init( - data = data, - modules = modules( - tm_g_forest_tte( - label = "forestplot", - adtte_name = "ADTTE", - mae_name = "MAE" - ) - ) -) -if (interactive()) { - shinyApp(app$ui, app$server) -} - -# Alternatively you can run the sample module with this function call: -if (interactive()) { - sample_tm_g_forest_tte() -} -} From fd4927f0ef71de4cc86de10b2add1f68fba78893 Mon Sep 17 00:00:00 2001 From: BFalquet Date: Tue, 27 Aug 2024 15:55:01 +0200 Subject: [PATCH 3/5] document --- man/tm_g_forest_tte.Rd | 154 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/man/tm_g_forest_tte.Rd b/man/tm_g_forest_tte.Rd index e69de29b..805009ba 100644 --- a/man/tm_g_forest_tte.Rd +++ b/man/tm_g_forest_tte.Rd @@ -0,0 +1,154 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/forestplot.R +\name{tm_g_forest_tte} +\alias{tm_g_forest_tte} +\alias{ui_g_forest_tte} +\alias{srv_g_forest_tte} +\alias{sample_tm_g_forest_tte} +\title{Teal Module for Survival Forest Plot} +\usage{ +tm_g_forest_tte( + label, + adtte_name, + mae_name, + adtte_vars = list(aval = "AVAL", is_event = "is_event", paramcd = "PARAMCD", usubjid = + "USUBJID", avalu = "AVALU"), + exclude_assays = "counts", + summary_funs = list(Mean = colMeans, Median = matrixStats::colMedians, Max = + matrixStats::colMaxs), + pre_output = NULL, + post_output = NULL, + plot_height = c(600L, 200L, 2000L), + plot_width = c(1360L, 500L, 2000L), + .test = FALSE +) + +ui_g_forest_tte( + id, + adtte_name, + mae_name, + summary_funs, + pre_output, + post_output, + .test = FALSE +) + +srv_g_forest_tte( + id, + data, + filter_panel_api, + reporter, + adtte_name, + mae_name, + adtte_vars, + exclude_assays, + summary_funs, + plot_height, + plot_width, + .test = FALSE +) + +sample_tm_g_forest_tte(.test = FALSE) +} +\arguments{ +\item{label}{(\code{string})\cr +menu item label of the module in the teal app.} + +\item{adtte_name}{(\code{string})\cr +name of the \code{ADTTE} dataset.} + +\item{mae_name}{(\code{string})\cr +name of the MAE data used in the teal module.} + +\item{adtte_vars}{(named \code{list} of \code{string})\cr +names of the variables to use in the \code{ADTTE} dataset. It should comprise elements: +\itemize{ +\item \code{aval}: the numeric time-to-event variable. +\item \code{avalu}: the variable holding the unit of \code{aval}. +\item \code{is_event}: the logical event variable. It needs to be \code{TRUE} +when there was an observed event, and \code{FALSE} if the time is censored without +observed event. +\item \code{paramcd}: the character or factor parameter code variable, defining the +type of time-to-event for selection in the module. +\item \code{usubjid}: the subject ID variable. +}} + +\item{exclude_assays}{(\code{character})\cr +names of the assays which should not be included in choices in the teal module.} + +\item{summary_funs}{(named \code{list} of functions or \code{NULL})\cr functions which can be used +in the the gene signatures. For modules that support also multiple genes without +summary, \code{NULL} can be included to not summarize the genes but provide all of them.} + +\item{pre_output}{(\code{shiny.tag} or \code{NULL})\cr +placed before the output to put the output into context (for example a title).} + +\item{post_output}{(\code{shiny.tag} or \code{NULL})\cr +placed after the output to put the output into context (for example the \code{\link[shiny:helpText]{shiny::helpText()}} +elements can be useful).} + +\item{plot_height}{(\code{list})\cr list of integers to set the default, minimum, +and maximum plot height.} + +\item{plot_width}{(\code{list})\cr list of integers to set the default, minimum, +and maximum plot width.} + +\item{.test}{(\code{flag})\cr whether to display the internal structure of the plot for testing purposes.} + +\item{id}{(\code{string}) the shiny module id.} + +\item{data}{(\code{reactive})\cr +\verb{reactive()} holding all the data sets provided +during app initialization after going through the filters.} + +\item{filter_panel_api}{(\code{FilterPanelAPI})\cr object describing the actual filter panel API.} + +\item{reporter}{(\code{Reporter}) object} +} +\value{ +Shiny module to be used in the teal app. +} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} + +This module provides an interactive survival forest plot. +} +\section{Functions}{ +\itemize{ +\item \code{ui_g_forest_tte()}: sets up the user interface. + +\item \code{srv_g_forest_tte()}: sets up the server with reactive graph. + +\item \code{sample_tm_g_forest_tte()}: sample module function. + +}} +\examples{ +data <- teal_data() +data <- within(data, { + ADTTE <- teal.modules.hermes::rADTTE \%>\% + dplyr::mutate(is_event = .data$CNSR == 0) + MAE <- hermes::multi_assay_experiment +}) +datanames <- c("ADTTE", "MAE") +datanames(data) <- datanames +teal.data::join_keys(data)["ADTTE", "ADTTE"] <- c("STUDYID", "USUBJID", "PARAMCD") + +app <- init( + data = data, + modules = modules( + tm_g_forest_tte( + label = "forestplot", + adtte_name = "ADTTE", + mae_name = "MAE" + ) + ) +) +if (interactive()) { + shinyApp(app$ui, app$server) +} + +# Alternatively you can run the sample module with this function call: +if (interactive()) { + sample_tm_g_forest_tte() +} +} From c9995cba5cb418b631b707073d62623707306abe Mon Sep 17 00:00:00 2001 From: Pawel Rucki <12943682+pawelru@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:28:00 +0200 Subject: [PATCH 4/5] add library upfront --- R/forestplot.R | 6 ++++-- man/tm_g_forest_tte.Rd | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/R/forestplot.R b/R/forestplot.R index 52a74d3f..31d39d5a 100644 --- a/R/forestplot.R +++ b/R/forestplot.R @@ -11,15 +11,17 @@ #' @export #' #' @examples +#' library(dplyr) +#' #' data <- teal_data() #' data <- within(data, { #' ADTTE <- teal.modules.hermes::rADTTE %>% -#' dplyr::mutate(is_event = .data$CNSR == 0) +#' mutate(is_event = .data$CNSR == 0) #' MAE <- hermes::multi_assay_experiment #' }) #' datanames <- c("ADTTE", "MAE") #' datanames(data) <- datanames -#' teal.data::join_keys(data)["ADTTE", "ADTTE"] <- c("STUDYID", "USUBJID", "PARAMCD") +#' join_keys(data)["ADTTE", "ADTTE"] <- c("STUDYID", "USUBJID", "PARAMCD") #' #' app <- init( #' data = data, diff --git a/man/tm_g_forest_tte.Rd b/man/tm_g_forest_tte.Rd index 805009ba..f7b1c9a3 100644 --- a/man/tm_g_forest_tte.Rd +++ b/man/tm_g_forest_tte.Rd @@ -123,15 +123,17 @@ This module provides an interactive survival forest plot. }} \examples{ +library(dplyr) + data <- teal_data() data <- within(data, { ADTTE <- teal.modules.hermes::rADTTE \%>\% - dplyr::mutate(is_event = .data$CNSR == 0) + mutate(is_event = .data$CNSR == 0) MAE <- hermes::multi_assay_experiment }) datanames <- c("ADTTE", "MAE") datanames(data) <- datanames -teal.data::join_keys(data)["ADTTE", "ADTTE"] <- c("STUDYID", "USUBJID", "PARAMCD") +join_keys(data)["ADTTE", "ADTTE"] <- c("STUDYID", "USUBJID", "PARAMCD") app <- init( data = data, From b3077440c333e16d2eea4263d938a16c0994ce53 Mon Sep 17 00:00:00 2001 From: Pawel Rucki <12943682+pawelru@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:45:09 +0200 Subject: [PATCH 5/5] add dplyr to more examples --- R/adtteSpec.R | 2 ++ R/forestplot.R | 2 +- R/km.R | 2 ++ man/adtteSpecServer.Rd | 2 ++ man/tm_g_forest_tte.Rd | 2 +- man/tm_g_km.Rd | 2 ++ 6 files changed, 10 insertions(+), 2 deletions(-) diff --git a/R/adtteSpec.R b/R/adtteSpec.R index 146bbd76..ea09b999 100644 --- a/R/adtteSpec.R +++ b/R/adtteSpec.R @@ -149,6 +149,8 @@ adtteSpecInput <- function(inputId, # nolint #' @export #' #' @examples +#' library(dplyr) +#' #' ui <- function(id) { #' ns <- NS(id) #' diff --git a/R/forestplot.R b/R/forestplot.R index 31d39d5a..293378cb 100644 --- a/R/forestplot.R +++ b/R/forestplot.R @@ -16,7 +16,7 @@ #' data <- teal_data() #' data <- within(data, { #' ADTTE <- teal.modules.hermes::rADTTE %>% -#' mutate(is_event = .data$CNSR == 0) +#' dplyr::mutate(is_event = .data$CNSR == 0) #' MAE <- hermes::multi_assay_experiment #' }) #' datanames <- c("ADTTE", "MAE") diff --git a/R/km.R b/R/km.R index 8ba5fadd..f52eefc0 100644 --- a/R/km.R +++ b/R/km.R @@ -12,6 +12,8 @@ #' @export #' #' @examples +#' library(dplyr) +#' #' data <- teal_data() #' data <- within(data, { #' ADTTE <- teal.modules.hermes::rADTTE %>% diff --git a/man/adtteSpecServer.Rd b/man/adtteSpecServer.Rd index 9df84670..ebeb23dd 100644 --- a/man/adtteSpecServer.Rd +++ b/man/adtteSpecServer.Rd @@ -74,6 +74,8 @@ and experiment, as numeric and factor columns. The factor column is created by b the numeric column according to the quantile cutoffs specified in \code{probs}. } \examples{ +library(dplyr) + ui <- function(id) { ns <- NS(id) diff --git a/man/tm_g_forest_tte.Rd b/man/tm_g_forest_tte.Rd index f7b1c9a3..c05f6d36 100644 --- a/man/tm_g_forest_tte.Rd +++ b/man/tm_g_forest_tte.Rd @@ -128,7 +128,7 @@ library(dplyr) data <- teal_data() data <- within(data, { ADTTE <- teal.modules.hermes::rADTTE \%>\% - mutate(is_event = .data$CNSR == 0) + dplyr::mutate(is_event = .data$CNSR == 0) MAE <- hermes::multi_assay_experiment }) datanames <- c("ADTTE", "MAE") diff --git a/man/tm_g_km.Rd b/man/tm_g_km.Rd index 76f52305..cb0d9c29 100644 --- a/man/tm_g_km.Rd +++ b/man/tm_g_km.Rd @@ -114,6 +114,8 @@ This teal module produces a grid style \code{Kaplan-Meier} plot for data with }} \examples{ +library(dplyr) + data <- teal_data() data <- within(data, { ADTTE <- teal.modules.hermes::rADTTE \%>\%