geneBrowserPlotServer: Shiny Module – gene browser expression profile plot

View source: R/gene_plots.R

geneBrowserPlotUIR Documentation

Shiny Module – gene browser expression profile plot

Description

Shiny Module – gene browser expression profile plot

Usage

geneBrowserPlotUI(id, contrasts = FALSE)

geneBrowserPlotServer(
  id,
  gene_id,
  covar,
  exprs,
  annot = NULL,
  cntr = NULL,
  primary_id = "PrimaryID",
  symbol_col = "SYMBOL",
  description_col = "GENENAME",
  annot_linkout = NULL
)

Arguments

id

module identifier (same as the one passed to geneBrowserTableUI)

contrasts

(logical) whether or not create an additional panel next to the plot which can be used to show detailed contrast information for a gene

gene_id

primary identifier of the gene to show. This must be either a list containing at least the element id and possibly the element ds (if multiple datasets are used). Alternatively, it is a reactiveValues object with the same elements.

covar

data frame with all covariates

exprs

expression matrix; row names must correspond to the primary identifiers

annot

(optional) annotation data frame containing column 'PrimaryID' corresponding to the rownames of the contrast data frames

cntr

(optional) list of contrasts

primary_id

name of the column which holds the primary identifiers

symbol_col

name of the column in annot which contains the gene symbols; use NULL if no such column

description_col

name of the column in annot which contains the gene title / description; use NULL if no such column

annot_linkout

a list; see Details.

Details

The gene_id parameter must be a reactive value, because that is the whole point of the plotting module: observe changes to the gene ID and update the plot accordingly.

In contrast, other parameters must not be reactive values. This may change in future to allow for dynamic exchange of data sets.

The parameter annot_linkout is a named list. Names must correspond to columns from the annotation data frame. The elements of the list are character strings containing URLs with the ⁠%s⁠ placeholder. For example, if the column ENSEMBL contains ENSEMBL identifiers, you can link out by specifying

annot_linkout=list(ENSEMBL="https://www.ensembl.org/id/%s")

Value

does not return anything useful

See Also

geneBrowserTableServer(), and gene_browser() for example code.

Examples

mtx <- matrix(rnorm(40, mean=rep(c(0, 1), each=20)), nrow=1)
rownames(mtx) <- "MUZG"
covar <- data.frame(
                    em=rep(LETTERS[1:2], each=20),
                    pstrem=rep(letters[1:20], 2),
                    bzdrem=rnorm(40))
  
if(interactive()) {
   ui  <- fluidPage(geneBrowserPlotUI("gplot", FALSE))
   serv <- function(input, output, session) {
     geneBrowserPlotServer("gplot", list(id="MUZG"), covar, mtx)
   }
   shinyApp(ui, serv)
}

## Example with the C19 dataset
data(C19)
if(interactive()) {
  ui <- fluidPage(
         fluidRow(selectizeInput("id", label="Search for a gene",
           choices=NULL),
         fluidRow(geneBrowserPlotUI("gplot", TRUE))
         ))

  server <- function(input, output, session) {
    gene_id <- reactiveValues()
    updateSelectizeInput(session, "id", choices=C19$annotation$SYMBOL)

    ## translate symbol to primary ID
    observeEvent(input$id, {
      nn <- match(input$id, C19$annotation$SYMBOL)
      gene_id$id <- C19$annotation$PrimaryID[ nn ]
    })

    geneBrowserPlotServer("gplot", gene_id=gene_id, 
                          covar=C19$covariates, 
                          exprs=C19$expression,
                          annot=C19$annotation, 
                          cntr=C19$contrasts
     )
  }
  shinyApp(ui, server)
}

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