Last data update: 2014.03.03

R: Multidimensional scaling plot of distances between digital...
plotMDS.DGEListR Documentation

Multidimensional scaling plot of distances between digital gene expression profiles

Description

Plot samples on a two-dimensional scatterplot so that distances on the plot approximate the expression differences between the samples.

Usage

## S3 method for class 'DGEList'
plotMDS(x, top = 500, labels = NULL, pch = NULL, cex = 1,
	        dim.plot = c(1,2), ndim = max(dim.plot), gene.selection = "pairwise",
	        xlab = NULL, ylab = NULL, method = "logFC", prior.count = 2,
	         ...)

Arguments

x

a DGEList object.

top

number of top genes used to calculate pairwise distances.

labels

character vector of sample names or labels. If x has no column names, then defaults the index of the samples.

pch

plotting symbol or symbols. See points for possible values. Ignored if labels is non-NULL.

cex

numeric vector of plot symbol expansions. See text for possible values.

dim.plot

which two dimensions should be plotted, numeric vector of length two.

ndim

number of dimensions in which data is to be represented

gene.selection

character, "pairwise" to choose the top genes separately for each pairwise comparison between the samples, or "common" to select the same genes for all comparisons. Only used when method="logFC".

xlab

x-axis label

ylab

y-axis label

method

method used to compute distances. Possible values are "logFC" or "bcv".

prior.count

average prior count to be added to observation to shrink the estimated log-fold-changes towards zero. Only used when method="logFC".

...

any other arguments are passed to plot.

Details

The default method (method="logFC") is to convert the counts to log-counts-per-million using cpm and to pass these to the limma plotMDS function. This method calculates distances between samples based on log2 fold changes. See the plotMDS help page for details.

The alternative method (method="bcv") calculates distances based on biological coefficient of variation. A set of top genes are chosen that have largest biological variation between the libraries (those with largest genewise dispersion treating all libraries as one group). Then the distance between each pair of libraries (columns) is the biological coefficient of variation (square root of the common dispersion) between those two libraries alone, using the top genes.

The number of genes (top) chosen for this exercise should roughly correspond to the number of differentially expressed genes with materially large fold-changes. The default setting of 500 genes is widely effective and suitable for routine use, but a smaller value might be chosen for when the samples are distinguished by a specific focused molecular pathway. Very large values (greater than 1000) are not usually so effective.

Note that the "bcv" method is slower than the "logFC" method when there are many libraries.

Value

An object of class MDS is invisibly returned and a plot is created on the current graphics device.

Author(s)

Yunshun Chen, Mark Robinson and Gordon Smyth

See Also

plotMDS, cmdscale, as.dist

Examples

# Simulate DGE data for 1000 genes and 6 samples.
# Samples are in two groups
# First 200 genes are differentially expressed in second group

ngenes <- 1000
nlib <- 6
counts <- matrix(rnbinom(ngenes*nlib, size=1/10, mu=20),ngenes,nlib)
rownames(counts) <- paste("gene",1:ngenes, sep=".")
group <- gl(2,3,labels=c("Grp1","Grp2"))
counts[1:200,group=="Grp2"] <- counts[1:200,group=="Grp2"] + 10
y <- DGEList(counts,group=group)
y <- calcNormFactors(y)

# without labels, indexes of samples are plotted.
col <- as.numeric(group)
mds <- plotMDS(y, top=200, col=col)

# or labels can be provided, here group indicators:
plotMDS(mds, col=col, labels=group)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(edgeR)
Loading required package: limma
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/edgeR/plotMDS.DGEList.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plotMDS.DGEList
> ### Title: Multidimensional scaling plot of distances between digital gene
> ###   expression profiles
> ### Aliases: plotMDS.DGEList
> ### Keywords: hplot
> 
> ### ** Examples
> 
> # Simulate DGE data for 1000 genes and 6 samples.
> # Samples are in two groups
> # First 200 genes are differentially expressed in second group
> 
> ngenes <- 1000
> nlib <- 6
> counts <- matrix(rnbinom(ngenes*nlib, size=1/10, mu=20),ngenes,nlib)
> rownames(counts) <- paste("gene",1:ngenes, sep=".")
> group <- gl(2,3,labels=c("Grp1","Grp2"))
> counts[1:200,group=="Grp2"] <- counts[1:200,group=="Grp2"] + 10
> y <- DGEList(counts,group=group)
> y <- calcNormFactors(y)
> 
> # without labels, indexes of samples are plotted.
> col <- as.numeric(group)
> mds <- plotMDS(y, top=200, col=col)
> 
> # or labels can be provided, here group indicators:
> plotMDS(mds, col=col, labels=group)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>