tmodBrowserPlotServer: Shiny Module – tmod browser evidence plots

View source: R/tmod_evidenceplot.R

tmodBrowserPlotUIR Documentation

Shiny Module – tmod browser evidence plots

Description

Shiny Module – gene browser evidence plots

Usage

tmodBrowserPlotUI(id)

tmodBrowserPlotServer(
  id,
  gs_id,
  tmod_dbs,
  cntr,
  tmod_map = NULL,
  tmod_gl = NULL,
  annot = NULL,
  tmod_res = NULL,
  primary_id = "PrimaryID",
  gene_id = NULL
)

Arguments

id

identifier (same as the one passed to geneBrowserTableUI)

gs_id

a "reactive values" object (returned by reactiveValues()), including dataset (ds), gene set ID (id), contrast id (cntr), database ID (db) and sorting mode (sort). If mod_id is not NULL, these reactive values will be populated, possibly triggering an action in another shiny module.

tmod_dbs

tmod gene set databases returned by get_tmod_dbs()

cntr

list of contrast results returned by get_contrasts()

tmod_map

tmod gene set ID mapping returned by get_tmod_mapping()

tmod_gl

tmod gene lists. See details.

annot

data frame containing gene annotation

tmod_res

Results of gene set enrichment analysis (optional).

primary_id

name of the column which holds the primary identifiers

gene_id

must be a reactiveValues object. If not NULL, then clicking on a gene identifier will modify this object (possibly triggering an event in another module).

Details

This part is a bit complex, because a lot of different data go into the evidence plots. To create a plot, following elements are necessary:

  • ordered gene list: this is the same gene list that is used as an input to tmod

  • a list of gene set collections (tmod gene set databases) for which the enrichments have been run

  • contrast data frame – to know which genes go up or down, for displaying gene names in color

  • if no gene list is given, then using the contrast data frame it is possible to create a list ordered by p-values. However, since the gene set database might use a different type of identifiers than the PrimaryID column of the contrasts data frame, it is necessary to provide a mapping between the PrimaryIDs and the database gene IDs as well.

The sections below discuss these elements.

Value

returns a reactive value with a selected gene identifier

tmod gene lists

To display an evidence plot, we need to have an ordered list of genes. This has to be provided from outside, as many different sortings are possible. The parameter tmod_gl is a hierarchical list:

  • First level: contrasts

  • Second level: sorting type

For example, then the tmod_gl[["Contrast1"]][["pval"]] is a vector of indices which correspond to sorting by pval in Contrast1.

If this argument is NULL, then the genes will be ordered by p-values from the contrast object provided. However, in this case it is necessary to provide a mapping between the PrimaryIDs of the contrasts and the gene identifiers used by the gene set database.

Use of tmod database objects

For gene set enrichments, collections (databases) of gene sets must be defined. Such gene set collections include KEGG and REACTOME pathways, Gene Ontologies, transcriptional modules as well as meta-collections such as MSigDB.

There are many ways of storing such gene set collections. One way that I find convenient (since I programmed it myself) is included in the gene set enrichment testing package tmod. Tmod database objects are lists with at least three elements: gs, gv and gv2gs (see details in the tmod package). They can be conveniently created using the tmod package.

In 'bioshmods', these objects are included in a structure which provides gene set information to the 'bioshmods' functions. Each such structure is a named list with one element per gene set collection (i.e., if you have gene set enrichment results for KEGG and REACTOME, you will have two such elements). Each of these element is a tmod database object (returned, for example, by the tmod::makeTmod() function from the 'tmod' package). See the example dataset C19_gs.

Examples

## extending the example from tmodBrowserTableServer
if(interactive()) {

  library(shiny)

  ui <- fluidPage(
   fluidRow(tmodBrowserTableUI("tt", names(C19_gs$tmod_res), upset=TRUE)),
   fluidRow(tmodBrowserPlotUI("tp"))
   )

  server <- function(input, output) {
    gs_id <- reactiveValues()
    tmodBrowserTableServer("tt", C19_gs$tmod_res, gs_id = gs_id,
                                 tmod_dbs = C19_gs$tmod_dbs)
    tmodBrowserPlotServer("tp",
             gs_id=gs_id,
             tmod_map=C19_gs$tmod_map,
             tmod_dbs=C19_gs$tmod_dbs,
             tmod_gl=C19_gs$tmod_gl,
             cntr=C19$contrasts,
             annot=C19$annotation)
  }
  runApp(shinyApp(ui, server))
}



bihealth/bioshmods documentation built on July 1, 2023, 4:32 a.m.