Question: How to do feature selection using PCA?
gravatar for ahmad mousavi
17 months ago by
ahmad mousavi470
Royan Institute, Tehran, Iran
ahmad mousavi470 wrote:


I have read about PCA and its power to do dimension reduction but for a specific project I need to do feature selection by PCA, although I know PCA might not be the best choice for it, but I need the result of PCA for feature selection.

Can anyone give me some advices or R code for that purpose?

My data contains both clinical and genomic information with a Target variable which define disease and healthy.


rna-seq pca R • 1.6k views
ADD COMMENTlink written 17 months ago by ahmad mousavi470

Are you looking to predict your Target Variable (disease/healthy) from the clinical and genomic data? It sounds like you have labeled training data where the disease/healthy classification is known. If so, you might want to use supervised approaches to do feature selection, rather than unsupervised approaches like PCA. Because your disease/healthy classes might not necessarily be driven by the features that drive overall variance in the data, and would be selected by PCA. If you do want to explore PCA, you could take your feature matrix (assuming it contains, or could be converted to, continuous-valued variables) and apply the R prcomp() function to derive principal components. You could then see what percentage of variance in the data your principal components explain, and if that looks reasonable, then you could select one or more of the principal components as your features for further modeling.

ADD REPLYlink written 17 months ago by Ahill1.8k

thanks @Ahill for good explanation. I don't want to group the variables based on their information in PCs.

Yes I have already know result label in my training set. How can I merge PCA score with Linear model?

Do you have any idea for combining PCA result with modeling (lm/GLM) ?

ADD REPLYlink modified 17 months ago • written 17 months ago by ahmad mousavi470
gravatar for Ahill
17 months ago by
United States
Ahill1.8k wrote:

It can be valid to use PC scores as the independent variables in linear models, instead of the underlying primary variables. For predicting a binary outcome like disease/healthy, you could look at a lm() logistic model like:

disease.status ~ PC1 + PC2 + ...

Of course, the usefulness of this will depend on the structure of your clinical and genomic predictors, and if the PCs are correlated with disease status.

ADD COMMENTlink written 17 months ago by Ahill1.8k

thanks, it woks for me.

ADD REPLYlink written 17 months ago by ahmad mousavi470

Moved this to answer. Thank you Ahill. Ahmad, feel free to up-vote and/or accept the answer if it helps.

ADD REPLYlink written 17 months ago by Kevin Blighe56k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1200 users visited in the last hour