Git Product home page Git Product logo

ibet's Introduction

iBET - interactive Bioinformatics Exploratory Tools

Generating static reports from R markdown documents is a common way to distribute bioinformatics analyses with additional context and commentary. However, interactivity within these reports is limited. While one can embed minimally interactive figures in HTML reports, there is no way to alter the underlying data or plot by the end user.

Shiny provides an avenue to overcome this limitation, as Shiny widgets can be designed to interactively perform or display the results of an analysis. This comes with the downside that the Rmd file and necessary code must be hosted on a server that can run Shiny applications and interactive documents. Options include RStudio Connect, shiny.apps.io (which has a free tier), and Shiny Server.

iBET (interactive Bioinformatics Exploratory Tools) is an R package that contains drop-in Shiny widgets that run and/or display the results of common analyses performed with bioinformatics R packages. These empower end-users to fully immerse themselves in the data through interactive alterations of plot and analysis parameters. They are excellent tools for collaborative data wading and exploration and function well both as stand-alone apps or within Rmd files hosted on Shiny Servers.

Installation

This package is in development - it may break at any time and contain unstable or untested features. A stable version will be submitted to CRAN or Bioconductor once the initially planned features are completed.

To install the package via Github:

install.packages("devtools")
devtools::install_github("j-andrews7/iBET")

Usage

iBET currently contains three interactive widgets - shinyPCAtools, shinyDESeq2, and shinyDECorr. They can be dropped into Rmd documents or ran directly within RStudio as shown below.

I highly recommend altering the width of your Rmd report by using a CSS block at the top of your document (right after the YAML header). This will use much more of the page, which makes using the widgets much easier. The following works well on most screens with no scaling:

```{css, echo=FALSE}
body {
  max-width: 1850px !important;
}
div.main-container {
  max-width: 1850px !important;
  width: 1850px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
.toc-content {
  padding-right: 0px;
  padding-left: 0px;
  margin-left: 300px;
  max-width: 1550px !important;
  width: 1550px !important;
}

Load Example Data

shh <- suppressPackageStartupMessages
shh(library("airway"))
shh(library("magrittr"))
shh(library("DESeq2"))
shh(library("PCAtools"))
shh(library("iBET"))

data("airway")
airway$dex <- relevel(airway$dex, ref = "untrt")
dds <- DESeqDataSet(airway, design = ~ cell)
dds <- DESeq(dds)
vst <- assay(vst(dds))

Interactive PCA via PCAtools

PCAtools is a straight-forward package for principle component analysis.

shinyPCAtools(vst, metadata = colData(dds), annot.by = c("cell", "dex"), 
              color.by = "dex", shape.by = "cell", scale = TRUE, height = 850)

Larger (scRNA) Dataset

shinyPCAtools Works well on larger datasets, though it takes significant time for the PCA to run. Removing a much greater percentage of features is highly recommended.

shh(library("scRNAseq"))
shh(library("scran"))
shh(library("scuttle"))
shh(library("scater"))
data <- ZeiselBrainData()
 
# # Remove genes expressed in few cells.
data <- data[rowMeans(counts(data) != 0) > 0.05, ]
data <- computeSumFactors(data, cluster = quickCluster(data))
data <- logNormCounts(data)
data$Cell.Type <- factor(data$level1class)

shinyPCAtools(logcounts(data), metadata = colData(data), annot.by = c("Cell.Type", "tissue", "age"), 
              color.by = "Cell.Type", removeVar = 0.9, scale = TRUE)

Interactive Differential Expression via DESeq2

This widget was heavily inspired by the interactivate function from the InteractiveComplexHeatmap package. It wraps DESeq2 and will run differential expression analysis if not provided a results dataframe as well.

Gene labels can be added to the MAplot and volcano plot by clicking a point. The labels can also be dragged around, though adding labels will reset the position, so it's recommended to add all labels prior to re-positioning them. Gene sets can be highlighted easily if provided.

Multiple comparisons can also be provided for switching between analyses quickly.

deseq.res1 <- results(dds, contrast = c("dex", "trt", "untrt"))
dds <- DESeqDataSet(airway, design = ~ cell)
dds <- DESeq(dds)
deseq.res2 <- results(dds, contrast = c("cell", "N080611", "N052611"))
deseq.res3 <- results(dds, contrast = c("cell", "N61311", "N080611"))
deseq.res4 <- results(dds, contrast = c("cell", "N080611", "N61311"))
res <- list("trt v untrt" = as.data.frame(deseq.res1), 
            "N080611vN052611" = as.data.frame(deseq.res2), 
            "N61311vN080611" = as.data.frame(deseq.res3), 
            "N080611vN61311" = as.data.frame(deseq.res4))

shinyDESeq2(dds, res = res, genesets = hs.msig, annot.by = c("cell", "dex"))

Correlating DE Results

This widget creates scatter plots for arbitrary combinations of DE results. It takes a named list of dataframes as input and will plot scatter plots of log2 Fold Change values for each gene. It accepts up to 4 results dataframes and will generate plots for all combinations of them along with a regression line and correlation testing. Points are colored by significance in each DE analysis. Results dataframes from edgeR, limma, and DESeq2 will automatically have the appropriate columns used for plotting, but users can also provide the column names for their significance value or fold change column as necessary.

Gene labels can be added to a plot by clicking a point. The labels can also be dragged around, though adding labels to a plot will reset the label positions for said plot, so it's recommended to add all labels prior to re-positioning them.

shinyDECorr(res, genesets = hs.msig, height = 800)

ibet's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ibet's Issues

`shinyDESeq2` error and solution

Hello @j-andrews7 ,

I followed the README and ran shinyPCAtools, shinyDESeq2, and shinyDECorr. Both shinyPCAtools and shinyDECorr showed amazing interactive views and I will try them on my project datasets.

However, shinyDESeq2 gave me the following error:
Error in DESeq2::lfcShrink(dds, coef = coef, lfcThreshold = lfcThreshold) : coef %in% resultsNamesDDS is not TRUE

I proceeded as follows and got it running:

> resultsNames(dds)
[1] "Intercept"               "cell_N061011_vs_N052611" "cell_N080611_vs_N052611" "cell_N61311_vs_N052611" 
> colData(dds)
> res = results(dds)
> shinyDESeq2(dds, res=res, coef = "dex_trt_vs_untrt", annot.by = c("cell", "dex"))

Even though R documentation for res says "If not provided, it will be generated from the dds object via lfcShrink or results and coef", but shinyDESeq2 did not run without that.

I know its a minor issue, just thought of letting you know in case someone else try it. :-)

Thanks.
Gurpreet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.