plot_mv: Mean-Variance Plot

View source: R/plot_mv.R

plot_mvR Documentation

Mean-Variance Plot

Description

This function visualizes the mean-variance relationship of omic data before or after modeling.

Usage

plot_mv(
  dat,
  trans = "rank",
  title = "Mean-Variance Plot",
  legend = "right",
  ...
)

## S3 method for class 'MArrayLM'
plot_mv(
  dat,
  trans = "log",
  span = 0.5,
  size = NULL,
  alpha = NULL,
  title = "Mean-Variance Plot",
  xlab = NULL,
  ylab = NULL,
  legend = "right",
  hover = FALSE
)

## S3 method for class 'DGEList'
plot_mv(
  dat,
  design = NULL,
  trans = "sqrt",
  span = 0.5,
  size = NULL,
  alpha = NULL,
  title = "Mean-Variance Plot",
  xlab = NULL,
  ylab = NULL,
  legend = "right",
  hover = FALSE
)

## S3 method for class 'DGELM'
plot_mv(
  dat,
  trans = "sqrt",
  span = 0.5,
  size = NULL,
  alpha = NULL,
  title = "Mean-Variance Plot",
  xlab = NULL,
  ylab = NULL,
  legend = "right",
  hover = FALSE
)

## S3 method for class 'DESeqDataSet'
plot_mv(
  dat,
  resid = FALSE,
  trans = "rank",
  span = 0.5,
  size = NULL,
  alpha = NULL,
  title = "Mean-Variance Plot",
  xlab = NULL,
  ylab = NULL,
  legend = "right",
  hover = FALSE
)

## S3 method for class 'DESeqTransform'
plot_mv(
  dat,
  trans = "rank",
  span = 0.5,
  size = NULL,
  alpha = NULL,
  title = "Mean-Variance Plot",
  xlab = NULL,
  ylab = NULL,
  legend = "right",
  hover = FALSE
)

## Default S3 method:
plot_mv(
  dat,
  trans = "rank",
  span = 0.5,
  size = NULL,
  alpha = NULL,
  title = "Mean-Variance Plot",
  xlab = NULL,
  ylab = NULL,
  legend = "right",
  hover = FALSE
)

Arguments

dat

Omic data matrix or matrix-like object with rows corresponding to probes and columns to samples. Data are presumed to be filtered and normalized prior to visualization. Alternatively, any object from the limma, edgeR, or DESeq2 pipelines. See Details.

trans

Data transformation to be applied to probewise means (if trans = "rank") or standard deviations (if trans = "log" or "sqrt"). Not all transformations are appropriate for all data types. See Details.

title

Optional plot title.

legend

Legend position. Must be one of "bottom", "left", "top", "right", "bottomright", "bottomleft", "topleft", or "topright".

span

Width of the LOWESS smoothing window as a proportion.

size

Point size.

alpha

Point transparency.

xlab

Optional label for x-axis.

ylab

Optional label for y-axis.

hover

Show probe name by hovering mouse over data point? If TRUE, the plot is rendered in HTML and will either open in your browser's graphic display or appear in the RStudio viewer. Probe names are extracted from dat.

design

Optional design matrix with rows corresponding to samples and columns to coefficients to be estimated. Only relevant for DGEList objects. See Details.

resid

Should y-axis plot genewise variance or residual variance? Only relevant for DESeqDataSets that have been fit with a negative binomial model. See Details.

Details

Mean-variance (MV) plots are a quick and easy way to visualize the relationship between the first two moments of probewise data distributions. When used prior to modeling, they may help better understand the internal structure of the data and inspect for potential outliers. The effects of filtering and transformations can also be readily evaluated. When applied after modeling, MV plots help assess the assumptions of the regression.

If dat is a matrix or object inheriting from the ExpressionSet class, then it is presumed to be filtered and normalized prior to plotting. For count data, this means undergoing some sort of variance stabilizing transformation, such as cpm (with log = TRUE), vst, rlog, etc. If dat is of class MArrayLM or DGEGLM, then the y-axis represents residual variance. For DESeqDataSets, the choice of whether to plot variance or residual variance is determined by the resid argument. For data that has been fit with a negative binomial model, a residual matrix is generated by subtracting the normalized signal matrix from the normalized counts on the log2-CPM scale.

Default setting for the trans argument vary by S3 class. When trans = 'rank', rank-transformed means are plotted against standard deviations for each probe. This is a reasonable choice for most data types. It is also common in the microarray literature to plot probewise means against log-transformed standard deviations, while the limma authors recommend the square-root transform for count data on the log2-CPM scale.

Note that if passing a matrix of log2-CPM transformed counts, the plot will not be exactly the same as the output of voom when plot = TRUE. This is because the voom transform involves an initial modeling step in which probewise means are plotted against square-root transformed residual standard deviations on the log2-CPM scale. See plot_voom to recreate the voom transformation plot in bioplotr style.

plot_mv fits a LOWESS curve to the points with a smoothing window given by span. If dat is an MArrayLM object with standard errors moderated by eBayes, then prior variance will also be plotted as either a horizontal line or a smooth curve, depending on whether a global or intensity-dependent prior was used. If robust empirical Bayes was used to create dat, outlier variances are highlighted. See squeezeVar for more details.

References

Huber, W., Hedebreck, A., Sültmann, H., Poustka, A. & Vingron, M. (2002). Variance Stabilization Applied to Microarray Data Calibration and to the Quantification of Differential Expression. Bioinformatics, 18(1), S96-2104.

Sartor, M.A., Tomlinson, C.R., Wesselkamper, S.C., Sivaganesan, S., Leikauf, G.D. & Medvedovic, M. (2006). Intensity-based hierarchical Bayes method improves testing for differentially expressed genes in microarray experiments. BMC Bioinformatics, 7: 538.

Law, C.W., Chen, Y., Shi, W., & Smyth, G.K. (2014). voom: precision weights unlock linear model analysis tools for RNA-seq read counts. Genome Biology, 15: R29.

See Also

plotMeanVar, dglmStdResid, meanSdPlot, plotSA, voom

Examples

mat <- matrix(rnorm(1000 * 10), nrow = 1000, ncol = 10)
plot_mv(mat, trans = "log")

library(limma)
grp <- rep(c("ctl", "trt"), each = 5)
des <- model.matrix(~ grp)
fit <- eBayes(lmFit(mat, des), trend = TRUE)
plot_mv(fit)


dswatson/bioplotr documentation built on March 3, 2023, 9:43 p.m.