Learn R Programming

mixOmics (version 5.0-4)

plotVar: Plot of Variables

Description

This function provides variables representation for (regularized) CCA, (sparse) PLS regression, PCA nd (sparse) Regularized generalised CCA.

Usage

## S3 method for class 'rcc':
plotVar(object, comp = 1:2, rad.in = 0.5, cutoff = NULL,
        X.label = FALSE, Y.label = FALSE,
        pch = NULL, cex = NULL, col = NULL, font = NULL, \ldots)

## S3 method for class 'pls': plotVar(object, comp = 1:2, rad.in = 0.5, X.label = FALSE, Y.label = FALSE, pch = NULL, cex = NULL, col = NULL, font = NULL, \ldots)

## S3 method for class 'plsda': plotVar(object, comp = 1:2, rad.in = 0.5, var.label = FALSE, pch = NULL, cex = NULL, col = NULL, font = NULL, \ldots)

## S3 method for class 'spls': plotVar(object, comp = 1:2, rad.in = 0.5, X.label = FALSE, Y.label = FALSE, pch = NULL, cex = NULL, col = NULL, font = NULL, \ldots)

## S3 method for class 'splsda': plotVar(object, comp = 1:2, rad.in = 0.5, var.label = FALSE, pch = NULL, cex = NULL, col = NULL, font = NULL, \ldots)

## S3 method for class 'pca': plotVar(object, comp = 1:2, rad.in = 0.5, var.label = FALSE, \ldots)

## S3 method for class 'spca': plotVar(object, comp = 1:2, rad.in = 0.5, var.label = FALSE, pch = NULL, cex = NULL, col = NULL, font = NULL, \ldots)

## S3 method for class 'rgcca': plotVar(object, comp = c(1,2), block = c(1,2), labels = FALSE, pch = c(16,17), cex = c(0.5, 0.5), col = color.mixo(2), font = c(2,3), rad.in = 0.5, ...) ## S3 method for class 'sgcca': plotVar(object, comp = c(1,2), block = c(1,2), ncomp.select = c(1,2), labels = FALSE, pch = c(16,17), cex = c(0.5, 0.5), col = color.mixo(2), font = c(2,3), rad.in = 0.5,...)

Arguments

object
object of class inheriting from "rcc", "pls", "plsda", "spls", "splsda", "pca" or "spca".
comp
integer vector of length two. The components that will be used on the horizontal and the vertical axis respectively to project the variables.
rad.in
numeric between 0 and 1, the radius of the inner circle. Defaults to 0.5.
cutoff
numeric between 0 and 1. Variables with correlations below this cutoff in absolute value are not plotted (see Details).
X.label, Y.label, var.label, labels
either a character vector of names for the variables or FALSE for no names. If TRUE, the columns names of the matrice are used as labels.
col
character or integer vector of colors for plotted character and symbols, can be of length 2 (one for each data set) or of length (p+q) (i.e. the total number of variables). See Details.
pch
plot character. A vector of single characters or integers, can be of length 2 (one for each data set) or of length (p+q) (i.e. the total number of variables). See points for all alternatives.
cex
numeric vector of character expansion sizes for the plotted character and symbols, can be of length 2 (one for each data set) or of length (p+q) (i.e. the total number of variables).
font
numeric vector of font to be used, can be of length 2 (one for each data set) or of length (p+q) (i.e. the total number of variables). See par for details.
block
for an object of class "rgcca" or "sgcca", a numerical vector indicating the block variables to display.
ncomp.select
for the sparse versions, an input vector indicating the components on which the variables were selected. Only those selected variables are displayed.
...
not used currently.

Value

  • A list containing the following components:
  • coord.Xmatrix of $X$-variables coordinates.
  • coord.Ymatrix of $Y$-variables coordinates.

encoding

latin1

Details

plotVar produce a "correlation circle", i.e. the correlations between each variable and the selected components are plotted as scatter plot, with concentric circles of radius one et radius given by rad.in. Each point corresponds to a variable. For (regularized) CCA the components correspond to the equiangular vector between $X$- and $Y$-variates. For (sparse) PLS regression mode the components correspond to the $X$-variates. If mode is canonical, the components for $X$ and $Y$ variables correspond to the $X$- and $Y$-variates respectively.

For plsda and splsda objects, only the $X$ variables are represented.

For spls and splsda objects, only the $X$ and $Y$ variables selected on dimensions comp are represented.

The arguments col, pch, cex and font can be either vectors of length two or a list with two vector components of length $p$ and $q$ respectively, where $p$ is the number of $X$-variables and $q$ is the number of $Y$-variables. In the first case, the first and second component of the vector determine the graphics attributes for the $X$- and $Y$-variables respectively. Otherwise, multiple arguments values can be specified so that each point (variable) can be given its own graphic attributes. In this case, the first component of the list correspond to the $X$ attributs and the second component correspond to the $Y$ attributs. Default values exist for this arguments.

