# lmdme-decomposition: 'decomposition' of lmdme object In lmdme: Linear Model decomposition for Designed Multivariate Experiments

## Description

This function calculates the decomposition of variance or covariance structure using Principal Component Analysis (PCA) or Partial Least Squared Regression (PLSR), on the ANOVA decomposed lmdme object. In this context, in a two factor experimental design with interaction, the linear model of the i-th observation (gene) can be written:
X=μ+X_{A}+X_{B}+X_{AB}+ε
where

• X stands for the observed value.

• the intercept μ.

• X_{A}, X_{B} and X_{AB} are the first, second and interaction coefficients respectively.

• The error term ε ~ N(0,σ^2).

The model is iteratively decomposed in a step by step fashion, decomposing one term each time by calling `lmdme` constructor:

1. Step 1: X=μ+E_{1}

2. Step 2: E_{1}=X_{A}+E_{2}

3. Step 3: E_{2}=X_{B}+E_{3}

4. Step 4: E_{3}=X_{AB}+E_{4}

Then, if we apply PCA on the i-th step using E_{i-1} matrix it is known as APCA but if applied on the coefficients X_{i} it is called ASCA. The same decomposition schema can also be used with PLSR.

## Arguments

 `object` lmdme class object. `decomposition` character to indicate the decomposition to be carried out, i.e., "pca" or "plsr". Default value is "pca". `term` character specifying the model term to perform the decomposition (e.g. "time" or "time:concentration" for interaction term). If the term is not specified (i.e. missing) it performs the analysis over all the model terms. `subset` subset of individuals (rows) to be included in the analysis. By default all the individuals are included. `type` character to indicate on which regression matrix ("coefficient" or "residual") the decomposition will be performed. The intercept term is not included in the results, as it can be directly analyzed with the original M data.frame. Default value is "coefficient" a.k.a. ASCA. Note that "residual" performs PCA or PLS on the i-th residual E_{i-1}=X_{i}+E_{i} and not the residuals of the i-th model E_{i}. `scale` character "row", "column" or "none" to indicate if the matrix should be scaled by the row, column or not respectively. Default value is "none". `Omatrix` the output matrix for PLSR only. If the parameter is missing, the output matrix will be an identity matrix for the ASCA. Otherwise, is the design matrix corresponding to the specified term for APCA. `...` additional parameters for `prcomp` or `plsr` functions, according to the decomposition call.

## Value

Internal update of the "components" slot of the lmdme object, which is a list of `prcomp` or a list of mvr (`plsr`) objects using the given term parameter. If missing(term), the length of the list equals the number of decomposed models minus the Intercept term for coefficients or the length of decomposed models for residual decomposition.

## Author(s)

Cristobal Fresno and Elmer A Fernandez

## References

1. Smilde AK, Jansen JJ, Hoefsloot HCJ, Lamer RAN, Van der Greef J, Timmerman ME (2005) ANOVA-simultaneous component analysis (ASCA): a new tool for analyzing designed meta-bolomics data, Bioinformatics 21,13,3043 DOI:/10.1093/bioinformatics/bti476

2. Zwanenburg G, Hoefsloot HCJ, Westerhuis JA, Jansen JJ, Smilde AK (2011) ANOVA Principal component analysis and ANOVA-simultaneous component analysis: a comparison J. Chemometrics 25:561-567 DOI:10.1002/cem.1400

3. Cristobal Fresno, Monica G. Balzarini, Elmer A. Fernandez (2014) lmdme: Linear Models on Designed Multivariate Experiments in R, Journal of Statistical Software, 56(7), 1-16, http://www.jstatsoft.org/v56/i07/.

`prcomp`, `plsr`

## 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``` ```{ data(stemHypoxia) ##Just to make a balanced dataset in the Fisher sense (2 samples per ## time*oxygen levels) design<-design[design\$time %in% c(0.5,1,5) & design\$oxygen %in% c(1,5,21), ] design\$time<-as.factor(design\$time) design\$oxygen<-as.factor(design\$oxygen) rownames(M)<-M[, 1] #Keeping appropriate samples only M<-M[, colnames(M) %in% design\$samplename] ##ANOVA decomposition fit<-lmdme(model=~time+oxygen+time:oxygen, data=M, design=design) ##Just a copy of the same fit object and to perform analysis on those ##subjects/genes where at least one interaction coefficient is statistically ##different from zero (F-test on the coefficients). asca<-fit apca<-fit id<-F.p.values(fit, term="time:oxygen")<0.001 ##ASCA and APCA decomposition for every available term. decomposition(asca, decomposition="pca", subset=id, scale="row") decomposition(apca, decomposition="pca", subset=id, scale="row", type="residual") ##Let's get the components for asca/apca decomposed objects asca<-components(asca) apca<-components(apca) ##Now let's try the PLSR decomposition for residuals and coefficients plsr.residuals<-fit plsr.coefficients<-fit decomposition(plsr.coefficients, decomposition="plsr", subset=id, scale="row") decomposition(plsr.residuals, decomposition="plsr", subset=id, scale="row", type="residual") ##Obtain the coefficients for decomposed plsr objects ##(coefficients/residuals) plsr.coefficients<-components(plsr.coefficients) plsr.residuals <- components(plsr.residuals) } ```

### Example output

```Loading required package: pls

Attaching package: 'pls'

The following object is masked from 'package:stats':