I made an application on version R 3.6.3 that works quite well.
While upgrading to R 4.0.1, I encountered a problem. The error "error evaluating the 'x' argument when selecting a method for the 'reducedDimsNames' function" appeared in the graphics where an input was not yet selected.
Here is an example (Shiny reprex) of code that shows me the error on version R 4.0.1 but not on version 3.6.3. (I hope this is a shiny reprex. It is in any case a simplification of my application which meets several times this problem)
## free SingleCellExperiment object
# library(scRNAseq)
# library(scater)
# library(SingleCellExperiment)
# sce <- LaMannoBrainData('mouse-adult')
# sce <- runPCA(sce,ncomponents=10,exprs_values="counts")
# reducedDimNames(sce)
# save(sce,file="SCEex.RData")
## Only run this example in interactive R sessions
if (interactive()) {
ui <- navbarPage("NOM APPLI",
# Onglet - data Import
tabPanel("Upload Data",
sidebarLayout(
sidebarPanel(
fileInput("fileData",label = "Choose the RData file containing the SCE object:"),
uiOutput("redDimInput"),
uiOutput("dimRed"),
actionButton("go_button_viz", "GO")
),
mainPanel(
verbatimTextOutput("idout")
)))
)
server <- function(input, output) {
object <- reactive({
# if (is.null(req(input$fileData))){return(NULL)}
inFile <- req(input$fileData)
file <- inFile$datapath
# load the file into new environment and get it from there
e = new.env()
name <- load(file, envir = e)
# name = nom des objets importes et on load les objets sur e
object <- e[[name]]
# return(list(object = object, name=name, file=inFile))
return(object)
})
output$redDimInput <- renderUI(selectInput("redDim",
"Choose the coordinates of dimension reduction",
choices=reducedDimNames(req(object()))))
output$idout <- renderPrint({
reducedDim(object(), type=input$redDim)
})
}
shinyApp(ui, server)
}
I think the error comes from the req() function which would not execute properly. But I probably don't know how to use it properly.
Thanks for your help,
Nicolas