References

Gonzalez I., Le Cao K-A., Davis, M.J. and Dejean, S. (2012). Visualising associations between paired 'omics data sets. J. Data Mining 5:19. http://www.biodatamining.org/content/5/1/19/abstract

See Also

plot3dVar, cim, network, par and http://www.mixOmics.org for more details.

Examples

Run this code
## variable representation for objects of class 'rcc'
# ----------------------------------------------------
data(nutrimouse)
X <- nutrimouse$lipid
Y <- nutrimouse$gene
nutri.res <- rcc(X, Y, ncomp = 3, lambda1 = 0.064, lambda2 = 0.008)

plotVar(nutri.res) #(default)

plotVar(nutri.res, comp = 1:2, cutoff = 0.5, 
        X.label = TRUE, Y.label = TRUE)

## variable representation for objects of class 'pls' or 'spls'
# ----------------------------------------------------
data(liver.toxicity)
X <- liver.toxicity$gene
Y <- liver.toxicity$clinic
toxicity.spls <- spls(X, Y, ncomp = 3, keepX = c(50, 50, 50), 
                      keepY = c(10, 10, 10))
	
plotVar(toxicity.spls, keep.var = TRUE, Y.label = TRUE, cex = c(1,0.8))	

## variable representation for objects of class 'splsda'
# ----------------------------------------------------
data(liver.toxicity)
X <- liver.toxicity$gene
Y <- as.factor(liver.toxicity$treatment[, 4])

ncomp <- 2
keepX <- rep(20, ncomp)

splsda.liver <- splsda(X, Y, ncomp = ncomp, keepX = keepX)
plotVar(splsda.liver, var.label = FALSE)

## variable representation for objects of class 'sgcca' (or 'rgcca')
# ----------------------------------------------------
data(nutrimouse)
# need to unmap the Y factor diet
Y = unmap(nutrimouse$diet)
# set up the data as list
data = list(nutrimouse$gene, nutrimouse$lipid,Y)

# set up the design matrix:
# with this design, gene expression and lipids are connected to the diet factor
# design = matrix(c(0,0,1,
#                   0,0,1,
#                   1,1,0), ncol = 3, nrow = 3, byrow = TRUE)

# with this design, gene expression and lipids are connected to the diet factor
# and gene expression and lipids are also connected
design = matrix(c(0,1,1,
                  1,0,1,
                  1,1,0), ncol = 3, nrow = 3, byrow = TRUE)



#note: the penalty parameters will need to be tuned
wrap.result.sgcca = wrapper.sgcca(data = data, design = design, penalty = c(.3,.3, 1), 
                                  ncomp = c(2, 2, 1),
                                  scheme = "centroid", verbose = FALSE)
wrap.result.sgcca

#variables selected on component 1 for the two blocks:
selectVar(wrap.result.sgcca, comp = 1, block = c(1,2))$name.var

#variables selected on component 2 for each block: 
selectVar(wrap.result.sgcca, comp = 2, block = c(1,2))$name.var


plotVar(wrap.result.sgcca, comp = c(1,2), block = c(1,2), ncomp.select = c(1,1), labels = TRUE)
title(main = c('Variables selected on component 1 only'))
plotVar(wrap.result.sgcca, comp = c(1,2), block = c(1,2), ncomp.select = c(2,2), labels = TRUE)
title(main = c('Variables selected on component 2 only'))
# -> this one shows the variables selected on both components
plotVar(wrap.result.sgcca, comp = c(1,2), block = c(1,2), labels = TRUE)
title(main = c('Variables selected on components 1 and 2'))

## variable representation for objects of class 'rgcca'
# ----------------------------------------------------
data(nutrimouse)
# need to unmap the Y factor diet
Y = unmap(nutrimouse$diet)
# set up the data as list
data = list(nutrimouse$gene, nutrimouse$lipid,Y)
# with this design, gene expression and lipids are connected to the diet factor
# design = matrix(c(0,0,1,
#                   0,0,1,
#                   1,1,0), ncol = 3, nrow = 3, byrow = TRUE)

# with this design, gene expression and lipids are connected to the diet factor
# and gene expression and lipids are also connected
design = matrix(c(0,1,1,
                  1,0,1,
                  1,1,0), ncol = 3, nrow = 3, byrow = TRUE)
#note: the tau parameter is the regularization parameter
wrap.result.rgcca = wrapper.rgcca(data = data, design = design, tau = c(1, 1, 0), 
                                  ncomp = c(2, 2, 1),
                                  scheme = "centroid", verbose = FALSE)
#wrap.result.rgcca
plotVar(wrap.result.rgcca, comp = c(1,2), block = c(1,2))
plotVar(wrap.result.rgcca, comp = c(1,2), block = c(1,2), labels = TRUE)

Run the code above in your browser using DataLab