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.
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:
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
.
In the plot above, try:
Some customisations to the plot include:
glimmaMDS(dge, width=1200, height=1200)
, which will adjust the dimensions in pixels of the created widget - default width and height is 920px.glimmaMDS(dge, continuous.color=TRUE)
, which specifies that continuous colour schemes should be used - useful for when a large number of differential selections are required.glimmaMDS(dge, groups=[vector or data frame])
, which allows changing the associated sample information such as experimental groups - this information is displayed in mouseover tooltips and can be used to adjust the plot using scale_by
, colour_by
and shape_by
.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:
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"))
We fit our DE analysis using voom
, this leaves us with an object that contains test statistics for each gene.
dge <- estimateDisp(dge, design)
gfit <- glmFit(dge, design)
glrt <- glmLRT(gfit, design, contrast = contr.matrix)
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.
In the plot above, try:
Some customisations to the plot include:
glimmaMA(efit, dge=dge, width=1200, height=1200)
, which will adjust the dimensions in pixels of the created widget
glimmaMA(efit, dge=dge, continuous.color=TRUE)
, which specifies that continuous colour schemes should be used
glimmaMA(efit, dge=dge, groups=[vector or data frame])
, which allows changing the associated sample information such as experimental groups
glimmaMA(efit, dge=dge, status.cols=c("powderblue", "seashell", "salmon")
, which customises the colours associated with the status of each gene
glimmaMA(efit, dge=dge, sample.cols=colours)
, which colours each sample based on the character vector of valid CSS colour strings colours
ncol(dge$counts)
or ncol(counts)
if specified.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.
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