diff --git a/RNA-seq/app.R b/RNA-seq/app.R index df4d48b7..f6cec4a2 100644 --- a/RNA-seq/app.R +++ b/RNA-seq/app.R @@ -6,9 +6,10 @@ options(shiny.useragg = FALSE) data <- teal_data() data <- within(data, { library(nestcolor) + library(random.cdisc.data) - ADSL <- random.cdisc.data::cadsl - ADTTE <- random.cdisc.data::cadtte %>% + ADSL <- radsl(seed = 1) + ADTTE <- radtte(ADSL, seed = 1) %>% dplyr::mutate(is_event = CNSR == 0) MAE <- hermes::multi_assay_experiment }) diff --git a/early-dev/app.R b/early-dev/app.R index 4fa39299..2dcfd8f2 100644 --- a/early-dev/app.R +++ b/early-dev/app.R @@ -6,13 +6,12 @@ options(shiny.useragg = FALSE) ## Data reproducible code ---- data <- teal_data() data <- within(data, { - library(random.cdisc.data) library(dplyr) library(nestcolor) # optional libraries library(sparkline) - ADSL <- radsl(seed = 1) + ADSL <- random.cdisc.data::cadsl # derive ADSL treatment duration .adsl_labels <- teal.data::col_labels(ADSL, fill = FALSE) @@ -31,7 +30,7 @@ data <- within(data, { droplevels() teal.data::col_labels(ADSL)[c(names(.adsl_labels))] <- .adsl_labels - ADAE <- radae(ADSL, seed = 1) + ADAE <- random.cdisc.data::cadae # derive common flags for AEs ADAE <- ADAE %>% @@ -63,7 +62,7 @@ data <- within(data, { AELLT = "Lowest Level Term" ) - ADCM <- radcm(ADSL, seed = 1) + ADCM <- random.cdisc.data::cadcm # process ADCM ADCM <- ADCM %>% @@ -76,7 +75,7 @@ data <- within(data, { AENDT = "Analysis End Date" ) - ADEX <- radex(ADSL, seed = 1) + ADEX <- random.cdisc.data::cadex # process ADEX ADEX <- ADEX %>% @@ -89,7 +88,7 @@ data <- within(data, { AENDT = "Analysis End Date" ) - ADTR <- radtr(ADSL, seed = 1) + ADTR <- random.cdisc.data::cadtr # process ADTR .adtr_labels <- teal.data::col_labels(ADTR, fill = FALSE) @@ -109,18 +108,18 @@ data <- within(data, { # process ADRS - ADRSSWIM <- radrs(ADSL, seed = 1) %>% + ADRSSWIM <- random.cdisc.data::cadrs %>% filter(PARAMCD == "OVRINV") %>% arrange(USUBJID) - ADRS <- radrs(ADSL, seed = 1) + ADRS <- random.cdisc.data::cadrs ADRS <- ADRS %>% filter(PARAMCD %in% c("BESRSPI", "INVET")) %>% mutate(ADT = as.Date(ADTM)) %>% droplevels() teal.data::col_labels(ADRS)["ADT"] <- "Analysis Date" - ADLB <- radlb(ADSL, seed = 1) + ADLB <- random.cdisc.data::cadlb # process ADLB ADLB <- ADLB %>% @@ -157,7 +156,6 @@ ADTRWF <- data[["ADTRWF"]] ADRSSWIM <- data[["ADRSSWIM"]] ADLB <- data[["ADLB"]] - fact_vars_asl <- names(Filter(isTRUE, sapply(ADSL, is.factor))) arm_vars <- c("ARMCD", "ARM", "ACTARMCD", "ACTARM", "EOSSTT") diff --git a/efficacy/app.R b/efficacy/app.R index f2ab560a..8d12e94a 100644 --- a/efficacy/app.R +++ b/efficacy/app.R @@ -6,12 +6,11 @@ options(shiny.useragg = FALSE) data <- teal_data() data <- within(data, { library(dplyr) - library(random.cdisc.data) library(nestcolor) # optional libraries library(sparkline) - ADSL <- radsl(seed = 1) + ADSL <- random.cdisc.data::cadsl .adsl_labels <- teal.data::col_labels(ADSL, fill = FALSE) .char_vars_asl <- names(Filter(isTRUE, sapply(ADSL, is.character))) @@ -31,14 +30,14 @@ data <- within(data, { teal.data::col_labels(ADSL) <- .adsl_labels - ADTTE <- radtte(ADSL, seed = 1) + ADTTE <- random.cdisc.data::cadtte - ADRS <- radrs(ADSL, seed = 1) + ADRS <- random.cdisc.data::cadrs .adrs_labels <- teal.data::col_labels(ADRS, fill = FALSE) ADRS <- filter(ADRS, PARAMCD == "BESRSPI" | AVISIT == "FOLLOW UP") teal.data::col_labels(ADRS) <- .adrs_labels - ADQS <- radqs(ADSL, seed = 1) + ADQS <- random.cdisc.data::cadqs .adqs_labels <- teal.data::col_labels(ADQS, fill = FALSE) ADQS <- ADQS %>% filter(ABLFL != "Y" & ABLFL2 != "Y") %>% @@ -61,7 +60,7 @@ ADSL <- data[["ADSL"]] ADTTE <- data[["ADTTE"]] ADRS <- data[["ADRS"]] ADQS <- data[["ADQS"]] -char_vars_asl <- data[["char_vars_asl"]] +char_vars_asl <- data[[".char_vars_asl"]] arm_vars <- c("ARMCD", "ARM") strata_vars <- c("STRATA1", "STRATA2") @@ -231,20 +230,8 @@ app <- init( ), tm_t_crosstable( "Cross Table", - x = data_extract_spec( - dataname = "ADSL", - select = select_spec( - choices = variable_choices(ADSL, fact_vars_asl_orig), - selected = fact_vars_asl_orig[1] - ) - ), - y = data_extract_spec( - dataname = "ADSL", - select = select_spec( - choices = variable_choices(ADSL, fact_vars_asl_orig), - selected = fact_vars_asl_orig[4] - ) - ) + x = picks(datasets("ADSL"), variables(fact_vars_asl_orig, 1L)), + y = picks(datasets("ADSL"), variables(fact_vars_asl_orig, 4L)) ), tm_t_coxreg( label = "Cox Reg", diff --git a/exploratory/app.R b/exploratory/app.R index cbe2c198..b2957f1b 100644 --- a/exploratory/app.R +++ b/exploratory/app.R @@ -7,6 +7,7 @@ options( ## Data reproducible code ---- data <- teal_data() data <- within(data, { + library(random.cdisc.data) library(dplyr) library(tidyr) library(ggExtra) @@ -25,9 +26,10 @@ data <- within(data, { library(colourpicker) library(sparkline) - ADSL <- random.cdisc.data::cadsl - ADRS <- random.cdisc.data::cadrs - ADLB <- random.cdisc.data::cadlb + + ADSL <- radsl(seed = 1) + ADRS <- radrs(ADSL, seed = 1) + ADLB <- radlb(ADSL, seed = 1) ADLBPCA <- ADLB %>% dplyr::select(USUBJID, STUDYID, SEX, ARMCD, AVAL, AVISIT, PARAMCD) %>% tidyr::pivot_wider( diff --git a/longitudinal/app.R b/longitudinal/app.R index 4f0955ac..b186611a 100644 --- a/longitudinal/app.R +++ b/longitudinal/app.R @@ -451,7 +451,7 @@ app <- teal::init( ), module( "User Guide", - server = function(input, output, session, datasets) {}, + server = function(input, output, session, data) {}, ui = function(id, ...) { div( h5( @@ -604,7 +604,7 @@ app <- teal::init( ), module( "Example Info Page", - server = function(input, output, session, datasets) {}, + server = function(input, output, session, data) {}, ui = function(id, ...) { div( h5(strong("Molecule:"), MOLECULE), diff --git a/python/app.R b/python/app.R index 91efe768..3c3f84d5 100644 --- a/python/app.R +++ b/python/app.R @@ -8,12 +8,19 @@ library(ggExtra) library(ggpmisc) library(sparkline) -options(shiny.useragg = FALSE) - data <- teal_data_module( ui = function(id) { ns <- NS(id) - actionButton(ns("submit"), label = "Load data") + tagList( + h5( + icon("fas fa-info-circle"), + "Click on the button below to load the IRIS dataset and run the Python code to generate the whitened dataset." + ), + p("This will take a few seconds to run the Python code and generate the whitened dataset."), + p("Once the data is loaded, you can explore the data using the modules on the teal app."), + hr(), + actionButton(ns("submit"), label = "Load data"), + ) }, server = function(id) { moduleServer(id, function(input, output, session, python_code) { @@ -28,7 +35,7 @@ library(reticulate) .python_dependencies <- c(\"pip\", \"numpy\", \"pandas\") # @linksto .py_dict .virtualenv_dir <- Sys.getenv(\"VIRTUALENV_NAME\", \"example_env_name\") # @linksto .py_dict .python_path <- Sys.getenv(\"PYTHON_PATH\") # @linksto .py_dict -if (.python_path == \"\") .python_path <- NULL +if (is.null(.python_path) || !nzchar(.python_path) || !file.exists(.python_path)) .python_path <- NULL reticulate::virtualenv_create( envname = .virtualenv_dir, python = .python_path ) # @linksto .py_dict @@ -38,7 +45,7 @@ reticulate::virtualenv_install( ignore_installed = TRUE ) # @linksto .py_dict reticulate::use_virtualenv(.virtualenv_dir, required = TRUE) # @linksto .py_dict -iris_raw <- cbind(id = seq_len(nrow(iris)), iris) # @linksto .py_dict +.iris_raw <- cbind(id = seq_len(nrow(iris)), iris) # @linksto .py_dict " ) @@ -49,7 +56,7 @@ iris_raw <- cbind(id = seq_len(nrow(iris)), iris) # @linksto .py_dict # python code needs to be un-indented .python_code <- " import pandas as pd -data = r.iris_raw +data = r['.iris_raw'] def svd_whiten(dat): import numpy as np X = np.matrix(dat) @@ -110,46 +117,31 @@ app <- teal::init( tm_variable_browser("Variable Browser"), tm_g_scatterplot( "Scatterplot", - x = data_extract_spec( - dataname = "IRIS", - select = select_spec( - label = "Select variable:", - choices = variable_choices("IRIS", c( + x = picks( + datasets("IRIS"), + variables( + c( "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Sepal.Length.whiten", "Sepal.Width.whiten", "Petal.Length.whiten", "Petal.Width.whiten" - )), - selected = "Petal.Length.whiten", - multiple = FALSE, - fixed = FALSE + ), + "Petal.Length.whiten" ) ), - y = data_extract_spec( - dataname = "IRIS", - select = select_spec( - label = "Select variable:", - choices = variable_choices("IRIS", c( + y = picks( + datasets("IRIS"), + variables( + c( "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Sepal.Length.whiten", "Sepal.Width.whiten", "Petal.Length.whiten", "Petal.Width.whiten" - )), - selected = "Petal.Width.whiten", - multiple = FALSE, - fixed = FALSE + ), + "Petal.Width.whiten" ) ), - color_by = data_extract_spec( - dataname = "IRIS", - select = select_spec( - label = "Select variable:", - choices = variable_choices("IRIS", c("Species")), - selected = "Species", - multiple = FALSE, - fixed = FALSE - ) - ) + color_by = picks(datasets("IRIS"), variables("Species", "Species", fixed = FALSE)) ) ) ) |>