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) readRDS(system.file("RNAseq123/dge.rds", package = "Glimma"))dge <-
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
In the plot above, try:
Adjusting plot size
glimmaMDS(dge, width=1200, height=1200)
Users can specify the width and height of the MDS plot widget in pixels. The default width and height are 900 and 500 respectively.
Continuous colour schemes
This argument specifies that continuous colour schemes should be used, which can be useful for colouring samples by their expression for a particular gene.
Custom experimental groups
glimmaMDS(dge, groups=[vector or data frame])
This allows the user to change the associated sample information such as experimental groups. This information is displayed in mouseover tooltips and can be used to adjust the plot using
The MA plot is a visualisation that plots the log-fold-change between experimental groups (M) against the average 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 need to run differential expression (DE) analysis for our data using either the
limma package or the
edgeR package (both are shown below). First, we load in design and contrast matrices generated from the RNAseq123 workflow.
readRDS( design <-system.file("RNAseq123/design.rds", package = "Glimma")) readRDS( contr.matrix <-system.file("RNAseq123/contr.matrix.rds", package = "Glimma"))
We fit our DE analysis using
limma to give us an object that contains test statistics for each gene.
voom(dge, design) v <- lmFit(v, design) vfit <- contrasts.fit(vfit, contrasts = contr.matrix) vfit <- eBayes(vfit)efit <-
Alternatively, we can fit our DE analysis using
estimateDisp(dge, design) dge <- glmFit(dge, design) gfit <- glmLRT(gfit, design, contrast = contr.matrix)glrt <-
The MA plot can then be created using the fitted object containing the statistics about the genes (either
glrt), and the
dge object containing raw counts and information about the samples. We use results from
limma in the following example:
glimmaMA(efit, dge = dge) # glimmaMA(glrt, dge = dge) to use edgeR results