Description Usage Arguments Details Value Author(s) Examples
Plot the component loadings for selected principal components / eigenvectors and label variables driving variation along these.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | plotloadings(
pcaobj,
components = getComponents(pcaobj, seq_len(5)),
rangeRetain = 0.05,
absolute = FALSE,
col = c("gold", "white", "royalblue"),
colMidpoint = 0,
shape = 21,
shapeSizeRange = c(10, 10),
legendPosition = "top",
legendLabSize = 10,
legendIconSize = 3,
xlim = NULL,
ylim = NULL,
labSize = 2,
labhjust = 1.5,
labvjust = 0,
drawConnectors = TRUE,
positionConnectors = "right",
widthConnectors = 0.5,
typeConnectors = "closed",
endsConnectors = "first",
lengthConnectors = unit(0.01, "npc"),
colConnectors = "grey50",
xlab = "Principal component",
xlabAngle = 0,
xlabhjust = 0.5,
xlabvjust = 0.5,
ylab = "Component loading",
ylabAngle = 0,
ylabhjust = 0.5,
ylabvjust = 0.5,
axisLabSize = 16,
title = "",
subtitle = "",
caption = "",
titleLabSize = 16,
subtitleLabSize = 12,
captionLabSize = 12,
hline = c(0),
hlineType = "longdash",
hlineCol = "black",
hlineWidth = 0.4,
vline = NULL,
vlineType = "longdash",
vlineCol = "black",
vlineWidth = 0.4,
gridlines.major = TRUE,
gridlines.minor = TRUE,
borderWidth = 0.8,
borderColour = "black",
returnPlot = TRUE
)
|
pcaobj |
Object of class 'pca' created by pca(). |
components |
The principal components to be included in the plot. |
rangeRetain |
Cut-off value for retaining variables. The function will look across each specified principal component and retain the variables that fall within this top/bottom fraction of the loadings range. |
absolute |
Logical, indicating whether or not to plot absolute loadings. |
col |
Colours used for generation of fill gradient according to loadings values. Can be 2 or 3 colours. |
colMidpoint |
Mid-point (loading) for the colour range. |
shape |
Shape of the plotted points. |
shapeSizeRange |
Size range for the plotted points (min, max). |
legendPosition |
Position of legend ('top', 'bottom', 'left', 'right', 'none'). |
legendLabSize |
Size of plot legend text. |
legendIconSize |
Size of plot legend icons / symbols. |
xlim |
Limits of the x-axis. |
ylim |
Limits of the y-axis. |
labSize |
Size of labels. |
labhjust |
Horizontal adjustment of label. |
labvjust |
Vertical adjustment of label. |
drawConnectors |
Logical, indicating whether or not to connect plot labels to their corresponding points by line connectors. |
positionConnectors |
Position of the connectors and their labels with respect to the plotted points ('left', 'right'). |
widthConnectors |
Line width of connectors. |
typeConnectors |
Have the arrow head open or filled ('closed')? ('open', 'closed'). |
endsConnectors |
Which end of connectors to draw arrow head? ('last', 'first', 'both'). |
lengthConnectors |
Length of the connectors. |
colConnectors |
Line colour of connectors. |
xlab |
Label for x-axis. |
xlabAngle |
Rotation angle of x-axis labels. |
xlabhjust |
Horizontal adjustment of x-axis labels. |
xlabvjust |
Vertical adjustment of x-axis labels. |
ylab |
Label for y-axis. |
ylabAngle |
Rotation angle of y-axis labels. |
ylabhjust |
Horizontal adjustment of y-axis labels. |
ylabvjust |
Vertical adjustment of y-axis labels. |
axisLabSize |
Size of x- and y-axis labels. |
title |
Plot title. |
subtitle |
Plot subtitle. |
caption |
Plot caption. |
titleLabSize |
Size of plot title. |
subtitleLabSize |
Size of plot subtitle. |
captionLabSize |
Size of plot caption. |
hline |
Draw one or more horizontal lines passing through this/these values on y-axis. For single values, only a single numerical value is necessary. For multiple lines, pass these as a vector, e.g., c(60,90). |
hlineType |
Line type for hline ('blank', 'solid', 'dashed', 'dotted', 'dotdash', 'longdash', 'twodash'). |
hlineCol |
Colour of hline. |
hlineWidth |
Width of hline. |
vline |
Draw one or more vertical lines passing through this/these values on x-axis. For single values, only a single numerical value is necessary. For multiple lines, pass these as a vector, e.g., c(60,90). |
vlineType |
Line type for vline ('blank', 'solid', 'dashed', 'dotted', 'dotdash', 'longdash', 'twodash'). |
vlineCol |
Colour of vline. |
vlineWidth |
Width of vline. |
gridlines.major |
Logical, indicating whether or not to draw major gridlines. |
gridlines.minor |
Logical, indicating whether or not to draw minor gridlines. |
borderWidth |
Width of the border on the x and y axes. |
borderColour |
Colour of the border on the x and y axes. |
returnPlot |
Logical, indicating whether or not to return the plot object. |
Plot the component loadings for selected principal components / eigenvectors and label variables driving variation along these.
A ggplot2
object.
Kevin Blighe <kevin@clinicalbioinformatics.co.uk>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | options(scipen=10)
options(digits=6)
col <- 20
row <- 20000
mat1 <- matrix(
rexp(col*row, rate = 0.1),
ncol = col)
rownames(mat1) <- paste0('gene', 1:nrow(mat1))
colnames(mat1) <- paste0('sample', 1:ncol(mat1))
mat2 <- matrix(
rexp(col*row, rate = 0.1),
ncol = col)
rownames(mat2) <- paste0('gene', 1:nrow(mat2))
colnames(mat2) <- paste0('sample', (ncol(mat1)+1):(ncol(mat1)+ncol(mat2)))
mat <- cbind(mat1, mat2)
metadata <- data.frame(row.names = colnames(mat))
metadata$Group <- rep(NA, ncol(mat))
metadata$Group[seq(1,40,2)] <- 'A'
metadata$Group[seq(2,40,2)] <- 'B'
metadata$CRP <- sample.int(100, size=ncol(mat), replace=TRUE)
metadata$ESR <- sample.int(100, size=ncol(mat), replace=TRUE)
p <- pca(mat, metadata = metadata, removeVar = 0.1)
plotloadings(p, drawConnectors = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.