shinyngs | R Documentation |
shinyngs is a package for downstream visualisation of data stored in
SummarizedExperiment
-like objects, produced as a end-point of
bioinformatics analysis workflows.
What follows is technical documentation for the package, use
vignette('shinyngs')
to get more user-friendly information on package
usage.
This package makes use of many packages, and is indebted to their developers. Shiny provides the overall framework that made the current work possible, and Plotly has been key to making the included visualisations as dynamic and useful as they are.
Plotly's R interface has changed markedly between versions, and
shinyngs
is currently dependent on a version later than the (now
somewhat old) version on CRAN. This should therefore be installed from
GitHub: devtools::install_github('ropensci/plotly',
upgrade_dependencies = FALSE)
.
shinyngs
defines two new data
structures. The first, ExploratorySummarizedExperiment
simply
takes SummarizedExperiment, and adds some slots to allow extra description
around experiments. These extra slots are not compulsory, however, and a
simple SummarizedExperiment can be converted directly into an
ExploratorySummarizedExperiment
:
ese <- as(airway, 'ExploratorySummarizedExperiment')
Because a single ExploratorySummarizedExperiment
is limited to one
set of features, ExploratorySummarizedExperimentList
was
devised to allow incorporation of other feature sets. For example, we might
want to visualise expression in terms of both transcripts and genes.
ExploratorySummarizedExperimentList
is just a list of
ExploratorySummarizedExperiment
s, with some additonal slots
pertaining to a study as a whole.
To use shinyngs
, data is assumed to be in these formats. I'm not
terribly happy with the structure of some of the slots in these objects,
and they may be open to 'improvement' in the future.
An example based on the Zhang et al study of neurons and glia (http://www.jneurosci.org/content/34/36/11929.long) is included in the package, and can be picked apart to further understand the data structure.
The functionality of shinyngs
revolves around
Shiny's concept of modules
(http://shiny.rstudio.com/articles/modules.html), so this bears some
explanation.
Modules allow essentially object-oriented coding for Shiny, and the hiving
of of code into namespaces such that it can be re-used in different parts
of an application without interfering with itself. shinyngs
has many
modules that provide various functionalities.
Each module will have server and UI functions that
provide processing and UI functionality respectively. For example, the
dendro
module, which provides sample clustering dengrograms, has
dendroInput
, which provides user interface components to
determine clustering method etc, and dendro
, which parses
those inputs and calls the appropriate functions to generate a dendrogram.
dendroOutput
provides elements that display the outputs when
they're ready. These functions are all present in dendro.R.
Any application seeking to create dendrograms need only
call dendroInput
dendroOutput
in the parts of
their application where inputs and outputs should appear, and then use
callModule
(again using the same ID) to activate them.
dendroInput(ns('dendro'), eselist) dendroOutput(ns('dendro')) callModule(dendro, 'dendro', eselist)
These module functions are not currently exported, not currenlty being
intended for use outside shinyngs
. This may change.
Usage of modules defined in shinyngs
is envisaged to be
predominantly via prepareApp
. For most modules, this passes
its arguments to simpleApp
, which very simply takes its
ExploratorySummarizedExperimentList
and a module name, and attempts
to call the UI and server functions of that module, creating a simple
sidebar layout. Taking our dendro app and using the airway
example
data:
data(airway, package = 'airway') ese <- as(airway, 'ExploratorySummarizedExperiment') eselist <- ExploratorySummarizedExperimentList(ese) app <- prepareApp('heatmap',eselist)
Other apps, for example rnaseq
require more complex layouts
and don't use simpleApp
.
prepareApp
returns list with UI and server applications components.
Shiny's shinyApp
must then be called to actually run
the app: shiny::shinyApp(ui = app$ui, server = app$server)
.
Assuming a ExploratorySummarizedExperimentList
has been serialised
with link[base]{saveRDS}
, the Shiny app can be deployed to a server
in a script called 'app.R' with content like this:
library(shinyngs) mydata <- readRDS('data.rds') app <- prepareApp('rnaseq', mydata) shiny::shinyApp(app$ui, app$server)
There are three varieties of module in shinyngs
. Top-level modules
such as rnaseq
provide complex data mining tools pulling together a
number of other modules. Some of those sub-modules can also be called
stand-alone to make heatmaps or dendrograms, for example. Other modules just
provide small components that don't make sense in isolation. This is the full
set at the time of writing:
Pull together PCA analysis, heat maps, dendgrograms, volcano plots, gene sets etc to make a comprehensive data mining tool.
Currenlty a near clone of rnaseq
, to
be optimised for ChIP-seq in due course.
These modules can also be called directly with prepareApp
:
Provide access to asay matrices of input object
Make quartile/ boxplots
Make sample-clustering dendgrograms.
Differential exon usage plot (where relevant slot populated)
Differential exon usage table (where relevant slot populated)
Differential table showing summarised group values and fold changes etc (where contrasts slot is populated).
Display colData() output from selected
ExploratorySummarizedExperiment
Plot mean values of one condition against another (where contrasts slot is populated)
Show expression plots and other available data for selected features
Display content of the
gene_set_analyses
slot for the selected
ExploratorySummarizedExperiment
Make a
barcode plot using selected data and limma
's
barcodeplot
Build heatmaps from selected matrix data. By default this is an expression matrix, but it can also be sample vs sample correlation heatmaps or PCA vs covariate association heatmaps.
Uses the scatterplot
module to plot mean
expression vs fold change
Plots 2D or 3D PCA and loading plots
based on selected matrix data, using the scatterplot
module
Makes bar plots and tables of read counts data where
provided in the read_reports
slot of an
ExploratorySummarizedExperimentList
Displays data
from the metadata slot of a ExploratorySummarizedExperiment
object
(accessed via mcols
)
Uses the scatterplot
module to plot fold change vs p value (where necessary slots are populated
These modules are only valid as components of applications created by other modules:
Used by readreports, for example. Requires reactive providing input data
Provides data on sample group
comparisons, using the contrasts
slot of the input object (where
available)
Provides selection filters for assay matrix
rows. Used mainly by the selectmatrix
module
Uses
Selectize to provide an
autocomplete field to select from available gene sets (where provided in the
gene_sets
slot)
Provides a UI element to choose from
the group_vars
in a SummarizedExperment. Useful for coloring in a PCA
etc
This module provides an input which allows
filtering on the basis of row IDs, labels, or other data in the metadata slot
of an ExploratorySummarizedExperiment
uses modals from shinyBS to create overlaid text for the current panel which displays when a link is clicked
Provides a download button for displayed plots
Allows a subset of columns to be selected from the selected assay matrix
A generic module for producing
scatter plots using Plotly's plot_ly
method. Used by
multiple other modules, including foldchangeplot
and
volcanoplot
A set of controls for scatter plots. Separation of controls in this module allows them to be used in multiple scatter plot instances. For example, both PCA and loading plots can be run off the same set of controls
Provides
functionality central to shinyngs
. Uses filtes on experiment and
assay, along with sampleselect
and geneselect
, to select parts
of input matrices for use by most other shinyngs
modules
A useful generic module that takes a reactive which returns a matrix, and both displays that table and produces a download button
Module which takes a matrix and a factor which groups columns, and summarises by a supplied method, mean by default
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.