R/mod_AA_abundance.R

Defines functions mod_AA_abundance_server mod_AA_abundance_ui

#' AA_abundance UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd
#'
#' @importFrom shiny NS tagList
mod_AA_abundance_ui <- function(id){
  ns <- NS(id)
  tagList(
    shiny::sidebarLayout(
      shiny::sidebarPanel(
        shiny::textAreaInput(
          inputId = ns("peptide"),
          label = "Peptide sequence",
          width = 300,
          height = 100,
          placeholder = "Insert peptide sequence"
        )
      ),
      shiny::mainPanel(
        shiny::plotOutput(
          outputId = ns("abundance")
        )
      )
    )
  )
}

#' AA_abundance Server Functions
#'
#' @noRd
mod_AA_abundance_server <- function(id){
  moduleServer(id, function(input, output, session){
    ns <- session$ns
    output$abundance <- renderPlot({
      if(input$peptide == ""){
        NULL
      } else{
        input$peptide %>%
          centralDogma::plot_abundance() +
          ggplot2::theme(legend.position = "none")
      }
    })
  })
}

## To be copied in the UI
# mod_AA_abundance_ui("AA_abundance_1")

## To be copied in the server
# mod_AA_abundance_server("AA_abundance_1")
Yi9898/shiny_app documentation built on May 18, 2022, 8:48 a.m.