ShinyApp not showing plots in browser but show only graph in viewer pane

I would like to show a table and a plot on my shiny app.
it shows the table, but it doesn't show the plot.
here is a part of the code (I have removed the table part)

   mainPanel(
                      fluidRow(
                        column(6, plotOutput("fancyPlot")),
                        column(6, DT::dataTableOutput("fancyTable"))
                      )
                 )
#Server Section
da_cell_plot <- reactive({
    L1 = Object@values
    if(input$TF_query1 != "ALL"){
     TF_columns = map_df(L1, ~pluck(., input$TF_query1))
     # TF_columns = map_df(L1, ~pluck(., "TAL1"))
     print("TF_columns")
    print(dim(TF_columns))
    metacell1 = umap_metacell$metacell
    metacell1 = cbind(metacell1, umap_metacell$celltype)
    print("metacell column")
    print(dim(metacell1))
    # if(length(TF_columns) != 0){
    TF_columns = cbind(TF_columns, metacell1[1:232, ])
    # print(TF_columns)
    print("Final TF_column: cbind of metacell and tf_column")
    print(dim(TF_columns))
    print("############")
    output_celltype1 <- subset(TF_columns, V2 == input$celltype1)
    output_celltype2 <- subset(TF_columns, V2 == input$celltype2)
    # print(head(output_celltype1))
    print("**********")
    # output_final1 = (sapply(output_celltype1[],mean))
    # output_final2 = (sapply(output_celltype2,mean))
    x = (length(output_celltype1))-2
    y = (length(output_celltype2))-2
    output_final1 = colMeans(output_celltype1[,1:x])
    # print(head(output_final1))
    output_final1 = t(output_final1)
    output_final1 = as.data.frame(output_final1)
    output_final2 = colMeans(output_celltype2[,1:y])
    output_final2 = t(output_final2)
    output_final2 = as.data.frame(output_final2)
    print(class(output_final1))
    print(dim(output_final1))
    # print(head(output_final1))
    output_final1 = t(output_final1)
    output_final1 = as.data.frame(output_final1)
    output_final2 = t(output_final2)
    output_final2 = as.data.frame(output_final2)
     plot1 = ggplot(output_final1, aes(x = input$celltype1, y = V1)) + 
      geom_boxplot(outlier.shape = NA) +
      geom_jitter()
     plot2 = ggplot(output_final2, aes(x = input$celltype2, y = V1)) + 
       geom_boxplot() +
       geom_jitter()
     print(paste("class(plot2):", class(plot2)))
     Final_fig_box <- subplot(plot1, plot2)%>%
       layout(title = "box plot")
     print(paste("class(Final_fig_box):", class(Final_fig_box)))
      Final_fig_box
     }
  })
  output$fancyPlot <- renderPlotly({
    f = da_cell_plot()
    print(paste("class(f):", class(f)))
    return(f)
     # da_cell_plot()
  })

sidenote : I edited your post to format the code (triple backticks on a line are used for turning this on and off )

plotOutput and plotlyOutput are not the same, and need to be coordinated with either a renderPlot or a renderPlotly.

1 Like

Thank you so much @nirgrahamuk

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.