geneBrowserPlotUI | R Documentation |
Shiny Module – gene browser expression profile plot
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
)
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 |
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 |
description_col |
name of the column in |
annot_linkout |
a list; see 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")
does not return anything useful
geneBrowserTableServer()
, and gene_browser()
for example
code.
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.