plot_md: Mean-Difference Plot

View source: R/plot_md.R

plot_mdR Documentation

Mean-Difference Plot

Description

This function plots probewise means vs. log2 fold changes for a test of differential expression or between-sample comparison.

Usage

plot_md(dat, title = "Mean-Difference Plot", legend = "right", ...)

## S3 method for class 'DGEList'
plot_md(
  dat,
  design = NULL,
  sample = 1L,
  ctrls = NULL,
  lfc = NULL,
  size = NULL,
  alpha = NULL,
  title = "Mean-Difference Plot",
  xlab = NULL,
  legend = "right",
  hover = FALSE
)

## S3 method for class 'DESeqDataSet'
plot_md(
  dat,
  sample = 1L,
  ctrls = NULL,
  lfc = NULL,
  size = NULL,
  alpha = NULL,
  title = "Mean-Difference Plot",
  xlab = NULL,
  legend = "right",
  hover = FALSE
)

## S3 method for class 'DESeqTransform'
plot_md(
  dat,
  sample = 1L,
  ctrls = NULL,
  lfc = NULL,
  size = NULL,
  alpha = NULL,
  title = "Mean-Difference Plot",
  xlab = NULL,
  legend = "right",
  hover = FALSE
)

## S3 method for class 'DESeqResults'
plot_md(
  dat,
  fdr = 0.05,
  lfc = NULL,
  size = NULL,
  alpha = NULL,
  title = "Mean-Difference Plot",
  xlab = NULL,
  legend = "right",
  hover = FALSE
)

## S3 method for class 'TopTags'
plot_md(
  dat,
  fdr = 0.05,
  lfc = NULL,
  size = NULL,
  alpha = NULL,
  title = "Mean-Difference Plot",
  xlab = NULL,
  legend = "right",
  hover = FALSE
)

## S3 method for class 'data.frame'
plot_md(
  dat,
  probes = NULL,
  fdr = 0.05,
  lfc = NULL,
  size = NULL,
  alpha = NULL,
  title = "Mean-Difference Plot",
  xlab = NULL,
  legend = "right",
  hover = FALSE
)

## Default S3 method:
plot_md(
  dat,
  sample = 1L,
  ctrls = NULL,
  lfc = NULL,
  size = NULL,
  alpha = NULL,
  title = "Mean-Difference Plot",
  xlab = NULL,
  legend = "right",
  hover = FALSE
)

Arguments

dat

Either a data frame representing the results of a test for differential expression, or a probe by sample omic data matrix. The former will render a study-wide MD plot, the latter a between-sample MD plot. Suitable objects from familiar packages are also acceptable. See Details.

title

Optional plot title.

legend

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

design

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

sample

Column number or name specifying which sample in dat to compare with the others. Only relevant for between-sample MD plots.

ctrls

Optional vector of length equal to nrow(dat) indicating the control status of each probe. Only relevant for between-sample MD plots.

lfc

Optional effect size threshold for declaring a probe differentially expressed. Only relevant for study-wide MD plots.

size

Point size.

alpha

Point transparency.

xlab

Optional label for x-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.

fdr

Optional significance threshold for declaring a probe differentially expressed. Only relevant for study-wide MD plots.

probes

Optional column number or name specifying where probe names are stored, presuming they are not stored in rownames(dat).

Details

MD plots (also known as "Bland-Altman plots" or "MA plots") visualize the relationship between a probe's mean value and its log2 fold change versus some relevant reference group. These figures help to evaluate the symmetry, magnitude, and significance of differential effects across the full omic range.

If dat summarizes the results of a test for differential expression, then each point's x-coordinate correponds to its average expression across all samples, while y-coordinates represent the log2 fold change for the given contrast. Points are colored to distinguish between those that do and do not meet a user-defined FDR threshold. plot_md accepts output from limma::topTable, edgeR::topTags, or DESeq2::results. Alternatively, any object with columns for log fold changes, probewise means, and FDR is acceptable.

If dat is probe by sample matrix or matrix-like object, then sample must be specified. An artificial array is created by averaging probewise values for all other samples in the data. The figure will then represent the mean vs. the difference of expression values for the specified sample vs. the artificial array. Acceptable inputs for between-sample MD plots include all limma expression set objects, as well as DGEList, DESeqDataSet, and DESeqTransform objects.

References

Bolstad, B.M., Irizarry, R.A., Åstrand, M. & Speed, T.P. (2003). A comparison of normalization methods for high density oligonucleotide array data based on variance and bias. Bioinformatics, 19(2): 185–193.

Dudoit, S., Yang, Y.H., Callow, M.J. & Speed, T.P. (2002). Statistical methods for identifying differentially expressed genes in replicated cDNA microarray experiments. Stat. Sin., 12, 111–140.

Martin, B.J. & Altman, D.G. (1986). Statistical methods for assessing agreement between two methods of clinical measurement. The Lancet, 327(8476): 307–310.

Ritchie, M.E., Phipson, B., Wu, D., Hu, Y., Law, C.W., Shi, W., & Smyth, G.K. (2015). limma powers differential expression analyses for RNA-sequencing and microarray studies. Nucleic Acids Res., 43(7): e47.

See Also

plotMD, plotMA, glMDPlot

Examples

library(DESeq2)
dds <- makeExampleDESeqDataSet()

# Between-sample MD plot
rld <- rlog(dds)
plot_md(rld)

# Study-wide MD plot
dds <- DESeq(dds)
res <- results(dds)
plot_md(res)


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