Last data update: 2014.03.03

R: A Function to Make a PCA Plot from an ExpressionSet
plotPCAR Documentation

A Function to Make a PCA Plot from an ExpressionSet

Description

This function makes a PCA plot from an ExpressionSet or matrix

Usage

plotPCA(object, groups = NULL, groupnames = NULL, addtext = NULL,
  x.coord = NULL, y.coord = NULL, screeplot = FALSE, squarepca = FALSE,
  pch = NULL, col = NULL, pcs = c(1, 2), legend = TRUE,
  main = "Principal Components Plot", plot3d = FALSE, outside = FALSE,
  ...)

Arguments

object

An ExpressionSet, matrix or prcomp object.

groups

A numeric vector delineating group membership for samples. Default is NULL, in which case default plotting symbols and colors will be used.

groupnames

A character vector describing the different groups. Default is NULL, in which case the sample names will be used.

addtext

A character vector of additional text to be placed just above the plotting symbol for each sample. This is helpful if there are a lot of samples for identifying e.g., outliers.

x.coord

Pass an x-coordinate if automatic legend placement fails

y.coord

Pass a y-coordinate if automatic legend placement fails.

screeplot

Boolean: Plot a screeplot instead of a PCA plot? Defaults to FALSE.

squarepca

Should the y-axis of the PCA plot be made comparable to the x-axis? This may aid in interpretation of the PCA plot. Defaults to FALSE.

pch

A numeric vector indicating what plotting symbols to use. Default is NULL, in which case default plotting symbols will be used. Note that this argument will override the 'groups' argument.

col

A numeric or character vector indicating what color(s) to use for the plotting symbols. Default is NULL in which case default colors will be used. Note that this argument will override the 'groups' argument.

pcs

A character vector of length two (or three if plot3d is TRUE), indicating which principal components to plot. Defaults to the first two principal components.

legend

Boolean. Should a legend be added to the plot? Defaults to TRUE.

main

A character vector for the plot title.

plot3d

Boolean. If TRUE, then the PCA plot will be rendered in 3D using the rgl package. Defaults to FALSE. Note that the pcs argument should have a length of three in this case.

outside

Boolean. If TRUE the legend will be placed outside the plotting region, at the top right of the plot.

...

Further arguments to be passed to plot. See the help page for plot for further information.

Value

This function returns nothing. It is called only for the side effect of producing a PCA plot or screeplot.

Author(s)

James W. MacDonald <jmacdon@u.washington.edu>

Examples


library("affy")
data(sample.ExpressionSet)
plotPCA(sample.ExpressionSet, groups =
 as.numeric(pData(sample.ExpressionSet)[,2]), groupnames =
 levels(pData(sample.ExpressionSet)[,2]))

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(affycoretools)
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.




Attaching package: 'affycoretools'

The following object is masked from 'package:BiocGenerics':

    plotPCA

Warning message:
replacing previous import 'ggplot2::Position' by 'BiocGenerics::Position' when loading 'ggbio' 
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/affycoretools/plotPCA.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plotPCA
> ### Title: A Function to Make a PCA Plot from an ExpressionSet
> ### Aliases: plotPCA
> ### Keywords: hplot
> 
> ### ** Examples
> 
> 
> library("affy")
> data(sample.ExpressionSet)
> plotPCA(sample.ExpressionSet, groups =
+  as.numeric(pData(sample.ExpressionSet)[,2]), groupnames =
+  levels(pData(sample.ExpressionSet)[,2]))
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>