Skip to content

Developer guide: PlotModule

Mauro Masiero edited this page May 15, 2023 · 3 revisions

Welcome to the PlotModule User Guide for Omics Playground! This guide will help you get started using the PlotModule within the Omics Playground Shiny application. The PlotModule is a powerful and flexible tool designed to simplify the process of rendering, exporting, and downloading plots in various formats within Omics Playground. With support for multiple plotting libraries, including Plotly, ggplot2, and base R graphics among others; PlotModule makes it easy to embed your new dynamic, interactive, and visually appealing plots to the Shiny application.

Omics Playground is a comprehensive platform for the analysis, visualization, and exploration of omics data. By incorporating the PlotModule into Omics Playground, users can efficiently generate plots that aid in the interpretation of their data and facilitate better understanding of the underlying biological processes.

This user guide will walk you through the main features of the PlotModule, as well as how to use the module in conjunction with other components of the Omics Playground Shiny application. Get ready to unlock the full potential of your omics data visualization with the PlotModule in Omics Playground!

UI

To start, it's essential to understand the role of the PlotModuleUI function. This function is responsible for constructing the user interface (UI) elements of the PlotModule, including the layout, option menus, and download options. A well-designed UI is crucial for an intuitive and seamless user experience, allowing you to easily interact with the PlotModule to create and export your desired plots. In the following sections, we will explore the PlotModuleUI function in-depth, discussing its arguments, customization options, and how it can be integrated into the overall Omics Playground Shiny application for a smooth and efficient workflow.

Here's a list of the PlotModuleUI function arguments along with a brief description of each:

  • id: A unique identifier string used for the input and output binding in the Shiny application. This ID ensures that the corresponding UI and server components are connected.
  • plotlib: A string specifying the plotting library to be used for the main plot. Supported libraries include "plotly", "ggplot", "grid", "iheatmapr", "image", "base", and more.
  • width: A numeric or character value defining the width of the main plot. This can be specified as a single value or a vector of two values for different widths in different contexts (e.g., normal view and popup).
  • height: A numeric or character value defining the height of the main plot. Similar to width, this can be specified as a single value or a vector of two values for different heights in different contexts (e.g., normal view and popup).
  • res: A numeric value or a vector of two values for the resolution of the main plot. Higher values result in higher resolution images.
  • no.download: A boolean specifying whether the download options should be disabled or not.
  • just.info: A boolean indicating if only information about the plot should be displayed instead of the actual plot.
  • show.maximize: A boolean specifying whether the maximize button should be displayed for the plots.
  • card: A boolean specifying whether bslib cards should be used inside the PlotModule to display multiple plots within the same PlotModule.
  • card_names: A character vector of names for the different cards when using bslib cards to display multiple plots within the same PlotModule.
  • downloadoptions: A list of file formats that the user can choose from when downloading the plot. Supported formats include "png", "pdf", "csv", "html", and "obj".

These arguments allow for a high degree of customization for the PlotModuleUI, making it adaptable to various use cases and user preferences.

Tabs with plots inside cards

Function: Provide the option of using cards inside a PlotModule. Info button are the same between two plots. The download button will download the active plot and the options button will display the options for the selected plot.

Usage: On the PlotModuleUI we have to use the arguments cards and card_names:

card: Bool value. If TRUE, cards will be used.

card_names: Name of the cards as in c("card1", "card2").

Exemple UI:

PlotModuleUI(
    ns("pltmod"),
    plotlib = c("plotly","base"),
    info.text = info_text,
    download.fmt = c("png", "pdf", "csv"),
    title = "Dataset explorer",
    cards = TRUE,
    card_names = c("card1", "card2")
  )

On the PlotModuleServer we have to create as many servers as cards. In this example, we have two plots, so two servers:

ID is shared between the UI declaration and all the servers We just specify which servers correspond to which card numerically

PlotModuleServer(
      "pltmod",
      plotlib = "plotly",
      func = plot.RENDER,
      func2 = modal_plot.RENDER,
      card = 1
)
PlotModuleServer(
      "pltmod",
      plotlib = "base",
      func = plot.RENDER2,
      func2 = modal_plot.RENDER2,
      card = 2
)