-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add two example apps to showcase DDL and Custom transformation #177
Open
vedhav
wants to merge
15
commits into
dev
Choose a base branch
from
669_insertUI@dev
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a2b260b
feat: add two example apps to showcase DDL and Custom transformation
vedhav e249509
fix: skip stable deployments for the two new apps
vedhav 08bee69
fix: alternative logic to skip the action
vedhav ff83143
Update custom-transform/app.R
vedhav 7ed2cc5
Update custom-transform/app.R
vedhav 984c15f
Update custom-transform/app.R
vedhav 321879d
chore: fix lint errors
vedhav 7869599
Merge remote-tracking branch 'origin/dev' into 669_insertUI@dev
vedhav 329e5fb
chore: update renv.lock and skip stable deployments for new apps
vedhav 929f2df
chore: chante checkout branch
vedhav 91d4179
chore: use the proper channel name to skip
vedhav 4b2f5a2
chore: update renv.lock
vedhav 563be2e
fix: remove dplyr pipe
vedhav b450042
fix: add shinyvalidate as a dependency
vedhav fdc6e4b
Merge branch 'dev' into 669_insertUI@dev
vedhav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
source("renv/activate.R") |
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,20 @@ | ||
|
||
<!-- Generated by app_readme_template.Rmd and generate_app_readme.R: do not edit by hand--> | ||
|
||
# custom-transform app | ||
|
||
### Run the app yourself | ||
|
||
source("https://raw.github.com/insightsengineering/teal.gallery/main/_internal/utils/sourceme.R") | ||
|
||
# Run the app | ||
restore_and_run("custom-transform", package_repo = "https://insightsengineering.r-universe.dev") | ||
|
||
### View the deployed app | ||
|
||
Deployed app: | ||
<https://genentech.shinyapps.io/NEST_custom-transform_stable> | ||
|
||
### Preview the app | ||
|
||
![](../_internal/quarto/assets/img/custom-transform.gif)<!-- --> |
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,132 @@ | ||
library(teal) | ||
|
||
my_transformers <- list( | ||
teal_transform_module( | ||
label = "Keep first n-observations from IRIS", | ||
ui = function(id) { | ||
ns <- NS(id) | ||
div( | ||
checkboxInput(ns("check"), label = "Toggle `head(iris)`"), | ||
) | ||
}, | ||
server = function(id, data) { | ||
moduleServer(id, function(input, output, session) { | ||
eventReactive(input$check, { | ||
req(data()) | ||
if (input$check) { | ||
within(data(), iris <- head(iris, 6)) | ||
} else { | ||
data() | ||
} | ||
}) | ||
}) | ||
} | ||
), | ||
teal_transform_module( | ||
label = "Merge datasets to get ANL", | ||
ui = function(id) { | ||
ns <- NS(id) | ||
tagList( | ||
div("Choose the two datasets to merge:"), | ||
teal.widgets::optionalSelectInput(ns("merge_a"), "Merge A", choices = NULL), | ||
teal.widgets::optionalSelectInput(ns("merge_b"), "Merge B", choices = NULL) | ||
) | ||
}, | ||
server = function(id, data) { | ||
checkmate::assert_class(data, "reactive") | ||
moduleServer(id, function(input, output, session) { | ||
iv <- shinyvalidate::InputValidator$new() | ||
iv$add_rule("merge_a", shinyvalidate::sv_required("Please select dataset A")) | ||
iv$add_rule("merge_b", shinyvalidate::sv_required("Please select dataset B")) | ||
iv$enable() | ||
|
||
reactive_datanames <- reactive({ | ||
req(data()) | ||
teal.data::datanames(data()) | ||
}) | ||
observeEvent(reactive_datanames(), { | ||
selected_a <- isolate(input$merge_a) | ||
if (identical(selected_a, "")) selected_a <- restoreInput(session$ns("merge_a"), NULL) | ||
teal.widgets::updateOptionalSelectInput( | ||
session = session, | ||
inputId = "merge_a", | ||
choices = reactive_datanames(), | ||
selected = restoreInput(session$ns("merge_a"), selected_a) | ||
) | ||
|
||
selected_b <- isolate(input$merge_b) | ||
if (identical(selected_b, "")) selected <- restoreInput(session$ns("merge_b"), NULL) | ||
teal.widgets::updateOptionalSelectInput( | ||
session = session, | ||
inputId = "merge_b", | ||
choices = reactive_datanames(), | ||
selected = restoreInput(session$ns("merge_b"), selected_b) | ||
) | ||
}) | ||
|
||
reactive({ | ||
req(input$merge_a, input$merge_b) | ||
new_data <- within( | ||
data(), | ||
ANL <- dplyr::left_join(merge_a, merge_b), | ||
merge_a = as.name(input$merge_a), | ||
merge_b = as.name(input$merge_b) | ||
) | ||
teal.data::datanames(new_data) <- c(teal.data::datanames(new_data), "ANL") | ||
new_data | ||
}) | ||
}) | ||
} | ||
) | ||
) | ||
|
||
data <- teal_data() | ||
data <- within(data, { | ||
ADSL <- teal.data::rADSL | ||
ADTTE <- teal.data::rADTTE | ||
iris <- iris | ||
CO2 <- CO2 | ||
factors <- names(Filter(isTRUE, vapply(CO2, is.factor, logical(1L)))) | ||
CO2[factors] <- lapply(CO2[factors], as.character) | ||
}) | ||
join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADTTE")] | ||
teal.data::datanames(data) <- c("ADSL", "ADTTE", "iris", "CO2") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no |
||
|
||
nest_logo <- "https://raw.githubusercontent.com/insightsengineering/hex-stickers/main/PNG/nest.png" | ||
app_source <- "https://github.com/insightsengineering/teal.gallery/tree/main/basic-teal" | ||
gh_issues_page <- "https://github.com/insightsengineering/teal.gallery/issues" | ||
|
||
header <- tags$span( | ||
style = "display: flex; align-items: center; justify-content: space-between; margin: 10px 0 10px 0;", | ||
tags$span("Teal app with custom transform", style = "font-size: 30px;"), | ||
tags$span( | ||
style = "display: flex; align-items: center;", | ||
tags$img(src = nest_logo, alt = "NEST logo", height = "45px", style = "margin-right:10px;"), | ||
tags$span(style = "font-size: 24px;", "NEST @ Roche") | ||
) | ||
) | ||
|
||
footer <- tags$p( | ||
"This teal app is brought to you by the NEST Team at Roche/Genentech. | ||
For more information, please visit:", | ||
tags$a(href = app_source, target = "_blank", "Source Code"), ", ", | ||
tags$a(href = gh_issues_page, target = "_blank", "Report Issues") | ||
) | ||
gogonzo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
app <- init( | ||
data = data, | ||
filter = teal_slices( | ||
teal_slice("ADSL", "SEX"), | ||
teal_slice("ADSL", "AGE", selected = c(18L, 65L)) | ||
), | ||
modules = modules( | ||
example_module("Module with transformations", transformers = my_transformers), | ||
example_module("Module with only iris transformation", transformers = my_transformers[1]), | ||
gogonzo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
example_module("Module with no transformations") | ||
), | ||
title = build_app_title("Custom Transform Teal App", nest_logo), | ||
header = header, | ||
footer = footer | ||
) | ||
|
||
shinyApp(app$ui, app$server) |
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,16 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX | ||
|
||
AutoAppendNewline: Yes | ||
StripTrailingWhitespace: Yes |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should revert the branch checkout before merging. This was changed just to test the deployment.