Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plotPCA

Sample PCA plot for transformed data


Description

This plot helps to check for batch effects and the like.

Usage

## S4 method for signature 'DESeqTransform'
plotPCA(object, intgroup = "condition", ntop = 500, returnData = FALSE)

Arguments

object

a DESeqTransform object, with data in assay(x), produced for example by either rlog or varianceStabilizingTransformation.

intgroup

interesting groups: a character vector of names in colData(x) to use for grouping

ntop

number of top genes to use for principal components, selected by highest row variance

returnData

should the function only return the data.frame of PC1 and PC2 with intgroup covariates for custom plotting (default is FALSE)

Value

An object created by ggplot, which can be assigned and further customized.

Note

See the vignette for an example of variance stabilization and PCA plots. Note that the source code of plotPCA is very simple. The source can be found by typing DESeq2:::plotPCA.DESeqTransform or getMethod("plotPCA","DESeqTransform"), or browsed on github at https://github.com/mikelove/DESeq2/blob/master/R/plots.R Users should find it easy to customize this function.

Author(s)

Wolfgang Huber

Examples

# using rlog transformed data:
dds <- makeExampleDESeqDataSet(betaSD=1)
rld <- rlog(dds)
plotPCA(rld)

# also possible to perform custom transformation:
dds <- estimateSizeFactors(dds)
# shifted log of normalized counts
se <- SummarizedExperiment(log2(counts(dds, normalized=TRUE) + 1),
                           colData=colData(dds))
# the call to DESeqTransform() is needed to
# trigger our plotPCA method.
plotPCA( DESeqTransform( se ) )

DESeq2

Differential gene expression analysis based on the negative binomial distribution

v1.30.1
LGPL (>= 3)
Authors
Michael Love [aut, cre], Constantin Ahlmann-Eltze [ctb], Kwame Forbes [ctb], Simon Anders [aut, ctb], Wolfgang Huber [aut, ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.