So I created an app to basically look at two different tumor types and when I run the app locally everything works fine. But after I publish the app I get an Error message: Error: error has occurred please check your logs. When I look at the error file it looks like the issues is that the app is trying to run my rmd file (the prep file to set up the variables needed for the app). However, without the file the app will not publish at all saying that it needs an rmd file. Any advice?
Did you write your app as an RStudio project, and only use relative file paths?
Did you upload your data to the server along with the app?
You should provide a lot more detail.
Hi, welcome!
We don't have enough information to help you out, Could you show what your app's logs say?
Hi, thanks for your reply. This is what I have written for the app locally.
library(shiny)
library(ggplot2)
library(utils)
library(base)
library(shinyWidgets)
library(dqshiny)
fonts <- list("Liberation Sans")
# Function to capitalize user-typed inputs
# Takes "gene" as input and returning "Gene"
capgene <- function(gene){
gene <- paste0(tolower(substring(gene, 1, 1)), tolower(substring(gene, 2)))
paste0(toupper(substring(gene, 1, 1)), substring(gene, 2))
}
# Grep, wrapped in a function to pre-set options
format.grep <- function(gg){
grep(substr(capgene(gg), 1, 3), dict$GENES, value = T, ignore.case = T)
}
# Function to draw feature plots from user-defined variables
simpleFeaturePlot <- function(gene = "Rbfox3",
color.use = 'red',
threshold = 0,
pt.size = 1,
to.include = "MSMO",
scale = 900){
# Identify which data sets were user-selected and add the plotting coordinates to "frame" variable
# If no data sets selected, return empty plot & exit function
if('MSMO' %in% to.include){
frame <- rbind(frame, MSMO.frame)
}
if('GSMO' %in% to.include){
frame <- rbind(frame, GSMO.frame)
}
if(length(to.include) == 0){d <- ggplot() + theme_classic() +
annotate("text", size = 12, fontface = 2,
color = color.use, x = 0, y = 0, label = "No Data Selected")
return(d)
}
# Translate gene to caps format (Gene, not gene or GENE)
gene <- capgene(gene)
# Build named list of data filehandles from vector of included datasets
fh <- lapply(to.include, FUN = function(sm) as.character(dict[which(dict$GENES == gene), paste(sm, sep = "_")]))
names(fh) <- paste(to.include, sep = "_")# Extract relevant gene from staged data files for each sample
for(sm in to.include){
data <- c(data, readRDS(paste0(sm, "/staged/", fh[[paste(sm, sep = '_')]]))[gene, ])
}
# Set background & highlight colors
colors <- c(grey(level = 0.7, alpha = 0.7), color.use)
names(colors) <- c('None', paste0(gene))
# Get Plotting Coordinates
frame <- cbind(frame,
as.data.frame(matrix(data = 0,
nrow = nrow(frame),
ncol = 1)))
#adjust if umap
colnames(frame) <- c('umap_1', 'umap_2', 'Plot.Status')
# Identify cells with expression of target gene
positive_cells <- names(data[data > threshold])
frame[which(rownames(frame) %in% positive_cells), 'Plot.Status'] <- paste0(gene)
# Divide coordinate data to plot negatives (first) below positives (second)
frame1 <- frame[which(frame[, 'Plot.Status'] == 0), ]
frame2 <- frame[which(frame[, 'Plot.Status'] != 0), ]
# Plot it. Return ggplot object & exit function, change to umap
d <- ggplot(mapping = aes(x = umap_1, y = umap_2)) +
geom_point(data = frame1, color = colors[1], size = pt.size) +
geom_point(data = frame2, aes(color = Plot.Status), size = pt.size, show.legend = F) +
scale_colour_manual(values = colors) + theme_classic() +
annotate("text", size = 6, fontface = 2, color = color.use, x = (min(frame$umap_1)+abs(0.1*min(frame$umap_1))), y = max(frame$umap_2), label = gene)
return(d)
}
# Pre-Load mapping coordinates and dictionaries. Establish placeholders for plotting variables
# This speeds up response time to user inputs
# Could be moved into the previous function for improved memory management if needed
GSMO.frame <- readRDS('GSMO/GSMO_xy.rds')
MSMO.frame <- readRDS('MSMO/MSMO_xy.rds')
dict <- readRDS('consensus_dict.rds')
frame <- c()
data <- c()
# Define UI. Shinythemes is an EASY way to pre-format color schemes & box styles.
# If making changes, BE CAREFUL to clean up commas when adding/removing panel elements
ui <- fluidPage(width = 8, theme = shinythemes::shinytheme("slate"),
# Application title
titlePanel("GSMO vs MSMO viewer"),
# Sidebar layouts
sidebarLayout(
# Panel to take gene inputs from user
sidebarPanel(
div(class = "panel panel-warning",
style = "box-shadow: 5px 5px 15px -5px rgba(0, 0, 0, 0.3);",
strong(div(class = "panel-heading", "Gene Options")),
# Which gene to plot
div(class = "panel-body",
strong(textInput("gene", "Gene", value = 'Rbfox3')),
#textInput(inputId = "gene" this means variable, label = "Gene Name", value = 'Mki67'),
# What threshold to use for calling positive values
sliderInput("threshold", "Expression Threshold (nUMI)",
min = 0.00,
max = 5.00,
step = 0.25,
value = 1),
selectInput("color", "Gene Color:",
c('Cyan' = "#00aeef", 'Sky Blue' = "#41b6e6", 'Teal' = "#487f84",
'Kelly Green' = "#348338", 'Sea Green' = "#006c5b", 'Olive' = "#5c8118",
'Orange' = "#c35413", 'Red' = "#da291c", 'Magenta' = "#c6007e",
'Purple' = "#6558b1", 'Grape' = "#6d2077"), selected = "#c35413")
))
, # Check box for data set selection, warning panel means the text is bold header is orange.
div(class = "panel panel-warning",
style = "box-shadow: 5px 5px 15px -5px rgba(0, 0, 0, 0.3);",
strong(div(class = "panel-heading", "Dataset Selection")),
checkboxGroupButtons(inputId = "dataset", label ="",
choiceNames = c("GSMO", "MSMO"),
choiceValues = c("GSMO", "MSMO"),
selected = c("GSMO"), justified = T, individual =T, status = "danger")),
#one or the other cannot overlay the umaps
# Panel to adjust graphical parameters (for figure generation)
div(class = "panel panel-info",
style = "box-shadow: 5px 5px 15px -5px rgba(0, 0, 0, 0.3);")
,
sliderInput("point.size",
"Point Size",
min = 0.00,
max = 2.00,
step = 0.2,
value = 0.8),
# Button to download user-generated graphics in .pdf format
downloadButton('downloadPlot', "Download as pdf")
),
# Format the graphics output in the main panel
mainPanel(plotOutput("plot", width = '90%'))
)
)
# Define server logic/ making two new functions one for WT and one for the tumor
# This is required to allow each plot to scale independently with screen size
# The plot takes it's width from the clientData output, which is specified by the plotOutput function in the UI chunk
server <- function(input, output, session) {
plotInput = function(){
simpleFeaturePlot(gene = input$gene,
color.use = as.character(input$color),
threshold = as.numeric(input$threshold),
pt.size = as.numeric(input$point.size),
to.include = input$dataset,
scale = session$clientData$output_plot_width)
}
output$plot <- renderPlot({
validate(
need(expr = (capgene(input$gene) %in% format.grep(input$gene)), message = c(paste0(input$gene, ' not found!'),
'Did you mean: ',
paste(format.grep(input$gene))))
)
plotInput()
}, height = function() {
session$clientData$output_plot_width*0.9
})
download.plotInput = function(){
simpleFeaturePlot(gene = input$gene,
color.use = as.character(input$color),
threshold = as.numeric(input$threshold),
# pt.size = as.numeric(input$point.size),
to.include = input$dataset)
}
output$downloadPlot <- downloadHandler(
filename = function() { paste0(input$gene, '.pdf') },
content = function(file) {
ggsave(file, plot = download.plotInput(), width = 10, height = 10, device = "pdf")
}
)
}
# Run the application
shinyApp(ui = ui, server = server)
So you will need to upload these files along with your app. I am not sure how you create the subdirectories or whether shiny will do this automatically.
GSMO.frame <- readRDS("GSMO/GSMO_xy.rds")
MSMO.frame <- readRDS("MSMO/MSMO_xy.rds")
dict <- readRDS("consensus_dict.rds")
I have created the subdirectories entitled: "MSMO" and "GSMO" and all of the files needed are in each of the directories. From the logs the part that seems to be killing the app is the GvMprep.Rmd where I create each of the GSMO_xy.rds or MSMO_xy.rds. Do you have any suggestions on how to bypass uploading the Rmd file? Or do you think that it has to do with file paths? Thank you for your help. I thought I posted the log files but here is what they said:
020-01-13T17:39:34.137521+00:00 shinyapps[1581143]: Server version: 1.7.8-7
2020-01-13T17:39:34.137522+00:00 shinyapps[1581143]: LANG: en_US.UTF-8
2020-01-13T17:39:34.137562+00:00 shinyapps[1581143]: R version: 3.5.2
2020-01-13T17:39:34.137563+00:00 shinyapps[1581143]: shiny version: 1.3.2
2020-01-13T17:39:34.137564+00:00 shinyapps[1581143]: httpuv version: 1.5.1
2020-01-13T17:39:34.137564+00:00 shinyapps[1581143]: rmarkdown version: 1.13
2020-01-13T17:39:34.137570+00:00 shinyapps[1581143]: knitr version: 1.23
2020-01-13T17:39:34.137571+00:00 shinyapps[1581143]: jsonlite version: 1.6
2020-01-13T17:39:34.137599+00:00 shinyapps[1581143]: RJSONIO version: (none)
2020-01-13T17:39:34.137610+00:00 shinyapps[1581143]: htmltools version: 0.3.6
2020-01-13T17:39:35.367247+00:00 shinyapps[1581143]: warning: using reticulate but python was not specified; will use python at /usr/bin/python
2020-01-13T17:39:35.367249+00:00 shinyapps[1581143]: Did you forget to set the RETICULATE_PYTHON environment variable in your .Rprofile before publishing?
2020-01-13T17:39:35.367538+00:00 shinyapps[1581143]: Using pandoc at /opt/connect/ext/pandoc2
2020-01-13T17:39:35.516701+00:00 shinyapps[1581143]: Using jsonlite for JSON processing
2020-01-13T17:39:35.521659+00:00 shinyapps[1581143]:
2020-01-13T17:39:35.521661+00:00 shinyapps[1581143]: Starting R with process ID: '25'
2020-01-13T17:39:35.620815+00:00 shinyapps[1581143]:
2020-01-13T17:39:35.620816+00:00 shinyapps[1581143]: Listening on http://127.0.0.1:35492
2020-01-13T17:39:36.796071+00:00 shinyapps[1581143]:
2020-01-13T17:39:37.151266+00:00 shinyapps[1581143]:
2020-01-13T17:39:37.151269+00:00 shinyapps[1581143]: processing file: GvMprep.Rmd
2020-01-13T17:39:37.154188+00:00 shinyapps[1581143]:
|
| | 0%
|
|................ | 25%
2020-01-13T17:39:37.154361+00:00 shinyapps[1581143]: ordinary text without R code
2020-01-13T17:39:37.151268+00:00 shinyapps[1581143]:
2020-01-13T17:39:37.154890+00:00 shinyapps[1581143]:
|
|................................ | 50%
2020-01-13T17:39:37.156150+00:00 shinyapps[1581143]: label: unnamed-chunk-1
2020-01-13T17:39:37.154362+00:00 shinyapps[1581143]:
2020-01-13T17:39:39.154512+00:00 shinyapps[1581143]: Quitting from lines 8-14 (GvMprep.Rmd)
2020-01-13T17:39:39.155399+00:00 shinyapps[1581143]:
2020-01-13T17:39:39.156672+00:00 shinyapps[1581143]: Warning: Error in gzfile: cannot open the connection
2020-01-13T17:39:39.163130+00:00 shinyapps[1581143]: 151: gzfile
2020-01-13T17:39:39.163132+00:00 shinyapps[1581143]: 149: eval
2020-01-13T17:39:39.163131+00:00 shinyapps[1581143]: 150: readRDS
2020-01-13T17:39:39.163132+00:00 shinyapps[1581143]: 148: eval
2020-01-13T17:39:39.163132+00:00 shinyapps[1581143]: 143: evaluate_call
2020-01-13T17:39:39.163133+00:00 shinyapps[1581143]: 141: evaluate
2020-01-13T17:39:39.163133+00:00 shinyapps[1581143]: 142: evaluate::evaluate
2020-01-13T17:39:39.163133+00:00 shinyapps[1581143]: 139: block_exec
2020-01-13T17:39:39.163134+00:00 shinyapps[1581143]: 138: call_block
2020-01-13T17:39:39.163134+00:00 shinyapps[1581143]: 137: process_group.block
2020-01-13T17:39:39.163149+00:00 shinyapps[1581143]: 15:
2020-01-13T17:39:39.163135+00:00 shinyapps[1581143]: 134: process_file
2020-01-13T17:39:39.163150+00:00 shinyapps[1581143]: 13: rmarkdown::run
2020-01-13T17:39:39.163135+00:00 shinyapps[1581143]: 133: knitr::knit
2020-01-13T17:39:39.163150+00:00 shinyapps[1581143]: 12: fn
2020-01-13T17:39:39.163147+00:00 shinyapps[1581143]: 132:
2020-01-13T17:39:39.163150+00:00 shinyapps[1581143]: 7: connect$retry
2020-01-13T17:39:39.163147+00:00 shinyapps[1581143]: 127:
2020-01-13T17:39:39.163151+00:00 shinyapps[1581143]: 6: eval
2020-01-13T17:39:39.163148+00:00 shinyapps[1581143]: 111: doc
2020-01-13T17:39:39.163151+00:00 shinyapps[1581143]: 5: eval
2020-01-13T17:39:39.163148+00:00 shinyapps[1581143]: 110: shiny::renderUI
2020-01-13T17:39:39.163148+00:00 shinyapps[1581143]: 109: func
2020-01-13T17:39:39.163149+00:00 shinyapps[1581143]: 96: origRenderFunc
2020-01-13T17:39:39.163149+00:00 shinyapps[1581143]: 95: output$reactivedoc
Hi thank you for responding! This is my first time using shiny so I am just getting the hang of it. Here is the log file:
2020-01-13T17:39:34.137521+00:00 shinyapps[1581143]: Server version: 1.7.8-7
2020-01-13T17:39:34.137522+00:00 shinyapps[1581143]: LANG: en_US.UTF-8
2020-01-13T17:39:34.137562+00:00 shinyapps[1581143]: R version: 3.5.2
2020-01-13T17:39:34.137563+00:00 shinyapps[1581143]: shiny version: 1.3.2
2020-01-13T17:39:34.137564+00:00 shinyapps[1581143]: httpuv version: 1.5.1
2020-01-13T17:39:34.137564+00:00 shinyapps[1581143]: rmarkdown version: 1.13
2020-01-13T17:39:34.137570+00:00 shinyapps[1581143]: knitr version: 1.23
2020-01-13T17:39:34.137571+00:00 shinyapps[1581143]: jsonlite version: 1.6
2020-01-13T17:39:34.137599+00:00 shinyapps[1581143]: RJSONIO version: (none)
2020-01-13T17:39:34.137610+00:00 shinyapps[1581143]: htmltools version: 0.3.6
2020-01-13T17:39:35.367247+00:00 shinyapps[1581143]: warning: using reticulate but python was not specified; will use python at /usr/bin/python
2020-01-13T17:39:35.367249+00:00 shinyapps[1581143]: Did you forget to set the RETICULATE_PYTHON environment variable in your .Rprofile before publishing?
2020-01-13T17:39:35.367538+00:00 shinyapps[1581143]: Using pandoc at /opt/connect/ext/pandoc2
2020-01-13T17:39:35.516701+00:00 shinyapps[1581143]: Using jsonlite for JSON processing
2020-01-13T17:39:35.521659+00:00 shinyapps[1581143]:
2020-01-13T17:39:35.521661+00:00 shinyapps[1581143]: Starting R with process ID: '25'
2020-01-13T17:39:35.620815+00:00 shinyapps[1581143]:
2020-01-13T17:39:35.620816+00:00 shinyapps[1581143]: Listening on http://127.0.0.1:35492
2020-01-13T17:39:36.796071+00:00 shinyapps[1581143]:
2020-01-13T17:39:37.151266+00:00 shinyapps[1581143]:
2020-01-13T17:39:37.151269+00:00 shinyapps[1581143]: processing file: GvMprep.Rmd
2020-01-13T17:39:37.154188+00:00 shinyapps[1581143]:
|
| | 0%
|
|................ | 25%
2020-01-13T17:39:37.154361+00:00 shinyapps[1581143]: ordinary text without R code
2020-01-13T17:39:37.151268+00:00 shinyapps[1581143]:
2020-01-13T17:39:37.154890+00:00 shinyapps[1581143]:
|
|................................ | 50%
2020-01-13T17:39:37.156150+00:00 shinyapps[1581143]: label: unnamed-chunk-1
2020-01-13T17:39:37.154362+00:00 shinyapps[1581143]:
2020-01-13T17:39:39.154512+00:00 shinyapps[1581143]: Quitting from lines 8-14 (GvMprep.Rmd)
2020-01-13T17:39:39.155399+00:00 shinyapps[1581143]:
2020-01-13T17:39:39.156672+00:00 shinyapps[1581143]: Warning: Error in gzfile: cannot open the connection
2020-01-13T17:39:39.163130+00:00 shinyapps[1581143]: 151: gzfile
2020-01-13T17:39:39.163132+00:00 shinyapps[1581143]: 149: eval
2020-01-13T17:39:39.163131+00:00 shinyapps[1581143]: 150: readRDS
2020-01-13T17:39:39.163132+00:00 shinyapps[1581143]: 148: eval
2020-01-13T17:39:39.163132+00:00 shinyapps[1581143]: 143: evaluate_call
2020-01-13T17:39:39.163133+00:00 shinyapps[1581143]: 141: evaluate
2020-01-13T17:39:39.163133+00:00 shinyapps[1581143]: 142: evaluate::evaluate
2020-01-13T17:39:39.163133+00:00 shinyapps[1581143]: 139: block_exec
2020-01-13T17:39:39.163134+00:00 shinyapps[1581143]: 138: call_block
2020-01-13T17:39:39.163134+00:00 shinyapps[1581143]: 137: process_group.block
2020-01-13T17:39:39.163149+00:00 shinyapps[1581143]: 15: <Anonymous>
2020-01-13T17:39:39.163135+00:00 shinyapps[1581143]: 134: process_file
2020-01-13T17:39:39.163150+00:00 shinyapps[1581143]: 13: rmarkdown::run
2020-01-13T17:39:39.163135+00:00 shinyapps[1581143]: 133: knitr::knit
2020-01-13T17:39:39.163150+00:00 shinyapps[1581143]: 12: fn
2020-01-13T17:39:39.163147+00:00 shinyapps[1581143]: 132: <Anonymous>
2020-01-13T17:39:39.163150+00:00 shinyapps[1581143]: 7: connect$retry
2020-01-13T17:39:39.163147+00:00 shinyapps[1581143]: 127: <reactive>
2020-01-13T17:39:39.163151+00:00 shinyapps[1581143]: 6: eval
2020-01-13T17:39:39.163148+00:00 shinyapps[1581143]: 111: doc
2020-01-13T17:39:39.163151+00:00 shinyapps[1581143]: 5: eval
2020-01-13T17:39:39.163148+00:00 shinyapps[1581143]: 110: shiny::renderUI
2020-01-13T17:39:39.163148+00:00 shinyapps[1581143]: 109: func
2020-01-13T17:39:39.163149+00:00 shinyapps[1581143]: 96: origRenderFunc
2020-01-13T17:39:39.163149+00:00 shinyapps[1581143]: 95: output$__reactivedoc__
Also, here is the structure of my folder that I am using for the app locally.
This file doesn't seem to be part of your app, if this is used as a script to generate intermediate output that is later used in your app, then do not include it when you publish the files for your application, specially if it is located at the app's root folder.
Correct, I have tried removing the file but when I go to publish I get this error message: reparing to deploy application...DONE
Uploading bundle for application: 1660213...Error in inferAppPrimaryDoc(appPrimaryDoc = appPrimaryDoc, appFiles = appFiles, :
Application mode static requires at least one document.
Calls: ... withStatus -> force -> bundleApp -> inferAppPrimaryDoc
Execution halted.
So this is where I am stuck.
I'm not completely sure this mandatory or if it can be configured other way but I believe your app's script file has to be named app.R
maybe that is why you are getting this error message.
That was it, wow that was a lot of time spent inspecting code instead of looking at names haha. Thank you!
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.