plotVar

plotVar

Variables representation

In this type of graphical display, the variables X and Y are represented through their projections onto the plane defined either by X-variates or Y-variates. The variables X and Y being assumed to be of unit variance, their projections are inside a circle of radius 1 centered at the origin called correlation circle. Strongly associated (or correlated) variables are projected in the same direction from the origin. The greater the distance from the origin the stronger the association. Two circumferences of radius 1 and 0.5 are plotted to reveal the correlation structure of the variables.

Note that this function also works for the case when there is a single data set (using a (s)PCA or a (s)PLS-DA result).

Usage in mixOmics

Variables 2D plots can be obtained in mixOmics via the function plotVar as displayed below:

library(mixOmics)
#pls/spls
data(liver.toxicity)
X <- liver.toxicity$gene
Y <- liver.toxicity$clinic
toxicity.spls <- spls(X, Y, ncomp = 3,
keepX = c(30, 30, 30), keepY = c(10, 10, 10))

#test overlap
plotVar(toxicity.spls,overlap = F)

plot of chunk unnamed-chunk-2

#rcc
data(linnerud)
X <- linnerud$exercise
Y <- linnerud$physiological
linn.res <- rcc(X, Y)

#test rad.in
plotVar(linn.res,rad.in=0.9)

plot of chunk unnamed-chunk-3

#pca/spca
data(liver.toxicity)
rat.spca <- spca(liver.toxicity$gene, ncomp = 3, keepX = rep(50, 3))


#test col and lattice style
plotVar(rat.spca,col=list(rep(c("green","red"),each=1558)),style="lattice")

plot of chunk unnamed-chunk-4

#pca/spca

 data(liver.toxicity)
    rat.spca <- spca(liver.toxicity$gene, ncomp = 3, keepX = rep(50, 3))


#test col and lattice style
plotVar(rat.spca,col=list(rep(c("green","red"),each=1558)),style="lattice")

plot of chunk unnamed-chunk-5

#sgcca

data(nutrimouse)
Y = unmap(nutrimouse$diet)

blocks = list(gene = nutrimouse$gene, lipid = nutrimouse$lipid, Y = Y)
design1 = matrix(c(0,1,1,1,0,1,1,1,0), ncol = 3, nrow = 3, byrow = TRUE)

nutri.sgcca <- wrapper.sgcca(blocks,
                             design = design1,
                             penalty = c(0.3, 0.5, 1),
                             ncomp = 2,
                             scheme = "centroid",
                             verbose = FALSE,
                             bias = FALSE)


###test var.names and lattice style
plotVar(nutri.sgcca,var.names = c(FALSE,TRUE,TRUE),blocks=1:3, style = "lattice")

plot of chunk unnamed-chunk-6

plotVar(nutri.sgcca, comp = c(2,2,1), cutoff = 0.5,style='3d')

3D-Variable Plot