Learn R Programming

mixOmics (version 5.1.1)

plotIndiv: Plot of Individuals (Experimental Units)

Description

This function provides scatter plots for individuals (experimental units) representation in (sparse)(I)PCA, (regularized)CCA, (sparse)PLS(DA) and (sparse)(R)GCCA(DA).

Usage

plotIndiv(object,
           comp = c(1, 2),
           ind.names = TRUE,
           rep.space = "X-variate",
           blocks = NULL, 
           X.label = NULL,
           Y.label = NULL,
           abline.line = FALSE,
           col.per.group,
           cex,
           pch,
           plot.ellipse = FALSE, 
           ellipse.level = 0.95,
           group = NULL, 
           main="plotIndiv",
           add.legend=FALSE,
           style="ggplot2", 
           ...)

Arguments

object
object of class inheriting from any mixOmics: PLS, sPLS, PLS-DA, SPLS-DA, rCC, PCA, sPCA, IPCA, sIPCA, rGCCA, sGCCA, sGCCDA
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 i
blocks
integer value of name of a block to be plotted using the GCCA module. See examples.
X.label
x axis titles.
Y.label
y axis titles
abline.line
should the vertical and horizontal line through the center be plotted? Default set to FALSE
col.per.group
character (or symbol) color to be used. If a supervised method is used, a color vector indicating the color per outcome group.
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.
plot.ellipse
boolean indicating if ellipse plots should be plotted. In the PCA, sPCA, IPCA, sIPCA, PLS, sPLS, rCC, rGCCA, sGCCA non supervised objects, by default will include all data points unless the argument group is set up. In the
ellipse.level
Numerical value indicating the confidence level of ellipse being plotted when plot.ellipse =TRUE (i.e. the size of the ellipse). The default is set to 0.95, for a 95% region.
group
factor indicating the group membership for each sample, useful for ellipse plots. Coded as default for the supervised methods PLS-DA, SPLS-DA,sGCCDA, but needs to be input for the unsupervised methods PCA, sPCA, IPCA, sIPCA, PLS, sPLS,
main
character indicating the title plot.
add.legend
boolean. Whether the legend should be added. Default is TRUE.
style
argument to be set to either 'graphics', 'lattice' or 'ggplot2' for a style of plotting.
...
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.per.group, 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/graphics 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)

# default, only in the X space
plotIndiv(nutri.res) 

# ellipse with respect to genotype in the XY space, 
# names also indicate genotype
plotIndiv(nutri.res, rep.space= 'XY-variate', 
  plot.ellipse = TRUE, ellipse.level = 0.9, 
  group = nutrimouse$genotype, ind.names = nutrimouse$genotype)

# ellipse with respect to genotype in the XY space, with legend
plotIndiv(nutri.res, rep.space= 'XY-variate', group = nutrimouse$genotype, 
  add.legend = TRUE)


# lattice style
plotIndiv(nutri.res, rep.space= 'XY-variate', group = nutrimouse$genotype, 
  add.legend = TRUE, style = 'lattice')

# classic style, in the Y space
plotIndiv(nutri.res, rep.space= 'Y-variate', group = nutrimouse$genotype, 
  add.legend = TRUE, style = 'graphics')


## 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))

#default
plotIndiv(toxicity.spls)

# in the Y space, colors indicate time of necropsy, text is the dose
plotIndiv(toxicity.spls, rep.space= 'Y-variate', 
  group = liver.toxicity$treatment[, 'Time.Group'], 
  ind.names = liver.toxicity$treatment[, 'Dose.Group'], 
  add.legend = TRUE)


## plot of individuals for objects of class 'plsda' or 'splsda'  
# ----------------------------------------------------   
data(breast.tumors)
X <- breast.tumors$gene.exp
Y <- breast.tumors$sample$treatment

splsda.breast <- splsda(X, Y,keepX=c(10,10),ncomp=2)

# default option: note the outcome color is included by default!
plotIndiv(splsda.breast)

# default option with no ind name: pch and color are set automatically
plotIndiv(splsda.breast, ind.names = FALSE, comp = c(1, 2))

# default option with no ind name: pch and color are set automatically, with legend
plotIndiv(splsda.breast, ind.names = FALSE, comp = c(1, 2), add.legend = TRUE)

# trying the different styles
plotIndiv(splsda.breast, ind.names = TRUE, comp = c(1, 2), plot.indiv = FALSE, 
  plot.ellipse = TRUE, style = "ggplot2", cex = c(1, 1))
plotIndiv(splsda.breast, ind.names = TRUE, comp = c(1, 2), plot.indiv = FALSE, 
  plot.ellipse = TRUE, style = "lattice", cex = c(1, 1))


## variable representation for objects of class 'sgcca' (or 'rgcca')
# ----------------------------------------------------
data(nutrimouse)
Y = unmap(nutrimouse$diet)
data = 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)
nutrimouse.sgcca <- wrapper.sgcca(blocks = data,
                                  design = design1,
                                  penalty = c(0.3, 0.5, 1),
                                  ncomp = c(2, 2, 3),
                                  scheme = "centroid",
                                  verbose = FALSE, 
                                  bias = FALSE)

# default style: one panel for each block
plotIndiv(nutrimouse.sgcca)

# for the block 'lipid' with ellipse plots and legend, different styles
plotIndiv(nutrimouse.sgcca, group = nutrimouse$diet, add.legend =TRUE, 
  plot.ellipse = TRUE, ellipse.level = 0.5, blocks = "lipid", main = 'my plot')
plotIndiv(nutrimouse.sgcca, style = "lattice", group = nutrimouse$diet, 
  add.legend = TRUE, plot.ellipse = TRUE, ellipse.level = 0.5, blocks = "lipid", 
  main = 'my plot')
plotIndiv(nutrimouse.sgcca, style = "graphics", group = nutrimouse$diet, 
  add.legend = TRUE, plot.ellipse = TRUE, ellipse.level = 0.5, blocks = "lipid", 
  main = 'my plot')


## variable representation for objects of class 'sgccda' 
# ----------------------------------------------------
# Note: the code differs from above as we use a 'supervised' GCCA analysis
data(nutrimouse)
Y = nutrimouse$diet
data = list(gene = nutrimouse$gene, lipid = nutrimouse$lipid)
design1 = matrix(c(0,1,0,1), ncol = 2, nrow = 2, byrow = TRUE)

nutrimouse.sgccda1 <- wrapper.sgccda(blocks = data,
                                     Y = Y,
                                     design = design1,
                                     ncomp = c(2, 2),
                                     keep = list(c(10,10), c(15,15)),
                                     scheme = "centroid",
                                     verbose = FALSE,
                                     bias = FALSE)


# plotIndiv
# ----------
# displaying all blocks. bu default colors correspond to outcome Y
plotIndiv(nutrimouse.sgccda1)

# displaying only 2 blocks
plotIndiv(nutrimouse.sgccda1, blocks = c(1,2), group = nutrimouse$diet)

# with some ellipse, legend and title
plotIndiv(nutrimouse.sgccda1, blocks = c(1,2), group = nutrimouse$diet, 
  plot.ellipse = TRUE, add.legend = TRUE, main = 'my sample plot')

Run the code above in your browser using DataLab