Title: | Linear Model decomposition for Designed Multivariate Experiments |
---|---|
Description: | linear ANOVA decomposition of Multivariate Designed Experiments implementation based on limma lmFit. Features: i)Flexible formula type interface, ii) Fast limma based implementation, iii) p-values for each estimated coefficient levels in each factor, iv) F values for factor effects and v) plotting functions for PCA and PLS. |
Authors: | Cristobal Fresno and Elmer A. Fernandez |
Maintainer: | Cristobal Fresno <[email protected]> |
License: | GPL (>=2) |
Version: | 1.49.0 |
Built: | 2024-11-29 08:11:20 UTC |
Source: | https://github.com/bioc/lmdme |
biplot
of a lmdme objectPlot a biplot over each decomposed "pca" or "plsr" present in lmdme component object's slot.
## S4 method for signature 'lmdme' biplot(x, comp=1:2, xlab=NULL, ylab=NULL, term=NULL, mfcol, xlabs, ylabs, which, ...)
## S4 method for signature 'lmdme' biplot(x, comp=1:2, xlab=NULL, ylab=NULL, term=NULL, mfcol, xlabs, ylabs, which, ...)
x |
lmdme class object. |
comp |
a two component vector with the PC components to plot. Default comp=1:2. |
xlab |
character for the x-label title for PCA biplots. |
ylab |
character for the y-label title for PCA biplots. |
term |
character with the corresponding term/s for biploting. Default value is NULL in order to obtain every available biplot/s. |
mfcol |
numeric vector for par layout. If missing mfcol=c(1,2) will be used if more than one biplot is available. Use mfcol==NULL to override par call inside biplot function. |
xlabs , ylabs
|
vector of character strings to label the first/second set of points. The default is to use dimname of "x"/"y", or "1:n" if the dimname is NULL for the respective set of points. If a single character is passed e.g. "o", the same character is used for all the points. |
which |
character to indicate the type of biplot to
use when plsr decomposition is applied. Default value is
"x" (X scores and loadings), "y" for (Y scores and
loadings), "scores" (X and Y scores) or "loadings" (X and
Y loadings). See |
... |
additional parameters for
|
plotted biplot/s of the component/s of the given lmdme
object. If par
() is called before this
function, the biplots can be arranged in the same window
Cristobal Fresno and Elmer A Fernandez
prcomp
, plsr
,
biplot.princomp
, biplot.mvr
{ 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) ##ASCA for all the available terms, over those subjects/genes where at least ##one interaction coefficient is statistically different from zero (F-test ##on coefficients). id<-F.p.values(fit, term="time:oxygen")<0.001 decomposition(fit, decomposition="pca",scale="row",subset=id) ## Not run: ##Does not call par inside par(mfrow=c(2,2)) biplot(fit, xlabs="o", mfcol=NULL) ##Just the term of interest biplot(fit, xlabs="o", term="time") ##In separate graphics biplot(fit, xlabs="o", term=c("time", "oxygen"), mfcol=c(1,1)) ##All terms in the same graphic biplot(fit, xlabs="o", mfcol=c(1,3)) ## End(Not run) } ##Now using plsr on interaction coefficients decomposition(fit, decomposition="plsr", term="time:oxygen", scale="row", subset=id) ## Not run: par(mfrow=c(2,2)) ##plsr biplot by default which="x" biplot(fit, which="x", mfcol=NULL) ##Other alternatives to which biplot(fit, which="y", mfcol=NULL) biplot(fit, which="scores", mfcol=NULL) biplot(fit, which="loadings", mfcol=NULL, xlabs="o") ## End(Not run)
{ 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) ##ASCA for all the available terms, over those subjects/genes where at least ##one interaction coefficient is statistically different from zero (F-test ##on coefficients). id<-F.p.values(fit, term="time:oxygen")<0.001 decomposition(fit, decomposition="pca",scale="row",subset=id) ## Not run: ##Does not call par inside par(mfrow=c(2,2)) biplot(fit, xlabs="o", mfcol=NULL) ##Just the term of interest biplot(fit, xlabs="o", term="time") ##In separate graphics biplot(fit, xlabs="o", term=c("time", "oxygen"), mfcol=c(1,1)) ##All terms in the same graphic biplot(fit, xlabs="o", mfcol=c(1,3)) ## End(Not run) } ##Now using plsr on interaction coefficients decomposition(fit, decomposition="plsr", term="time:oxygen", scale="row", subset=id) ## Not run: par(mfrow=c(2,2)) ##plsr biplot by default which="x" biplot(fit, which="x", mfcol=NULL) ##Other alternatives to which biplot(fit, which="y", mfcol=NULL) biplot(fit, which="scores", mfcol=NULL) biplot(fit, which="loadings", mfcol=NULL, xlabs="o") ## End(Not run)
decomposition
of lmdme objectThis 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:
where
X stands for the observed value.
the intercept .
,
and
are the first, second and interaction
coefficients respectively.
The error term
.
The model is
iteratively decomposed in a step by step fashion,
decomposing one term each time by calling
lmdme
constructor:
Step
1:
Step 2:
Step 3:
Step 4:
Then, if we apply PCA on the
i-th step using matrix it is known as
APCA but if applied on the coefficients
it is called ASCA. The same
decomposition schema can also be used with PLSR.
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 |
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 |
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.
Cristobal Fresno and Elmer A Fernandez
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
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
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/.
{ 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) }
{ 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) }
To obtain lmdme slot information, according to the given function call (see Values). If a term parameter is not specified, it will return all the available terms. Otherwise, just the one specified.
## S4 method for signature 'lmdme' fitted.values(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' fitted(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' coef(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' coefficients(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' resid(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' residuals(object, term=NULL, drop=TRUE) F.p.values(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' F.p.values(object, term=NULL, drop=TRUE) p.values(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' p.values(object, term=NULL, drop=TRUE) modelDecomposition(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' modelDecomposition(object, term=NULL, drop=TRUE) components(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' components(object, term=NULL, drop=TRUE) componentsType(object) ## S4 method for signature 'lmdme' componentsType(object) model(object) ## S4 method for signature 'lmdme' model(object) design(object) ## S4 method for signature 'lmdme' design(object)
## S4 method for signature 'lmdme' fitted.values(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' fitted(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' coef(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' coefficients(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' resid(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' residuals(object, term=NULL, drop=TRUE) F.p.values(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' F.p.values(object, term=NULL, drop=TRUE) p.values(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' p.values(object, term=NULL, drop=TRUE) modelDecomposition(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' modelDecomposition(object, term=NULL, drop=TRUE) components(object, term=NULL, drop=TRUE) ## S4 method for signature 'lmdme' components(object, term=NULL, drop=TRUE) componentsType(object) ## S4 method for signature 'lmdme' componentsType(object) model(object) ## S4 method for signature 'lmdme' model(object) design(object) ## S4 method for signature 'lmdme' design(object)
object |
lmdme class object. |
term |
character with the corresponding term/s to return. Default value is NULL in order to return every available term/s. |
drop |
should try to drop list structure if length==1? Default value is TRUE |
according to the call one of the following objects can be returned
design |
experiment design data.frame used. |
model |
decomposed formula used. |
modelDecomposition |
list of decomposed model formulas. |
residuals , resid , coef , coefficients , fitted , fitted.values , p.values or F.p.values
|
list of appropriate slot where each item is a matrix that will have G rows (individuals) x k columns (levels of the corresponding model term). |
components |
list with corresponding PCA or PLSR terms according to the decomposition function call. |
componentsType |
character name vector with the information of the component calculations. |
Cristobal Fresno and Elmer A Fernandez
lmdme
, decomposition
,
print
, show
{ 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) ##Let's inspect how the decomposition process was carried out: ##a) The model formula used ##b) The design data.frame used ##c) The decomposition itself fit.model<-model(fit) fit.design<-design(fit) fit.modelDecomposition<-modelDecomposition(fit) ##Getting the specific "time" term coefficients, p-values or F-values. ## Omit "term" parameter for all available terms. timeCoef<-coef(fit,term="time") fit.p.values<-p.values(fit,term="time") fit.f.values<-F.p.values(fit,term="time") ##Getting the residuals or fitted values, for the interaction "time:oxygen" ## term. Omit "term" parameter for all available terms. interactionResid<-resid(fit, term="time:oxygen") interactionFit<-fitted(fit, term="time:oxygen") }
{ 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) ##Let's inspect how the decomposition process was carried out: ##a) The model formula used ##b) The design data.frame used ##c) The decomposition itself fit.model<-model(fit) fit.design<-design(fit) fit.modelDecomposition<-modelDecomposition(fit) ##Getting the specific "time" term coefficients, p-values or F-values. ## Omit "term" parameter for all available terms. timeCoef<-coef(fit,term="time") fit.p.values<-p.values(fit,term="time") fit.f.values<-F.p.values(fit,term="time") ##Getting the residuals or fitted values, for the interaction "time:oxygen" ## term. Omit "term" parameter for all available terms. interactionResid<-resid(fit, term="time:oxygen") interactionFit<-fitted(fit, term="time:oxygen") }
leverage
test of lmdme objectsThis function calculates the leverage test for each individual using the Principal Component Analysis (comps function) on the coefficients of the given decomposed model term.
object |
lmdme class object. |
comps |
a numeric vector indicating the PCA component indexes to keep. Default the first two components (1:2). |
term |
a character specifying the model term. |
level |
the quantile level. Default value 0.95 |
data.frame with the following fields
leverage |
numeric for the corresponding row leverage |
over |
logical indicating if the leverage > quantile(leverage,level) for the given decomposed term |
Cristobal Fresno and Elmer A Fernandez
Tarazona S, Prado-Lopez S, Dopazo J, Ferrer A, Conesa A, Variable Selection for Multifactorial Genomic Data, Chemometrics and Intelligent Laboratory Systems, 110:113-122 (2012)
{ 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) ##Leverages for the first two Principal Components and q95 (default value). ##Leverages for the first three Principal Components and q99. leverages2PCDefault<-leverage(fit, term="time:oxygen") leverages3PCq99<-leverage(fit, comps=1:3, term="time:oxygen", level=0.99) }
{ 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) ##Leverages for the first two Principal Components and q95 (default value). ##Leverages for the first three Principal Components and q99. leverages2PCDefault<-leverage(fit, term="time:oxygen") leverages3PCq99<-leverage(fit, comps=1:3, term="time:oxygen", level=0.99) }
Linear model ANOVA decomposition of Designed Multivariate
Experiments based on limma lmFit
implementation. For example in a two factor experimental
design with interaction, the linear model of the i-th
observation (gene) can be written:
where
X stands for the observed value
the intercept
A, B and AB are the first, second and interaction terms respectively
The error term
.
The model is iteratively decomposed in a step by step fashion decomposing one term each time:
The
intercept is estimated using
The
first factor (A) using
The second
factor (B) using
The interaction
(AB) using .
For each decomposed step the model, residuals, coefficients, p-values and F-value are stored in a list container, so their corresponding length is equal to the number of model terms + 1 (the intercept).
model |
formula object to carry out the decomposition. |
data |
matrix or data.frame with individuals/genes (per rows) and samples/conditions (per columns). |
design |
data.frame with the design of the experiment, (rows) samples/conditions as in data columns and as many columns to indicate the factors present in each sample. |
Bayes |
Should limma estimate empirical Bayes statistics, i. e., moderated t-statistics? Default value is FALSE. |
verbose |
Should the process progress be printed? Default value is FALSE. |
... |
Additional parameters for |
lmdme |
lmdme class object with the corresponding completed slots according to the given model |
use lmdme
high level constructor for
the creation of the class instead of directly calling its
constructor by means of new.
Cristobal Fresno and Elmer A Fernandez
Smyth, G. K. (2005). Limma: linear models for microarray data. In: Bioinformatics and Computational Biology Solutions using R and Bioconductor. R. Gentleman, V. Carey, S. Dudoit, R. Irizarry, W. Huber (eds), Springer, New York, pages 397–420.
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/.
{ 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) }
{ 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) }
Linear Model ANOVA decomposition of Designed Multivariate
Experiments based on limma lmFit
implementation. For example in a two factor experimental
design with interaction, the linear model of the i-th
observation (gene) can be written:
where
X stands for the observed value
The intercept
A, B and AB are the first, second and interaction terms respectively
The error term
.
The model is iterative decomposed in a step by step fashion decomposing one term at each time:
The intercept is
estimated using
The first factor
(A) using
The second factor (B)
using
The interaction (AB) using
.
For each decomposed step the model, residuals, coefficients, p-values and F-values are stored in a list container, so their corresponding length is equal to the number of model terms + 1 (the intercept).
Flexible formula type interface,
Fast limma based implementation based on
lmFit
,
p values for each estimated coefficient levels in each factor
F values for factor effects
Plotting functions for PCA and PLS.
design: data.frame with experimental design.
model: formula with the designed model to be decomposed.
modelDecomposition: list with the model formula obtained for each decomposition step.
residuals: list of residual matrices G rows(genes) x N columns (arrays-designed measurements).
coefficients: list of coefficient matrices. Each matrix will have G rows(genes) x k columns(levels of the corresponding model term).
p.values: list of p-value matrices.
F.p.values: list with corresponding F-p-values vectors for each individual.
components: list with corresponding PCA or PLS components for the selected term/s.
componentsType: name character vector to keep process trace of the variance/covariance components slot: decomposition ("pca" or "pls"), type ("apca" for ANOVA-PCA or "asca" for ANOVA-SCA) and scale ("none", "row" or "column")
Basic output for lmdme class
Basic statistics for lmdme class
Getters for their respective slots.
Getters for their respective slots.
Function that produces the complete ANOVA decomposition based on model specification through a formula interface. Technically it's a high level wrapper of the initialize function.
Getter for the used decomposed formula in each step
Adjust coefficients p-values for the Multiple Comparison Tests.
Getters for the corresponding associated decomposed model coefficient statistics in each step, for each observation.
Getters for the corresponding decomposed model in each step.
Produces the specified lmdme in addition to the required permuted objects (sampling the columns of data), using the same parameters to fit the model.
Function to perform PCA
or PLS on the ANOVA decomposed terms. PCA can be
performed on ,
or
and it is
referred to, as ANOVA-PCA (APCA) but, if it is performed
on the coefficients it is referred to, as ANOVA-SCA
(ASCA). On the other hand PLSR is based on pls library
and if it is performed on coefficients (ASCA like) it
uses the identity matrix for output co-variance
maximization or can be carried out on the
(APCA like) using the design matrix as the output.
Getter for PCA or PLS decomposed models.
Getter for componentsType slot.
Leverage calculation on PCA (APCA or ASCA) terms.
Biplots for PCA or PLSR decomposed terms.
Screeplot on each PCA decomposed term.
Loadingplot for PCA interaction terms.
Cristobal Fresno and Elmer A Fernandez
Smilde AK, Jansen JJ, Hoefsloot HCJ,
Lamer RAN, Van der Greef J, Timmerman ME (2005)
ANOVA-simultaneaus component analysis (ASCA): a new tool
for analyzing designed
metabolomics data,
Bioinformatics 21,13,3043
DOI:/10.1093/bioinformatics/bti476
Zwanenburg G,
Hoefsloot HCJ, Westerhuis JA, Jansen JJ, Smilde AK (2011)
ANOVA.Principal component analysis and ANOVA-simultaneaus
component analysis: a comparison J.
Chemometrics
25:561-567 DOI:10.1002/cem.1400
Tarazona S, Prado-Lopez S, Dopazo J, Ferrer A, Conesa A (2012) Variable Selection for Multifactorial Genomic Data, Chemometrics and Intelligent Laboratory Systems, 110:113-122
lmdme
, decomposition
,
biplot
, loadingplot
and
additional related lmdme class functions.
loadingplot
of interaction PCA decomposed lmdme objectThis function plots the PCA loadings for a given interaction (A:B) lmdme object's components slot, for the given "pc" component. The user can choose which term (A or B) is used for x-axis and y-axis functions (B or A) respectively.
## S4 method for signature 'lmdme' loadingplot(object, term.x, term.y, pc=1, ord.x, col, ...)
## S4 method for signature 'lmdme' loadingplot(object, term.x, term.y, pc=1, ord.x, col, ...)
object |
lmdme class object. |
term.x , term.y
|
character indicating the model principal factor for the interaction term (term.x:term.y or term.y:term.x) for the corresponding x or y axis. |
pc |
integer indicating which principal component loading is to be plotted on the y-axis. Default value is 1. |
col |
which color to use for each level present in term.y. |
ord.x |
numeric indicating the term.x levels order, for plotting purposes. If missing, the levels order is used. |
... |
additional parameters for matplot. |
loading plot of the selected interaction (term.x:term.y) lmdme object's components slot, if PCA decomposition was applied.
Cristobal Fresno and Elmer A Fernandez
{ 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) ##ASCA for all the available terms, on those subjects/genes where at least ##one interaction coefficient is statistically different from zero (F-test ##on the coefficients). id<-F.p.values(fit, term="time:oxygen")<0.001 decomposition(fit, decomposition="pca", scale="row", subset=id) ## Not run: loadingplot(fit, term.x="time", term.y="oxygen") ##Or change the axis order loadingplot(fit, term.x="oxygen", term.y="time") ##Or change the PC to display loadingplot(fit, term.x="time", term.y="oxygen", pc=2) ##Or the order of x-levels loadingplot(fit, term.x="time", term.y="oxygen", ord.x=3:1) ## End(Not run) }
{ 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) ##ASCA for all the available terms, on those subjects/genes where at least ##one interaction coefficient is statistically different from zero (F-test ##on the coefficients). id<-F.p.values(fit, term="time:oxygen")<0.001 decomposition(fit, decomposition="pca", scale="row", subset=id) ## Not run: loadingplot(fit, term.x="time", term.y="oxygen") ##Or change the axis order loadingplot(fit, term.x="oxygen", term.y="time") ##Or change the PC to display loadingplot(fit, term.x="time", term.y="oxygen", pc=2) ##Or the order of x-levels loadingplot(fit, term.x="time", term.y="oxygen", ord.x=3:1) ## End(Not run) }
p.adjust
of p-values for Multiple Test Comparison CorrectionsGiven a set of p-values, returns adjusted p-values using one of several methods.
## S4 method for signature 'lmdme' p.adjust(p, term=NULL, method=p.adjust.methods, drop=TRUE)
## S4 method for signature 'lmdme' p.adjust(p, term=NULL, method=p.adjust.methods, drop=TRUE)
p |
numeric vector of p-values as in stats::p.adjust or lmdme class object. |
method |
correction method available in
|
term |
character with the corresponding term to return. |
... |
other arguments. |
drop |
should try to drop the list structure if length==1? Default value is TRUE |
according to the call, one of the following objects can be returned
numeric |
vector of adjusted p-values. |
matrix |
for lmdme object If term!=NULL, the corresponding character is looked up within the list of p.values returning the associated matrix of G rows (individuals) x k columns (levels of the corresponding model term) with the adjusted p-values. |
Cristobal Fresno and Elmer A Fernandez
{ 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) ##Adjust p-values only on the interaction p.values using false discovery rate ## method pInteraction<-p.values(fit, term="time:oxygen") FDRInteraction<-p.adjust(fit, term="time:oxygen", method="fdr") corrected<-sum(pInteraction < 0.05) - sum(FDRInteraction < 0.05) }
{ 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) ##Adjust p-values only on the interaction p.values using false discovery rate ## method pInteraction<-p.values(fit, term="time:oxygen") FDRInteraction<-p.adjust(fit, term="time:oxygen", method="fdr") corrected<-sum(pInteraction < 0.05) - sum(FDRInteraction < 0.05) }
permutation
of the specified lmdme objectProduces the specified lmdme plus the required permuted objects (sampling the columns), using the same parameters to fit the additional models.
## S4 method for signature 'formula,data.frame,data.frame' permutation(model,data,design,Bayes=FALSE,verbose=FALSE,NPermutations=100,nCpus=1,...)
## S4 method for signature 'formula,data.frame,data.frame' permutation(model,data,design,Bayes=FALSE,verbose=FALSE,NPermutations=100,nCpus=1,...)
model |
formula object to carry out the decomposition. |
data |
data.frame with individuals (rows) and samples/conditions (columns) |
design |
data.frame with the design of the experiment, (rows) samples/conditions as in data columns and as many columns to indicate the factors present in each sample. |
Bayes |
Should limma estimate empirical Bayes statistics, i.e., moderated t-statistics? Default value is FALSE. |
verbose |
Should the process progress be printed? Default value is FALSE. |
NPermutations |
number of permutations to be calculated. Default value is 100. |
nCpus |
number of cores to be used. Default value is 1, i.e. sequential calculation. |
... |
Additional parameters for the
|
list |
contains the original lmdme object plus the required amount of permuted versions. |
Cristobal Fresno and Elmer A Fernandez
{ 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] ##Just to test if it works. In a real scenario, use NPermutations >= 100 if ##the conditions (columns) of M allow it. Verbose parameter is FALSE by ##default permuted<-permutation(model=~time*oxygen, data=M, design=design, NPermutations=2, nCpus=3) }
{ 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] ##Just to test if it works. In a real scenario, use NPermutations >= 100 if ##the conditions (columns) of M allow it. Verbose parameter is FALSE by ##default permuted<-permutation(model=~time*oxygen, data=M, design=design, NPermutations=2, nCpus=3) }
Show
, Print
or Summary
a lmdme objectGeneric Show/Print/Summary method for lmdme class output visualization.
## S4 method for signature 'lmdme' print(x, term) ## S4 method for signature 'lmdme' show(object) ## S4 method for signature 'lmdme' summary(object)
## S4 method for signature 'lmdme' print(x, term) ## S4 method for signature 'lmdme' show(object) ## S4 method for signature 'lmdme' summary(object)
x |
lmdme class object. |
object |
lmdme class object. |
term |
character with the corresponding term to return. Default value is NULL to return every decomposed term (if more than one is available). |
according to the call
print , show or
summary:
|
console output text with increasing detail of lmdme object. |
show or summary |
console output text of the lmdme object, plus a data.frame with model decomposition summary data. |
Cristobal Fresno and Elmer A Fernandez
lmdme
, coef
,
resid
, fitted
,
modelDecomposition
,
components
, componentsType
{ 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) } ## Not run: #equivalent to call show(fit) fit print(fit) summary(fit) ## End(Not run)
{ 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) } ## Not run: #equivalent to call show(fit) fit print(fit) summary(fit) ## End(Not run)
screeplot
of a PCA decomposed lmdme objectScreeplot on each decomposed "pca" model present in lmdme components slot.
## S4 method for signature 'lmdme' screeplot(x, independent=TRUE, col=seq(along=components(x)), npcs, term=NULL, mfcol, ...)
## S4 method for signature 'lmdme' screeplot(x, independent=TRUE, col=seq(along=components(x)), npcs, term=NULL, mfcol, ...)
x |
lmdme class object. |
independent |
logical indicating whether the screeplots should be plotted together. Default value is FALSE. |
col |
which color to use for each decomposed model. Default value seq(along= components(x)). |
npcs |
integer with the number of components to plot. By default all present components are plotted. |
term |
character with the corresponding term/s for biploting. Default value is NULL in order to obtain every available biplot/s. |
mfcol |
numeric vector for par layout. If missing, mfcol=c(1,2) will be used if more than one biplot is available. Use mfcol==NULL to override par call inside biplot function. |
... |
additional parameters for screeplot or plot/lines according to independent FALSE or TRUE respectively. |
plotted screeplot/s of the components slot if PCA decomposition was applied.
Cristobal Fresno and Elmer A Fernandez
stats::screeplot
{ 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) ##ASCA for all the available terms, on those subjects/genes where at least ##one interaction coefficient is statistically different from zero (F-test ##on the coefficients). id<-F.p.values(fit,term="time:oxygen")<0.001 decomposition(fit, decomposition="pca", scale="row", subset=id) ## Not run: par(mfrow=c(2,2)) ##Does not call par inside screeplot(fit,mfcol=NULL) ##Just the term of interest screeplot(fit,term="time") ##In separate graphics screeplot(fit,term=c("time","oxygen"),mfcol=c(1,1)) ##All term in the same graphic device screeplot(fit,mfcol=c(1,3)) ##All in the same graphic screeplot(fit,independent=FALSE) ## End(Not run) }
{ 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) ##ASCA for all the available terms, on those subjects/genes where at least ##one interaction coefficient is statistically different from zero (F-test ##on the coefficients). id<-F.p.values(fit,term="time:oxygen")<0.001 decomposition(fit, decomposition="pca", scale="row", subset=id) ## Not run: par(mfrow=c(2,2)) ##Does not call par inside screeplot(fit,mfcol=NULL) ##Just the term of interest screeplot(fit,term="time") ##In separate graphics screeplot(fit,term=c("time","oxygen"),mfcol=c(1,1)) ##All term in the same graphic device screeplot(fit,mfcol=c(1,3)) ##All in the same graphic screeplot(fit,independent=FALSE) ## End(Not run) }