-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat, wip: simple DEMO of tlg implementation
- Loading branch information
1 parent
fdf0454
commit a74289d
Showing
6 changed files
with
161 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#' TODO: Implement actual pkconc plot | ||
#' @export | ||
g_pkconc_ind <- function(data, scale = "lin", xlab = "test x lab", ylab = "test y lab") { | ||
p <- ggplot2::ggplot( | ||
data = data, | ||
mapping = aes(x = TIME, y = ADOSEDUR) | ||
) + | ||
ggplot2::geom_point() + | ||
ggplot2::labs( | ||
x = xlab, | ||
y = ylab | ||
) | ||
|
||
if (scale == "log") { | ||
p <- p + | ||
ggplot2::scale_y_log10() | ||
} | ||
|
||
p | ||
} | ||
|
||
#' @export | ||
g_pkconc_ind_lin <- function(data, ...) { | ||
g_pkconc_ind(data = data, scale = "lin", ...) | ||
} | ||
|
||
#' @export | ||
g_pkconc_ind_log <- function(data, ...) { | ||
g_pkconc_ind(data, scale = "log", ...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
tlg_plot_ui <- function(id) { | ||
ns <- NS(id) | ||
|
||
fluidRow( | ||
column( | ||
width = 9, | ||
plotOutput(ns("plot")) | ||
), | ||
column( | ||
width = 3, | ||
uiOutput(ns("options")) | ||
) | ||
) | ||
} | ||
|
||
tlg_plot_server <- function(id, render_plot, options = NULL, data = NULL) { | ||
moduleServer(id, function(input, output, session) { | ||
output$plot <- renderPlot({ | ||
do.call(render_plot, purrr::list_modify(list(data = data()), !!!reactiveValuesToList(opts))) | ||
}) | ||
|
||
opts <- reactiveValues() | ||
|
||
option_widgets <- lapply(options, function(opt_id) { | ||
observeEvent(input[[opt_id]], { | ||
opts[[opt_id]] <- input[[opt_id]] | ||
}) | ||
|
||
textInput( | ||
session$ns(opt_id), | ||
label = opt_id | ||
) | ||
}) | ||
|
||
output$options <- renderUI(option_widgets) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Configuration file containing TLG definitions. Each TLG should be a separate entry, with unique ID. | ||
# The TLG entry should have the following format: | ||
# id: | ||
# is_default: # true / false whether TLG should be included as default | ||
# type: # Graph / List / Table | ||
# dataset: # name of the dataset | ||
# pkid: # standarized id of the TLG | ||
# label: # short label to display as tab name | ||
# description: # longer descriptions, to be displayed in the order table | ||
# link: # link to the documentation of the TLG | ||
# fun: # name of the function exported by the package, responsible for generating TLG | ||
# opts: # options that can be passed as arguments to the function | ||
# - option1 # will generate input widgets for editing | ||
# - option2 # TODO: add ability to specify default value and type | ||
|
||
g_pkconc_ind_lin: | ||
is_default: true | ||
type: Graph | ||
dataset: ADPC | ||
pkid: pkcg01 | ||
label: pkcg01 - linear | ||
description: "Individual plots of concentrations vs. time (one plot per patient/subject) with linear scale" | ||
link: https://insightsengineering.github.io/tlg-catalog/stable/graphs/pharmacokinetic/pkcg01.html | ||
fun: g_pkconc_ind_lin | ||
opts: | ||
- xlab | ||
- ylab | ||
g_pkconc_ind_log: | ||
is_default: true | ||
type: Graph | ||
dataset: ADPC | ||
pkid: pkcg01 | ||
label: pkcg01 - log | ||
description: "Individual plots of concentrations vs. time (one plot per patient/subject) with log10 scale" | ||
link: https://insightsengineering.github.io/tlg-catalog/stable/graphs/pharmacokinetic/pkcg01.html | ||
fun: g_pkconc_ind_log | ||
opts: | ||
- xlab | ||
- ylab | ||
|