DESeq2

Introduction

In this vignette we present the basic features of Glimma. Glimma is an interactive R widget for creating plots for differential expression analysis, created using the Vega and htmlwidgets frameworks. The created plots can be embedded in R Markdown, or exported as standalone HTML documents. The data presented here is slightly modified from the RNAseq123 workflow with only a single contrast has been performed for simplicity. Here we use DESeq2 to fit the model.

To begin, the DGEList object from the workflow has been included with the package as internal data. We will convert this to a DESeq data object.

library(Glimma)
library(edgeR)
library(DESeq2)

dge <- readRDS(system.file("RNAseq123/dge.rds", package = "Glimma"))

dds <- DESeqDataSetFromMatrix(
  countData = dge$counts,
  colData = dge$samples,
  rowData = dge$genes,
  design = ~group
)
#> converting counts to integer mode

MDS Plot

The multidimensional scaling (MDS) plot is frequently used to explore differences in samples. When data has been MDS transformed, the first two dimensions explain the greatest variance between samples, and the amount of variance decreases monotonically with increasing dimension.

The Glimma MDS contains two main components:

  1. a plot showing two MDS dimensions, and
  2. a plot of the eigenvalues of each dimension

The Glimma MDS allows different dimensions to be plotted against each other, with the proportion of variability explained by each dimension highlighted in the barplot alongside it. The interactive MDS plot can be created simply with a single argument for a DESeqDataSet object. The points in the MDS plot can have their size, colour and shape changed based on the information that is stored in the colData of the DESeqDataSet.

glimmaMDS(dds)

Interactions with the plot

In the plot above, try:

Modifications to the pot

Some helpful customisations to the plot include:

MA Plot

The MA plot is a visualisation that plots the log-fold-change between experimental groups (M) against the mean expression across all the samples (A) for each gene.

The Glimma MA plot contains two main components:

  1. a plot of summary statistics across all genes that have been tested, and
  2. a plot of gene expression from individual samples for a given gene

The second plot shows gene expression from the last selected sample, which can be selected from the table or directly from the summary plot.

To create the MA plot we first need to run differential expression (DE) analysis for our data using the DESeq function.

dds <- DESeq(dds, quiet=TRUE)

The MA plot can then be created using the dds object that now contains fitted results.

glimmaMA(dds)
#> 15 of 16624 genes were filtered out in DESeq2 tests

Interactions with the plot

In the plot above, try:

Modifications to the plot

Some customisations to the plot include:

Saving widgets

The plots created are automatically embedded into Rmarkdown reports, but having many interactive plots can significantly slow down the page. It is instead recommended to save the plots using htmlwidgets::saveWidget and linking to it via markdown hyperlinks.

# creates ma-plot.html in working directory
# link to it in Rmarkdown using [MA-plot](ma-plot.html)
htmlwidgets::saveWidget(glimmaMA(dds), "ma-plot.html")

Session Info

sessionInfo()
#> R version 4.0.3 (2020-10-10)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 18.04.5 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.12-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.12-bioc/R/lib/libRlapack.so
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C              
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] parallel  stats4    stats     graphics  grDevices utils     datasets 
#> [8] methods   base     
#> 
#> other attached packages:
#>  [1] DESeq2_1.30.0               SummarizedExperiment_1.20.0
#>  [3] Biobase_2.50.0              MatrixGenerics_1.2.0       
#>  [5] matrixStats_0.57.0          GenomicRanges_1.42.0       
#>  [7] GenomeInfoDb_1.26.0         IRanges_2.24.0             
#>  [9] S4Vectors_0.28.0            BiocGenerics_0.36.0        
#> [11] edgeR_3.32.0                limma_3.46.0               
#> [13] Glimma_2.0.0               
#> 
#> loaded via a namespace (and not attached):
#>  [1] locfit_1.5-9.4         Rcpp_1.0.5             lattice_0.20-41       
#>  [4] digest_0.6.27          R6_2.4.1               RSQLite_2.2.1         
#>  [7] evaluate_0.14          httr_1.4.2             ggplot2_3.3.2         
#> [10] pillar_1.4.6           zlibbioc_1.36.0        rlang_0.4.8           
#> [13] annotate_1.68.0        blob_1.2.1             Matrix_1.2-18         
#> [16] rmarkdown_2.5          splines_4.0.3          BiocParallel_1.24.0   
#> [19] geneplotter_1.68.0     stringr_1.4.0          htmlwidgets_1.5.2     
#> [22] RCurl_1.98-1.2         bit_4.0.4              munsell_0.5.0         
#> [25] DelayedArray_0.16.0    compiler_4.0.3         xfun_0.18             
#> [28] pkgconfig_2.0.3        htmltools_0.5.0        tidyselect_1.1.0      
#> [31] tibble_3.0.4           GenomeInfoDbData_1.2.4 XML_3.99-0.5          
#> [34] crayon_1.3.4           dplyr_1.0.2            bitops_1.0-6          
#> [37] grid_4.0.3             jsonlite_1.7.1         xtable_1.8-4          
#> [40] gtable_0.3.0           lifecycle_0.2.0        DBI_1.1.0             
#> [43] magrittr_1.5           scales_1.1.1           stringi_1.5.3         
#> [46] XVector_0.30.0         genefilter_1.72.0      ellipsis_0.3.1        
#> [49] vctrs_0.3.4            generics_0.0.2         RColorBrewer_1.1-2    
#> [52] tools_4.0.3            bit64_4.0.5            glue_1.4.2            
#> [55] purrr_0.3.4            survival_3.2-7         yaml_2.2.1            
#> [58] AnnotationDbi_1.52.0   colorspace_1.4-1       memoise_1.1.0         
#> [61] knitr_1.30