spls: Sparse Partial Least Squares (sPLS)

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/spls.R

Description

Function to perform sparse Partial Least Squares (sPLS). The sPLS approach combines both integration and variable selection simultaneously on two data sets in a one-step strategy.

Usage

1
2
3
4
5
spls(X, Y, ncomp = 2, mode = c("regression", "canonical", "invariant",
  "classic"), keepX, keepY, scale = TRUE, tol = 1e-06,
  max.iter = 100, near.zero.var = FALSE, logratio = "none",
  multilevel = NULL, all.outputs = TRUE, data = NULL,
  formula = NULL)

Arguments

X

Numeric matrix of predictors, or name of such an assay from data . NAs are allowed.

Y

Numeric vector or matrix of responses (for multi-response models), or name of such an assay or colData from data. NAs are allowed.

ncomp

The number of components to include in the model. Default to 2.

mode

Character string. What type of algorithm to use, (partially) matching one of "regression", "canonical", "invariant" or "classic". See Details.

keepX

Numeric vector of length ncomp, the number of variables to keep in X-loadings. By default all variables are kept in the model.

keepY

Numeric vector of length ncomp, the number of variables to keep in Y-loadings. By default all variables are kept in the model.

scale

Boleean. If scale = TRUE, each block is standardized to zero means and unit variances (default: TRUE)

tol

Convergence stopping value.

max.iter

Integer, the maximum number of iterations.

near.zero.var

Boolean, see the internal nearZeroVar function (should be set to TRUE in particular for data with many zero values). Setting this argument to FALSE (when appropriate) will speed up the computations. Default value is FALSE

logratio

One of ('none','CLR'). Default to 'none'

multilevel

Design matrix for repeated measurement analysis, where multlevel decomposition is required. For a one factor decomposition, the repeated measures on each individual, i.e. the individuals ID is input as the first column. For a 2 level factor decomposition then 2nd AND 3rd columns indicate those factors. See examples in ?spls).

all.outputs

Boolean. Computation can be faster when some specific (and non-essential) outputs are not calculated. Default = TRUE.

data

A MultiAssayExperiment object.

formula

(X and Y must be NULL) formula of form LHS~RHS (names of objects without quotations) where LHS and RHS (in effect Y and X, respectively) are numeric matrices . LHS and RHS can also be an assay names from data. LHS can also be a numeric colData name from data. see examples.

Details

spls function fit sPLS models with 1, … ,ncomp components. Multi-response models are fully supported. The X and Y datasets can contain missing values.

The type of algorithm to use is specified with the mode argument. Four PLS algorithms are available: PLS regression ("regression"), PLS canonical analysis ("canonical"), redundancy analysis ("invariant") and the classical PLS algorithm ("classic") (see References and ?pls for more details).

The estimation of the missing values can be performed by the reconstitution of the data matrix using the nipals function. Otherwise, missing values are handled by casewise deletion in the spls function without having to delete the rows with missing data.

logratio transform and multilevel analysis are performed sequentially as internal pre-processing step, through logratio.transfo and withinVariation respectively.

Multilevel sPLS enables the integration of data measured on two different data sets on the same individuals. This approach differs from multilevel sPLS-DA as the aim is to select subsets of variables from both data sets that are highly positively or negatively correlated across samples. The approach is unsupervised, i.e. no prior knowledge about the sample groups is included.

Value

spls returns an object of class "spls", a list that contains the following components:

X

the centered and standardized original predictor matrix.

Y

the centered and standardized original response vector or matrix.

ncomp

the number of components included in the model.

mode

the algorithm used to fit the model.

keepX

number of X variables kept in the model on each component.

keepY

number of Y variables kept in the model on each component.

variates

list containing the variates.

loadings

list containing the estimated loadings for the X and Y variates.

names

list containing the names to be used for individuals and variables.

tol

the tolerance used in the iterative algorithm, used for subsequent S3 methods

