Skip to content

Modularizing singleCellTK R Shiny Code

Irzam Sarfraz edited this page Aug 24, 2022 · 3 revisions

Introduction to modules

Why use modules?

Issues with large applications

Code complexity (single file & too much code) Reusability Need separate identifiers (namespace) Create functions that dynamically generate user-interface & server code

Modules help

Small units Separate user-interface and server code Call multiple times like a function Separate namespace for each called instance of the module

Example of a module in SCTK

filterTable module

image6

Input

Dataframe

Actions

UI for the input dataframe is setup (table) UI for filters populated corresponding to the columns of the input dataframe Server code setup for actions taken on the table & filters

Output

Selected rows of the table

How to use shiny modules? (add figures from presentation)

image1 image2

  1. Create module R file a. Module UI b. Module Server
  2. Source module R file in your application
  3. Call module UI in your application UI (assign ID)
  4. Call module server code in your application server (use same ID)

Communicating between modules

Different instances of same module Different modules

Clone this wiki locally