plotPCA.prcomp | R Documentation |
plotPCA
is designed to visualize sample relationships revealed by PCA
analysis of high-dimensional expression data. It is adapted from the
biplot
function in the stats
package, with functionalities
useful for sample visualization and labelling, and removing the
visualization of features (usually genes) in the input matrix. The rationale
is that in most cases there are too many features to provide an informative
visualization.
## S3 method for class 'prcomp'
plotPCA(
x,
choices = c(1, 2),
text = FALSE,
points = list(pch = NULL, col = NULL, cex = NULL, bg = NULL, lwd = NULL, lty = NULL,
order = NULL),
arrows = FALSE,
grid = FALSE,
abline = FALSE,
xlim = NULL,
ylim = NULL,
xlab = NULL,
ylab = NULL,
offset,
main = NULL,
reverse = c(FALSE, FALSE),
...
)
x |
|
choices |
An integer vector of length 2, indicating which PCs to visualize. By default the first (X-axis) and second (Y-axis) are visualized |
text |
A logical value or a list of options to label samples. See Details. |
points |
A logical value or a list of options to pinpoint samples. See details. |
arrows |
A logical or a list of options to draw arrows. |
grid |
Logical value, indicating whether grid lines should be added to the plot. |
abline |
A logical or a list of options to draw abline |
xlim |
xlim of the plot. Automatically determined if missing. |
ylim |
ylim of the plot. Automatically determined if missing. |
xlab |
xlab of the plot. If missing, the PC and the explained variability are shown. |
ylab |
ylab of the plot. If missing, the PC and the explained variability are shown. |
offset |
Offset should be either one or more rows's names in the loading matrix, or indices, or a logical vector. The average loading of the rows specified by offset is set to zero. |
main |
Title of the plot |
reverse |
ogical of length 2 or 1 (which will be repeated to 2), indicating whether the sign of values in the 1st/2nd axis should be reversed. |
... |
Other parameters passed to |
The values for text
, points
and arrows
can be
Logical. If FALSE
, no text or point is added.
List. A list containing options passed to text
, points
,
and arrows
respectively, such as col
, cex
, lwd
,
lty
, code
, length
,angle
, and pos
(only
for text
). order
decides in what order are the points drawn,
which can be useful when there are points to be drawn 'above' other points.
A vector of character strigns (only for text
)
See examples below.
The value of the rotated data, namely the centered (and scaled if requested) data multiplied by the rotation matrix.
prcomp
should be called with retx=TRUE
, which is the
default behaviour.
prcomp
and pcaScores
testVal <- matrix(rnorm(10000), nrow=500)
colnames(testVal) <- paste("Sample", 1:ncol(testVal), sep="")
rownames(testVal) <- paste("Gene",1:nrow(testVal), sep="")
testPCA <- prcomp(t(testVal), center=TRUE, scale=TRUE)
plotPCA(testPCA)
plotPCA(testPCA, points=FALSE, text=TRUE, grid=TRUE)
pointsList <- list(col=1:3, bg=21,pch=22, cex=4:1, lwd=1:2, lty=2:4)
textList <- list(col=c("orange", "royalblue"), cex=1.2, srt=15, pos=1)
plotPCA(testPCA, choices=c(1,2), grid=TRUE, points=pointsList,
text=TRUE)
## visualize dimension 1:3
rop <- par(mfrow=c(1,2), pty="s")
plotPCA(testPCA, choices=c(1,2), grid=TRUE, points=pointsList, text=textList)
plotPCA(testPCA, choices=c(2,3), grid=TRUE, points=pointsList, text=textList)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.