iter

Number of iterations of the algorthm for each component

max.iter

the maximum number of iterations, used for subsequent S3 methods

nzv

list containing the zero- or near-zero predictors information.

scale

whether scaling was applied per predictor.

logratio

whether log ratio transformation for relative proportion data was applied, and if so, which type of transformation.

explained_variance

amount of variance explained per component (note that contrary to PCA, this amount may not decrease as the aim of the method is not to maximise the variance, but the covariance between data sets).

input.X

numeric matrix of predictors in X that was input, before any saling / logratio / multilevel transformation.

mat.c

matrix of coefficients from the regression of X / residual matrices X on the X-variates, to be used internally by predict.

defl.matrix

residual matrices X for each dimension.

Author(s)

Sébastien Déjean, Ignacio González and Kim-Anh Lê Cao.

References

Sparse PLS: canonical and regression modes:

Lê Cao, K.-A., Martin, P.G.P., Robert-Granie, C. and Besse, P. (2009). Sparse canonical methods for biological data integration: application to a cross-platform study. BMC Bioinformatics 10:34.

Lê Cao, K.-A., Rossouw, D., Robert-Granie, C. and Besse, P. (2008). A sparse PLS for variable selection when integrating Omics data. Statistical Applications in Genetics and Molecular Biology 7, article 35.

Sparse SVD: Shen, H. and Huang, J. Z. (2008). Sparse principal component analysis via regularized low rank matrix approximation. Journal of Multivariate Analysis 99, 1015-1034.

PLS methods: Tenenhaus, M. (1998). La regression PLS: theorie et pratique. Paris: Editions Technic. Chapters 9 and 11.

Abdi H (2010). Partial least squares regression and projection on latent structure regression (PLS Regression). Wiley Interdisciplinary Reviews: Computational Statistics, 2(1), 97-106.

Wold H. (1966). Estimation of principal components and related models by iterative least squares. In: Krishnaiah, P. R. (editors), Multivariate Analysis. Academic Press, N.Y., 391-420.

On multilevel analysis:

Liquet, B., Lê Cao, K.-A., Hocini, H. and Thiebaut, R. (2012) A novel approach for biomarker selection and the integration of repeated measures experiments from two platforms. BMC Bioinformatics 13:325.

Westerhuis, J. A., van Velzen, E. J., Hoefsloot, H. C., and Smilde, A. K. (2010). Multivariate paired data analysis: multilevel PLSDA versus OPLSDA. Metabolomics, 6(1), 119-128.

See Also

pls, summary, plotIndiv, plotVar, cim, network, predict, perf and http://www.mixOmics.org for more details.

Examples

 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#' \dontrun{
## 1st example: accepted input formats
#--------------------------------------------------------------

library(mixOmics.data)
X <- liver.toxicity$gene
Y <- liver.toxicity$clinic
keepX <- c(50, 50)
keepY <- c(5, 5)
spls.res1 <- spls(X=X, Y=Y, keepX = keepX, keepY = keepY)
plotVar(spls.res1)

## ---------------- formula method for matrices
## 'formula' argument should be explicitly mentioned (formula = ...)
## for correct method dispatch
spls.res2 <- spls(formula = Y ~ X, keepX = keepX, keepY = keepY)
## exclude calls and see if all outputs  are identical
identical(spls.res1[-1], spls.res2[-1])
#> TRUE
## ---------------- MultiAssayExperiment and assay names as X and Y
## 'data' argument should be explicitly mentioned for correct method dispatch
spls.res3 <- spls(X='gene', Y='clinic', data = liver.toxicity.mae,
                  keepX = keepX, keepY = keepY)
identical(spls.res1[-1], spls.res3[-1])
#> TRUE

## ---------------- MultiAssayExperiment and formula with assay names
spls.res4 <- spls(formula = clinic ~ gene, data = liver.toxicity.mae,
                  keepX = keepX, keepY = keepY)
