I have run a PCA on my microarray data and found the clustering pattern for my samples. Now I need to find out the genes which are associated with first principal component and likewise till 4th PC.
How would I go about finding that?
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It only takes a minute to sign up.Sign up to join this community
Principle components constitute a new space for your data. You need to multiply your data points with each eigenvector representing the selected components to project them onto the new space. Then you can run a clustering algorithm to decide which points belong to which cluster, e.g. k-means if classes are well separated and globular.
I would recommend either plotting the features into the PCA space like in Fig. 1 of this tutorial (note that FactoMineR in R does this nicely) or, as others have recommended, run a clustering algorithm, then perform tests for differential expression on the results of the clusters.
In Python I would do this the following way:
from sklearn import decomposition from pandas import DataFrame # assuming training data is a pandas dataframe named 'train' # training the PCA pca = decomposition.PCA() pca.fit(train) # getting the weights for original parameters for i in range(0,4): featureWeights = list(pca.components_[i]) weights = DataFrame(data = featureWeights) filename = 'principal_component_' + str(i) + '.txt' weights.to_csv(filename, sep = '\t')
Then you get the weights how much each original component contributes into the new component in four .txt files. You can take the genes that have an absolute value above an arbitrary threshold.