# How to remove technical noise by discarding several leading PCA components? [duplicate]

I have a large metabolomics dataset, 6000 samples and 3300 features. For the samples the only thing that differentiates each sample from the rest is that one gene was knocked out, which will not affect most of the metabolites. The features are metabolite concentrations.

There are some 'known'/measured batch and technical variables such as different Mass Spec runs, differential growth of the bacteria in the samples. However, I also want to adjust for the unknown variables.

It has been suggested that I perform PCA then throw out the first few principal components. However, I'm not sure how I can use the PCA information to predict values for the original features using the remaining principal components.

df.pca <- prcomp(as.matrix(df.rw),
center = TRUE,
scale. = TRUE)

df.pca.x.minus12<-df.pca$x[,-c(1,2)]  How to predict values of the original 3300 features after removing the first 2 components? • The first (accepted) answer here stats.stackexchange.com/questions/57467 explains how to reconstruct original features in R using a small number of leading principal components. You need just a tiny modification: instead of using leading principal components, you use all except the leadings ones. – amoeba says Reinstate Monica Sep 21 '15 at 14:32 • Thanks, I had actually read that answer earlier but still couldn't quite follow. Reading it a second time, its now more clear. – user2814482 Sep 21 '15 at 19:33 • df.denoised <- df.pca$x[,3:3300] %*% t(df.pca\$rotation[,3:3300]), but then you probably want to de-scale and de-center the reconstructed data, as explained in the linked question. – amoeba says Reinstate Monica Sep 23 '15 at 10:42
• @amoeba I appreciate that the modification is in some sense "small" but in another sense it is asking quite the reverse. I think overall that this question benefits from having an answer in its own right, but certainly it is good for the new thread to be strongly linked to it. – Silverfish Aug 12 '16 at 12:11
• @Silverfish I tried to explicitly cover this situation in my new thread but perhaps I failed. Keeping the leading PCs and discarding the rest or discarding the leading PCs but keeping the rest is conceptually just exactly the same thing! Do you maybe think that I can make it more explicit in my new answer so that it could work as a duplicate? Any advises welcome. – amoeba says Reinstate Monica Aug 12 '16 at 12:14