identical(spls.res1[-1], spls.res4[-1])
#> TRUE

## ---------------- MultiAssayExperiment; X=assay and Y=colData
toxicity.spls1 <- spls(data = liver.toxicity.mae, formula = Dose.Group~gene,
                       ncomp = 2, keepX=keepX)
toxicity.spls2 <- spls(data = liver.toxicity.mae, Y='Dose.Group', X='gene',
                       ncomp = 2, keepX=keepX)
identical(toxicity.spls1[-1], toxicity.spls2[-1])
#> TRUE

## 2nd example: one-factor multilevel analysis with sPLS, selecting a subset of variables
#--------------------------------------------------------------

# note: we made up those data, pretending they are repeated measurements
repeat.indiv <- c(1, 2, 1, 2, 1, 2, 1, 2, 3, 3, 4, 3, 4, 3, 4, 4, 5, 6, 5, 5,
                  6, 5, 6, 7, 7, 8, 6, 7, 8, 7, 8, 8, 9, 10, 9, 10, 11, 9, 9,
                  10, 11, 12, 12, 10, 11, 12, 11, 12, 13, 14, 13, 14, 13, 14,
                  13, 14, 15, 16, 15, 16, 15, 16, 15, 16)
summary(as.factor(repeat.indiv)) # 16 rats, 4 measurements each

# this is a spls (unsupervised analysis) so no need to mention any factor in design
# we only perform a one level variation split
design <- data.frame(sample = repeat.indiv)
res.spls.1level <- spls(X = liver.toxicity$gene,
                        Y=liver.toxicity$clinic,
                        multilevel = design,
                        ncomp = 3,
                        keepX = c(50, 50, 50), keepY = c(5, 5, 5),
                        mode = 'canonical')

# set up colors and pch for plotIndiv
col.stimu <- 1:nlevels(design$stimu)

plotIndiv(res.spls.1level, rep.space = 'X-variate', ind.names = FALSE,
          group = liver.toxicity$treatment$Dose.Group,
          pch = 20, main = 'Gene expression subspace',
          legend = TRUE)


plotIndiv(res.spls.1level, rep.space = 'Y-variate', ind.names = FALSE,
          group = liver.toxicity$treatment$Dose.Group,
          pch = 20, main = 'Clinical measurements ssubpace',
          legend = TRUE)

plotIndiv(res.spls.1level, rep.space = 'XY-variate', ind.names = FALSE,
          group = liver.toxicity$treatment$Dose.Group,
          pch = 20, main = 'Both Gene expression and Clinical subspaces',
          legend = TRUE)

## 3rd example: two-factor multilevel analysis with sPLS, selecting a subset of variables
#--------------------------------------------------------------

dose <- as.factor(liver.toxicity$treatment$Dose.Group)
time <- as.factor(liver.toxicity$treatment$Time.Group)
# note: we made up those data, pretending they are repeated measurements
repeat.indiv <- c(1, 2, 1, 2, 1, 2, 1, 2, 3, 3, 4, 3, 4, 3, 4, 4, 5, 6, 5, 5,
                  6, 5, 6, 7, 7, 8, 6, 7, 8, 7, 8, 8, 9, 10, 9, 10, 11, 9, 9,
                  10, 11, 12, 12, 10, 11, 12, 11, 12, 13, 14, 13, 14, 13, 14,
                  13, 14, 15, 16, 15, 16, 15, 16, 15, 16)
summary(as.factor(repeat.indiv)) # 16 rats, 4 measurements each
design <- data.frame(sample = repeat.indiv, dose = dose, time = time)

res.spls.2level = spls(liver.toxicity$gene,
                       Y = liver.toxicity$clinic,
                       multilevel = design,
                       ncomp=2,
                       keepX = c(10,10), keepY = c(5,5))

#' }

ajabadi/mixOmics2 documentation built on Aug. 9, 2019, 1:08 a.m.