showNotification causes a side effect, and is not itself something that renderPlotly knows how to render, therefore you can hack-solve that by returning NULL
}else{
showNotification("You should select first and second celltype and a TF as well.")
return(NULL)
}
aside from that you might choose to use shiny validate/need which is the more common approach to letting the user know you wont render something for a reason, not least because it ties the message to the undrawn item
output$fancyPlot <- renderPlotly({
shiny::validate(shiny::need(
expr = (length(input$celltype1) == 1 && length(input$celltype2) == 1 && input$TF_query1 != "ALL"),
message = "You should select first and second celltype and a TF as well."
))
f1 = da_cell_plot1()
plot1 = ggplot(f1, aes(x = input$celltype1, y = V1)) +
geom_jitter(alpha = 0.1, color = "tomato")+
geom_boxplot(alpha = 0)
f2 = da_cell_plot2()
plot2 = ggplot(f2, aes(x = input$celltype2, y = V1)) +
geom_jitter(alpha = 0.1, color = "tomato") +
geom_boxplot(alpha = 0)
Final_fig_box <- subplot(plot1, plot2)%>%
layout(title = "Inferred Celltype Activity")
print("it works")
return(Final_fig_box)
})