When you want to get to know and love your data

Archive for January, 2013

Modeling Short-term Glucose Effects on Primary Metabolism




# Need pwr package

# t-TEST

n<-1:150 # sample sizes




#plot results using base
obj<-t.test.power.effect # object to plot
lwd=5 # line thickness

#highligh important effect sizes
imp<-c(2,5,8) # cuts


#initialize plot
#add custom axis and grid
#plot lines

Which makes the following graph.
power calculation for t-test



#plot using ggplot2
#plot results using ggplot2
x11() # graphic device on windows

# wow ggplot2 is amazing in its brevity
# need to tweak legend and lty, but otherwise very similar
power calculation for t-test ggplot2

Covariate Adjustement for PLS-DA Models

A typical experiment may involve the testing of a wide variety of factors. For instance, here is an example of an experiment aimed at determining metabolic differences between two plant cultivars at three different ontological stages and in two different tissues. Exploratory principal components analysis (PCA) can be used to evaluate the major modes of variance in the data prior to conducting any univariate tests.

PCA complete data set

Based on the PCA (autoscaled data) we can see that the majority of the differences are driven by differences between tissues. This is evident from the scores separation in (a) between leaf and fruit tissues, which is driven by metabolites with large positive/negative loadings  on the first dimension or x-axis in (b). A lesser mode of variance is captured in the second dimension, and particularly in fruit we can see that there is some separation in scores between the two cultivars and their different ontological stages. Based on this it was concluded to carry out test in leaf and fruit tissue separately. Additionally in order to identify the effects of cultivar on the metabolomic profiles which are independent of stage and vice versa, a linear covariate adjustments were applied to the data.  

covar adjusted data

Again using PCA and focusing on fruit tissue, we can evaluate the variance in the data given our hypotheses (differences between cultivars or stages). Looking at (a) we can see that there is not a clear separation in scores in any one dimension between cultivars or stages. However there is separation in two dimensions. This is problematic in that this suggest that there is an interaction between cultivar and stage, which will complicate any univariate tests for these factors. We can see that carrying out linear covariate adjustment either for  cultivar (b) or stage (c) translate the variance for the target hypothesis into one dimension, which therefore simplifies its testing. Note, this is exactly what is done when doing an analysis of covariance or ANCOVA. However if we want to use this same favorable variance environment for multivariate modeling like for example partial least squares projection to latent structures discriminant analysis (PLS-DA) we need to covariate adjust the data which in this case is achieved by taking the residuals from linear model for the covariate we want to adjust for.

PLS-DA of covariate adjusted data

Now that we have adjusted the data for covariate effects we can test the primary hypotheses (differences between cultivars, stages and tissues) using PLS-DA. Quick  visual inspection of model scores can be used to get a feel for the quality of the models. Ideally we would like to see a scores separation between the various levels of our hypotheses in one dimension.  We can see that  both fruit models  are of higher quality than that for leaf.  However to fully validate these models we  need to carry out some permutation testing or something similar. The benefit of PLS-DA is that   we can use  the information about the variables contribution to the scores separation or loadings to identify metabolomic differences between cultivars or with increasing maturity or stage.

net cultHere is an example where PLS-DA variable loadings are mapped into a biochemical context using a chemical similarity network.  This network represents differences in metabolites due to cultivar, wherein significant differences  in metabolite means (ANCOVA, FDR adjusted p-value < 0.05)  between cultivars are represented by nodes or vertices which are colored  based on the sign of the loading and their size  used to encode the magnitude of their loading in the model.

net 2

We can now compare the two networks  representing metabolomic differences due to cultivar (far top) or to stage (above) to identify biochemical changes due to these factors which are independent of each others effects (or interaction).