mirror of
https://github.com/johrpan/ubigen.git
synced 2025-10-26 19:57:24 +01:00
Allow setting a custom default dataset
This commit is contained in:
parent
c14208c2b2
commit
995b31646e
4 changed files with 203 additions and 177 deletions
15
R/app.R
15
R/app.R
|
|
@ -2,8 +2,19 @@
|
||||||
#'
|
#'
|
||||||
#' @param host The hostname to serve the application on.
|
#' @param host The hostname to serve the application on.
|
||||||
#' @param port The port to serve the application on.
|
#' @param port The port to serve the application on.
|
||||||
|
#' @param custom_dataset This allows to set a custom dataset (return value of
|
||||||
|
#' [analyze()]) as the default dataset of the UI.
|
||||||
#'
|
#'
|
||||||
#' @export
|
#' @export
|
||||||
run_app <- function(host = "127.0.0.1", port = 3464) {
|
run_app <- function(host = "127.0.0.1",
|
||||||
runApp(shinyApp(ui, server), host = host, port = port)
|
port = 3464,
|
||||||
|
custom_dataset = NULL) {
|
||||||
|
runApp(
|
||||||
|
shinyApp(
|
||||||
|
ui(custom_dataset = custom_dataset),
|
||||||
|
server(custom_dataset = custom_dataset)
|
||||||
|
),
|
||||||
|
host = host,
|
||||||
|
port = port
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
#' Server implementing the main user interface.
|
#' Server implementing the main user interface.
|
||||||
#' @noRd
|
#' @noRd
|
||||||
server <- function(input, output, session) {
|
server <- function(custom_dataset = NULL) {
|
||||||
|
function(input, output, session) {
|
||||||
dataset <- reactive({
|
dataset <- reactive({
|
||||||
analysis <- if (input$dataset == "gtex_tissues") {
|
analysis <- if (input$dataset == "gtex_tissues") {
|
||||||
ubigen::gtex_tissues
|
ubigen::gtex_tissues
|
||||||
} else if (input$dataset == "hpa_tissues") {
|
} else if (input$dataset == "hpa_tissues") {
|
||||||
ubigen::hpa_tissues
|
ubigen::hpa_tissues
|
||||||
} else {
|
} else if (input$dataset == "gtex_all") {
|
||||||
ubigen::gtex_all
|
ubigen::gtex_all
|
||||||
|
} else {
|
||||||
|
custom_dataset
|
||||||
}
|
}
|
||||||
|
|
||||||
merge(analysis, ubigen::genes, by = "gene")
|
merge(analysis, ubigen::genes, by = "gene")
|
||||||
|
|
@ -182,3 +185,4 @@ server <- function(input, output, session) {
|
||||||
|
|
||||||
output$gsea_plot_ranking <- plotly::renderPlotly(gsea_plot_ranking)
|
output$gsea_plot_ranking <- plotly::renderPlotly(gsea_plot_ranking)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
12
R/ui.R
12
R/ui.R
|
|
@ -1,6 +1,6 @@
|
||||||
#' Function for creating the main user interface.
|
#' Function for creating the main user interface.
|
||||||
#' @noRd
|
#' @noRd
|
||||||
ui <- function() {
|
ui <- function(custom_dataset = NULL) {
|
||||||
div(
|
div(
|
||||||
custom_css(),
|
custom_css(),
|
||||||
rclipboard::rclipboardSetup(),
|
rclipboard::rclipboardSetup(),
|
||||||
|
|
@ -22,11 +22,19 @@ ui <- function() {
|
||||||
selectInput(
|
selectInput(
|
||||||
"dataset",
|
"dataset",
|
||||||
label = strong("Expression dataset"),
|
label = strong("Expression dataset"),
|
||||||
list(
|
{
|
||||||
|
choices <- list(
|
||||||
"GTEx (across tissues and conditions)" = "gtex_all",
|
"GTEx (across tissues and conditions)" = "gtex_all",
|
||||||
"GTEx (across tissues)" = "gtex_tissues",
|
"GTEx (across tissues)" = "gtex_tissues",
|
||||||
"Human Protein Atlas (across tissues)" = "hpa_tissues"
|
"Human Protein Atlas (across tissues)" = "hpa_tissues"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!is.null(custom_dataset)) {
|
||||||
|
c(list("Custom dataset" = "custom"), choices)
|
||||||
|
} else {
|
||||||
|
choices
|
||||||
|
}
|
||||||
|
}
|
||||||
),
|
),
|
||||||
selectInput(
|
selectInput(
|
||||||
"cross_sample_metric",
|
"cross_sample_metric",
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,15 @@
|
||||||
\alias{run_app}
|
\alias{run_app}
|
||||||
\title{Run the application server.}
|
\title{Run the application server.}
|
||||||
\usage{
|
\usage{
|
||||||
run_app(host = "127.0.0.1", port = 3464)
|
run_app(host = "127.0.0.1", port = 3464, custom_dataset = NULL)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{host}{The hostname to serve the application on.}
|
\item{host}{The hostname to serve the application on.}
|
||||||
|
|
||||||
\item{port}{The port to serve the application on.}
|
\item{port}{The port to serve the application on.}
|
||||||
|
|
||||||
|
\item{custom_dataset}{This allows to set a custom dataset (return value of
|
||||||
|
\code{\link[=analyze]{analyze()}}) as the default dataset of the UI.}
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
Run the application server.
|
Run the application server.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue