Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from ohdsi-studies/develop
added shiny, hot fix for cohort 100 error
- Loading branch information
Showing
8 changed files
with
195 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
^LICENSE\.md$ | ||
^\.github$ | ||
^README\.Rmd$ | ||
^rsconnect$ |
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
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,142 @@ | ||
#' `runAlopeciaShiny()` launches an app to visualise TreatmentPatterns results for the alopecia study. | ||
#' | ||
#' @param resultsFolder Define the results folder path in character. | ||
#' | ||
#' @import shinythemes shinydashboard shinycssloaders shinyWidgets TreatmentPatterns here | ||
#' @importFrom readr read_csv | ||
#' @importFrom DT dataTableOutput renderDataTable | ||
#' @importFrom stringr str_detect | ||
#' @importFrom shiny shinyApp h4 uiOutput | ||
#' @export | ||
runShinyAlopecia <- function(resultsFolder = here::here("results")) { | ||
ui <- dashboardPage( | ||
dashboardHeader(title = "Menu"), | ||
dashboardSidebar( | ||
sidebarMenu( | ||
menuItem( | ||
text = "Home", | ||
tabName = "home" | ||
), | ||
menuItem( | ||
text = "TreatmentPathways", | ||
tabName = "data" | ||
) | ||
) | ||
), | ||
dashboardBody( | ||
tabItems( | ||
tabItem( | ||
tabName = "home", | ||
h4("Analytic software to perform large-scale distributed analysis of patients with Alopecia as part of the EHDEN study-athon.") | ||
), | ||
tabItem( | ||
tabName = "data", | ||
uiOutput("dataTable") | ||
) | ||
) | ||
) | ||
) | ||
|
||
server <- function(input, output, session) { | ||
## TreatmentPatterns ---- | ||
resultsPathways <- reactive({ | ||
databases <- list.files(resultsFolder, full.names = TRUE) | ||
resultsPathways <- list() | ||
for (i in seq(1:length(databases))) { | ||
# i <- 1 | ||
targetCohorts <- list.files(databases[i], full.names = TRUE) | ||
targetCohortNumber <- list.files(databases[i]) | ||
for (v in seq(1:length(targetCohorts))) { | ||
# v <- 1 | ||
pathwaysFiles <- list.files(targetCohorts[v], full.names = TRUE) | ||
file_metaData <- pathwaysFiles[stringr::str_detect(pathwaysFiles, "metadata")] | ||
cdm_name <- readr::read_csv(file_metaData, show_col_types = FALSE) %>% | ||
pull(cdmSourceName) | ||
file_TreatmentPathways <- pathwaysFiles[stringr::str_detect(pathwaysFiles, "treatmentPathways")] | ||
resultsPathways <- bind_rows(resultsPathways, readr::read_csv(file_TreatmentPathways, show_col_types = FALSE) %>% | ||
mutate(cdm_name = cdm_name, | ||
targetCohort = targetCohortNumber[v])) | ||
} | ||
} | ||
return(resultsPathways) | ||
}) | ||
|
||
output$dataTable <- renderUI({ | ||
tagList( | ||
pickerInput( | ||
inputId = "dataDatabase", | ||
label = "Data partner", | ||
choices = unique(resultsPathways()$cdm_name), | ||
selected = unique(resultsPathways()$cdm_name)[1], | ||
multiple = FALSE | ||
), | ||
pickerInput( | ||
inputId = "dataTargetCohort", | ||
label = "Target Cohort", | ||
choices = unique(resultsPathways()$targetCohort), | ||
selected = unique(resultsPathways()$targetCohort)[1], | ||
multiple = FALSE | ||
), | ||
pickerInput( | ||
inputId = "dataSex", | ||
label = "Sex", | ||
choices = unique(resultsPathways()$sex), | ||
selected = unique(resultsPathways()$sex)[1], | ||
multiple = FALSE | ||
), | ||
pickerInput( | ||
inputId = "dataAge", | ||
label = "Age", | ||
choices = unique(resultsPathways()$age), | ||
selected = unique(resultsPathways()$age)[1], | ||
multiple = FALSE | ||
), | ||
pickerInput( | ||
inputId = "dataIndex", | ||
label = "Index year", | ||
choices = unique(resultsPathways()$indexYear), | ||
selected = unique(resultsPathways()$indexYear)[1], | ||
multiple = FALSE | ||
), | ||
tabsetPanel( | ||
type = "tabs", | ||
tabPanel( | ||
"Data", | ||
DT::dataTableOutput(outputId = "treatmentPathways") | ||
), | ||
tabPanel( | ||
"Sunburst Plot", | ||
uiOutput(outputId = "sunburstPlot") | ||
) | ||
# , | ||
# tabPanel( | ||
# "Sankey Diagram", | ||
# uiOutput(outputId = "sankeyDiagram") | ||
# ) | ||
) | ||
) | ||
}) | ||
|
||
pathwaysData <- reactive({ | ||
resultsPathways() %>% | ||
filter(cdm_name == input$dataDatabase, | ||
targetCohort == input$dataTargetCohort, | ||
sex == input$dataSex, | ||
age == input$dataAge, | ||
indexYear == input$dataIndex) | ||
}) | ||
|
||
output$treatmentPathways <- DT::renderDataTable(pathwaysData()) | ||
|
||
output$sunburstPlot <- renderUI({ | ||
TreatmentPatterns::createSunburstPlot2(treatmentPathways = pathwaysData(), | ||
groupCombinations = TRUE) | ||
}) | ||
|
||
# output$sankeyDiagram <- renderUI({ | ||
# TreatmentPatterns::createSankeyDiagram2(treatmentPathways = pathwaysData(), | ||
# groupCombinations = TRUE) | ||
# }) | ||
} | ||
shinyApp(ui, 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.