I want to upload a fastq file and render some plots using Rqc Package especially the rqcQA function.
This is the code :
library(shiny)
library(Rqc)
ui <- fluidPage(
titlePanel("Uploading Files"),
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Choose file to upload',
accept = c('.fastq')
)
),
mainPanel(
plotOutput("plot1")
)
))
server <- function(input, output) {
output$plot1 <- renderPlot({
inFile <- input$file1
if (is.null(inFile))
return(NULL)
# folder <- "D:/sample.fastq"
rqcResultSet <- rqcQA(inFile$datapath, workers=1)
rqcReadQualityBoxPlot(rqcResultSet)
})
}
shinyApp(ui, server)
I got an error while reading the input :
'rqcQA' : Error in FUN(X[[i]], ...) : File format not detected or supported: 0
When i replace inFile$datapath
by folder
variable, i don't get any errors:
folder <- "D:/sample.fastq"
rqcResultSet <- rqcQA(folder, workers=1)
I did some research and i found the source code in Github, detectFileFormat.R is the file containing the function which specify the type format.
Any help will be appreciated.
The problem is that the file is renamed to 0
when you upload it to shiny and doesn't pass the rqcQA
file tests. Try running:
file.rename(inFile$datapath,inFile$name)
rqcResultSet <- rqcQA(inFile$name,workers=1)
This just renames the file to the original name in the current wd.
You can alternatively do
rqcResultSet <- rqcQA(FastqFile(inFile$datapath))
to skip the file check.