Introduction using limma or edgeR

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 and only a single contrast has been performed for simplicity. We can use either limma or edgeR to fit the models and they both share upstream steps in common.

To begin, the DGEList object from the workflow has been included with the package as internal data.

library(Glimma)
library(limma)
library(edgeR)

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

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 plot 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, and for the colours of the points to be changed based on predefined factors. The grouping variables are taken from the samples component of DGEList objects used in limma and edgeR.

glimmaMDS(dge)

Interactions with the plot

In the plot above, try:

Modifications to the plot

Some 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 this plot we first need to run differential expression (DE) analysis for our data. We load in design and contrast matrices generated from the RNAseq123 workflow.

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

Using limma

We fit our DE analysis using voom, this leaves us with an object that contains test statistics for each gene.

Using edgeR

The MA plot can then be created using the fitted object containing the statistics about the genes, and the dge object containing information about the samples and raw counts.

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 and link to them via markdown hyperlinks. Plots can be saved either by providing the html argument a filename, or by using htmlwidgets::saveWidget, which also provides further customisation options.

# creates ma-plot.html in working directory
# link to it in Rmarkdown using [MA-plot](ma-plot.html)
htmlwidgets::saveWidget(glimmaMA(efit, dge = dge), "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