#' dataInput UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd
#'
#' @importFrom shiny NS tagList
mod_dataInput_ui <- function(id){
ns <- NS(id)
tagList(
fluidPage( # Create fluidPage layout for tab
fluidRow(
column(
width = 6,
offset = 3,
h3("1. Upload"),
fileInput(
width = "100%",
inputId = ns("upload_rdsFile"),
label = "Upload Seurat Object: (.rds)",
accept = ".rds",
buttonLabel = "Browse",
placeholder = "No file selected"
),
hr(),
h3("2. Selection"),
selectizeInput(
width = "100%",
inputId = ns("selectGenes_manually"),
label = "Select Genes Manually:",
choices = NULL,
multiple = TRUE
),
hr(),
actionButton(
inputId = ns("goto_settings"),
label = "Advanced Settings",
class = "btn btn-secondary btn-lg btn-block"
)
# conditionalPanel(
# condition = "output.fileUploaded",
# ns = ns,
# ),
#
# conditionalPanel(
# condition = "output.genesSelected",
# ns = ns,
# )
)
)
)
)
}
#' dataInput Server Functions
#'
#' @noRd
mod_dataInput_server <- function(id){
moduleServer( id, function(input, output, session){
ns <- session$ns
# Gets file from fileInput()
rds = reactive({
validate(need(input$upload_rdsFile, message = FALSE))
input$upload_rdsFile
})
# Loads rds file
sc = reactive({
readRDS(rds()$datapath)
})
features_names_ids = reactive({
paste(rownames(sc()[["RNA"]][[]]), "_", sc()@assays[["RNA"]]@meta.features[["feature_id"]], sep = "")
})
observeEvent(features_names_ids(),{
updateSelectizeInput(
inputId = "selectGenes_manually",
choices = features_names_ids(),
server = TRUE
)
print(features_names_ids()[1])
})
return(
list(
features_names_ids = reactive({features_names_ids()})
)
)
# # Needed for conditionalPanel()
# # Shows UI after rds file was successfully uploaded
# output$fileUploaded = reactive({
# return(!is.null(sc()))
# })
# outputOptions(output, 'fileUploaded', suspendWhenHidden = FALSE)
#
# # Shows UI after genes were selected
# output$genesSelected = reactive({
# return(!is.null(inpt$selectGenes_manually))
# })
# outputOptions(output, 'genesSelected', suspendWhenHidden = FALSE)
})
}
## To be copied in the UI
# mod_dataInput_ui("dataInput_ui_1")
## To be copied in the server
# mod_dataInput_server("dataInput_ui_1")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.