Skip to content

Commit

Permalink
Merge pull request #33 from CRI-iAtlas/nanostring_ui
Browse files Browse the repository at this point in the history
add interface in ici cohort selection for nanostring
  • Loading branch information
andrewelamb authored May 16, 2022
2 parents 7a73c74 + b88f553 commit 378231c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 17 deletions.
13 changes: 13 additions & 0 deletions R/cohort_dataset_selection_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,16 @@ create_cohort_module_string <- function(.datasets, tbl = NULL){
}

}

#Create a list of ICI datasets based on whether the data is RNA-Seq or Nanostring. Needs to be updated if more Nanostring data is added
create_ici_options <- function(.datasets){
nanostring_ds <- c("Chen_CanDisc_2016", "Melero_GBM_2019", "Prat_CanRes_2017")
rnaseq_nano_ds <- "Prins_GBM_2019" #this dataset has both RNA-Seq and Nanostring data available

return(
list(
'RNA-Seq' = .datasets[!(.datasets %in% nanostring_ds)],
'Nanostring' = .datasets[.datasets %in% c(nanostring_ds, rnaseq_nano_ds)]
)
)
}
56 changes: 40 additions & 16 deletions R/cohort_dataset_selection_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,50 @@ cohort_dataset_selection_server <- function(
ns <- session$ns

choices <- shiny::reactive({
iatlasGraphQLClient::query_datasets(types = dataset_type()) %>%
options <- iatlasGraphQLClient::query_datasets(types = dataset_type()) %>%
dplyr::select("display", "name") %>%
tibble::deframe(.)
if(dataset_type() == "analysis") return(options)
else return(create_ici_options(options)) #for the ICI Cohort Selection, we have RNA-Seq and Nanostring data. This function returns a list organizing them.
})

ui_func <- shiny::reactive({
shiny::req(dataset_type())
if(dataset_type() == "analysis") return(shiny::selectInput)
else return(shiny::checkboxGroupInput)
})


output$dataset_selection_ui <- shiny::renderUI({
shiny::req(ui_func(), choices(), default_datasets())
ui_func()(
inputId = ns("dataset_choices"),
label = "Select Datasets",
choices = choices(),
selected = default_datasets()
)
shiny::req(choices(), default_datasets())

if(dataset_type() == "analysis"){
shiny::selectInput(
inputId = ns("dataset_choices"),
label = "Select Datasets",
choices = choices(),
selected = default_datasets()
)
}else{ #ICI Cohort selection will have two dataset columns, one for RNA-Seq and the other for Nanostring datasets
shiny::fluidRow(
shiny::column(
width = 6,
shiny::checkboxGroupInput(
inputId = ns("dataset_choices"),
label = "Select Datasets - RNA-Seq data",
choices = choices()[[1]], #list RNA-seq datasets
selected = default_datasets()
)
),
shiny::column(
width = 6,
shiny::checkboxGroupInput(
inputId = ns("dataset_choices_ns"),
label = "Select Datasets - Nanostring data (only Immunomodulators module)",
choices = choices()[[2]], #list nanostring datasets
selected = default_datasets()
)
)
)
}
})

dataset_selection <- shiny::reactive({
if(dataset_type() == "analysis") return(input$dataset_choices)
else return(c(input$dataset_choices, input$dataset_choices_ns)) #ICI Cohort selection can have RNA-Seq and Nanostring ds selected
})

# This is so that the conditional panel can see the various shiny::reactives
Expand All @@ -50,7 +74,7 @@ cohort_dataset_selection_server <- function(
)
})

return(shiny::reactive(input$dataset_choices))
return(shiny::reactive(sort(dataset_selection())))
}
)
}
2 changes: 1 addition & 1 deletion inst/markdown/cohort_dataset_selection.markdown
Original file line number Diff line number Diff line change
@@ -1 +1 @@
First, select a cancer genomics dataset from the dropdown below.
First, select data of interest from the options below.

0 comments on commit 378231c

Please sign in to comment.