Skip to content

Examples

jwildfire edited this page Sep 9, 2021 · 1 revision

NOTE: These examples were copied and pasted from an early version of the app, and have not been tested in a recent build. Updates may be needed to get them to run.

Examples

safety_histogram

config <- list()
config[["description"]] <- "Test page"
config[["data"]] <- "https://raw.githubusercontent.com/RhoInc/data-library/master/data/clinical-trials/renderer-specific/adbds.csv"
config[["settings"]] <- safetyGraphics::generateSettings("sdtm", charts = "safetyhistogram")

data <- read.csv("https://raw.githubusercontent.com/RhoInc/data-library/master/data/clinical-trials/renderer-specific/adbds.csv",
    stringsAsFactors = FALSE, na.strings = c("NA", "")
)
settings <- config[["settings"]]
settings[["unit_col"]] <- "STRESU"
description <- config[["description"]]

source("R/safety_histogram.R")
p <- safety_histogram(data = data, settings = settings, description = config$description)
ggsave("examples/test_safety_histogram.png", plot = p, dpi = 300)

image

safety_outlier_explorer

devtools::install()
library(safetyCharts)
library(shiny)

data <- read.csv(
    "https://raw.githubusercontent.com/RhoInc/data-library/master/data/clinical-trials/renderer-specific/adbds.csv",
    stringsAsFactors = FALSE,
    na.strings = c("NA", "")
)

settings <- list(
    id_col = "USUBJID",
    value_col = "STRESN",
    measure_col = "TEST",
    visit_col = "VISIT",
    studyday_col = "DY",
    normal_col_low = "STNRLO",
    normal_col_high = "STNRHI",
    visitn_col = "VISITN",
    unit_col = "STRESU"
)

ui <- safetyOutlierExplorer_ui("soe")

server <- function(input, output, session) {
    callModule(
        safetyOutlierExplorer_server,
        "soe",
        params = reactive({
            list(data = data, settings = settings)
        })
    )
}

shinyApp(ui, server)

image image image

safety_outlier_explorer_module

devtools::install()
library(safetyCharts)
library(shiny)

data <- read.csv(
    "https://raw.githubusercontent.com/RhoInc/data-library/master/data/clinical-trials/renderer-specific/adbds.csv",
    stringsAsFactors = FALSE,
    na.strings = c("NA", "")
)

settings <- list(
    id_col = "USUBJID",
    value_col = "STRESN",
    measure_col = "TEST",
    visit_col = "VISIT",
    studyday_col = "DY",
    normal_col_low = "STNRLO",
    normal_col_high = "STNRHI",
    visitn_col = "VISITN",
    unit_col = "STRESU"
)

ui <- safetyOutlierExplorer_ui("soe")

server <- function(input, output, session) {
    callModule(
        safetyOutlierExplorer_server,
        "soe",
        params = reactive({
            list(data = data, settings = settings)
        })
    )
}

shinyApp(ui, server)

safety_results_over_time

config <- list()
config[["description"]] <- "Test page"
config[["data"]] <- "https://raw.githubusercontent.com/RhoInc/data-library/master/data/clinical-trials/renderer-specific/adbds.csv"
config[["settings"]] <- safetyGraphics::generateSettings("sdtm", charts = "safetyresultsovertime")


data <- read.csv(config[["data"]], stringsAsFactors = FALSE, na.strings = c("NA", ""))
settings <- config[["settings"]]
settings[["group_cols"]] <- c(
    "Site" = "SITEID", "Treatment Group" = "ARM",
    "Sex" = "SEX", "Race" = "RACE"
)
settings[["unit_col"]] <- "STRESU"

# manipulate SG settings
settings[["time_settings"]] <- list(
    value_col = settings[["visit_col"]],
    label = "Visit",
    order_col = settings[["visitn_col"]],
    order = NULL,
    rotate_tick_labels = TRUE,
    vertical_space = 100
)

## settings not in SG but needed
# settings[["measure_selected"]] <- "Albumin"
settings[["groups"]][["value_col"]] <- "ARM"
settings[["groups"]][["label"]] <- "Treatment arm"
# settings[["groups"]] <- list(value_col=NULL, label=NULL)
settings[["boxplots"]] <- TRUE
settings[["violins"]] <- FALSE
settings[["outliers"]] <- TRUE
settings[["axis"]] <- "log"

source("R/safety_results_over_time.R")

p <- safety_results_over_time(data = data, settings = settings, description = config$description)

ggsave("examples/test_safety_results_over_time.png", plot = p, height = 4, width = 6.5, dpi = 300)

image

Clone this wiki locally