Learn R Programming

mixOmics (version 5.0-4)

plotIndiv: Plot of Individuals (Experimental Units)

Description

This function provides scatter plots for individuals (experimental units) representation in (regularized) CCA, (sparse) PLS regression, (sparse)RGCCA and PCA.

Usage

## S3 method for class 'rcc':
plotIndiv(object, comp = 1:2, ind.names = TRUE,
          rep.space = "XY-variate",
          X.label = NULL, Y.label = NULL,
          col = "black", cex = 1, pch = 1, 
          abline.line = FALSE, \ldots)
	  
## S3 method for class 'pls':
plotIndiv(object, comp = 1:2, 
			ind.names = TRUE,
          rep.space = "X-variate",
          X.label = NULL, Y.label = NULL,  
          col = "black", cex = 1, pch = 1, 
          abline.line = FALSE,\ldots)	

## S3 method for class 'spls': plotIndiv(object, comp = 1:2, ind.names = TRUE, rep.space = "X-variate", X.label = NULL, Y.label = NULL, col = "black", cex = 1, pch = 1, abline.line = FALSE,\ldots)

## S3 method for class 'pca': plotIndiv(object, comp = 1:2, ind.names = TRUE, X.label = NULL, Y.label = NULL, abline.line = FALSE,\ldots)

## S3 method for class 'spca': plotIndiv(object, comp = 1:2, ind.names = TRUE, X.label = NULL, Y.label = NULL, abline.line = FALSE,\ldots)

## S3 method for class 'rgcca': plotIndiv(object, comp = 1:2, ind.names = TRUE, rep.space = 1, X.label = NULL, Y.label = NULL, col = "black", cex = 1, pch = 1, abline.line = FALSE,\ldots)

## S3 method for class 'sgcca': plotIndiv(object, comp = 1:2, ind.names = TRUE, rep.space = 1, X.label = NULL, Y.label = NULL, col = "black", cex = 1, pch = 1, abline.line = FALSE, \ldots)

Arguments

object
object of class inheriting from "rcc", "pls", "plsda", "spls", "plsda", "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 individuals.
ind.names
either a character vector of names for the individuals to be plotted, or FALSE for no names. If TRUE, the row names of the first (or second) data matrix is used as names (see Details).
rep.space
For objects of class "rcc", "pls", "spls", character string, (partially) matching one of "X-variate", "Y-variate" or "XY-variate", determining the subspace to project the
X.label
x axis titles.
Y.label
y axis titles
col
character (or symbol) color to be used, possibly vector.
cex
numeric character (or symbol) expansion, possibly vector.
pch
plot character. A character string or a vector of single characters or integers. See points for all alternatives.
abline.line
should the vertical and horizontal line through the center be plotted?default set to FALSE
...
further graphical parameters are passed to text.

encoding

latin1

Details

plotIndiv method makes scatter plot for individuals representation depending on the subspace of projection. Each point corresponds to an individual.

If ind.names=TRUE and row names is NULL, then ind.names=1:n, where n is the number of individuals.

The arguments col, cex and pch can be atomic vectors or vectors of length n. If atomic, this argument value determines the graphical attribute for all the individuals. In the last case, multiple arguments values can be specified so that each point (individual) can be given its own graphic attributes (see par). Default values exist for this arguments.

See Also

plot3dIndiv, text, points and http://mixOmics.org for more details.

Examples

Run this code
## plot of individuals 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)

plotIndiv(nutri.res) #(default) 

col <- rep(c("blue", "red"), c(20, 20))
plotIndiv(nutri.res, ind.names = nutrimouse$diet, col = col)
legend(-2.2, -1.1, c("WT", "PPAR"), pch = c(16, 16), 
       col = c("blue", "red"), text.col = c("blue", "red"),
       cex = 1, pt.cex = c(1.2, 1.2))

## plot of individuals 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))
		  
col <- rep(c("blue", "red", "darkgreen", "darkviolet"), rep(16, 4))
cex <- rep(c(1, 1.2, 1, 1.4), c(16, 16, 16, 16))
pch <- rep(c(15, 16, 17, 18), c(16, 16, 16, 16))
plotIndiv(toxicity.spls, comp = 1:2, ind.names = FALSE,
          rep.space = "X-variate", col = col, cex = cex, pch = pch)
legend("topright", c("50 mg/kg", "150 mg/kg", "1500 mg/kg", "2000 mg/kg"), 
       col = c("blue", "red", "darkgreen", "darkviolet"), 
       pch = c(15, 16, 17, 18), pt.cex = c(1, 1.2, 1, 1.4), 
       title = "Treatment")
       
## variable representation for objects of class 'sgcca' (or 'rgcca')
# ----------------------------------------------------
data(nutrimouse)

# need to unmap the Y factor diet
Y = unmap(nutrimouse$diet)
data = list(nutrimouse$gene, nutrimouse$lipid,Y)
# 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,.5, 1), 
                                  ncomp = c(2, 2, 1),
                                  scheme = "centroid", verbose = FALSE)


# on the first data set
plotIndiv(wrap.result.sgcca, rep.space = 1, ind.names = TRUE, 
          col = as.numeric(nutrimouse$diet), cex = .6)
# on the second data set
plotIndiv(wrap.result.sgcca, rep.space = 2, ind.names = TRUE, 
          col = as.numeric(nutrimouse$diet), cex = .6)

Run the code above in your browser using DataLab