This defines the server part for the ADTTE specification. The resulting data
set binned_adtte_subset contains the subset of ADTTE selected by the time-to-event
endpoint, joined together with the gene information extracted from specified assay
and experiment, as numeric and factor columns. The factor column is created by binning
the numeric column according to the quantile cutoffs specified in probs.
Usage
adtteSpecServer(
id,
datasets,
mae_name,
adtte_name,
adtte_vars,
experiment_data,
experiment_name,
assay,
genes,
probs
)Arguments
- id
(
string) the shiny module id.- datasets
(
Datasets)
teal specific argument which is automatically passed to the UI and server functions, holding all the data sets provided in the app initialization.- mae_name
(
string)
name of the MAE data used in the teal module.- adtte_name
(
string)
name of the ADTTE dataset.- adtte_vars
-
(named
listofstring)
names of the variables to use in the ADTTE dataset. It should comprise elements:aval: the numeric time-to-event variable.avalu: the variable holding the unit ofaval.is_event: the logical event variable. It needs to beTRUEwhen there was an observed event, andFALSEif the time is censored without observed event.paramcd: the character or factor parameter code variable, defining the type of time-to-event for selection in the module.usubjid: the subject ID variable.
- experiment_data
(reactive
AnyHermesData)
input experiment.- experiment_name
(reactive
string)
name of the input experiment.- assay
(reactive
string)
name of the assay.- genes
(reactive
GeneSpec)
gene specification.- probs
(reactive
numeric)
probabilities to bin the gene or gene signature into.
Value
List with the following elements:
binned_adtte_subset: reactive containing the joined ADTTE and gene data.gene_col: reactive containing the string with the column name of the original numeric gene variable.gene_factor: string with the variable name for the binned gene data.time_unit: reactive string with the time unit for the current subset.
See also
adtteSpecInput() for the module UI.
Examples
ui <- function(id,
datasets) {
ns <- NS(id)
teal.widgets::standard_layout(
encoding = div(
experimentSpecInput(ns("experiment"), datasets = datasets, mae_name = "MAE"),
assaySpecInput(ns("assay")),
geneSpecInput(ns("genes"), funs = list(Mean = colMeans)),
adtteSpecInput(ns("adtte"))
),
output = verbatimTextOutput(ns("summary"))
)
}
server <- function(id, datasets) {
moduleServer(id, function(input, output, session) {
experiment <- experimentSpecServer(
"experiment",
datasets = datasets,
mae_name = "MAE"
)
assay <- assaySpecServer(
"assay",
assays = experiment$assays
)
genes <- geneSpecServer(
"genes",
funs = list(Mean = colMeans),
gene_choices = experiment$genes
)
adtte <- adtteSpecServer(
"adtte",
datasets = datasets,
adtte_name = "ADTTE",
mae_name = "MAE",
adtte_vars = list(
aval = "AVAL",
avalu = "AVALU",
is_event = "is_event",
paramcd = "PARAMCD",
usubjid = "USUBJID"
),
experiment_data = experiment$data,
experiment_name = experiment$name,
assay = assay,
genes = genes,
probs = reactive({
0.5
})
)
output$summary <- renderPrint({
binned_adtte_subset <- adtte$binned_adtte_subset()
summary(binned_adtte_subset)
})
})
}
my_app <- function() {
mae <- hermes::multi_assay_experiment
adtte <- scda::synthetic_cdisc_data("rcd_2021_07_07")$adtte %>%
dplyr::mutate(is_event = .data$CNSR == 0)
data <- teal_data(
dataset(
"ADTTE",
adtte,
code = 'adtte <- scda::synthetic_cdisc_data("rcd_2021_07_07")$adtte %>%
dplyr::mutate(is_event = .data$CNSR == 0)'
),
dataset("MAE", mae)
)
app <- init(
data = data,
modules = modules(
module(
label = "adtteSpec example",
server = server,
ui = ui,
filters = "all"
)
)
)
shinyApp(app$ui, app$server)
}
if (interactive()) {
my_app()
}