I'm doing PCA and I would like to plot first principal component vs second in R:
pca<-princomp(~.,data=data, na.action=na.omit
plot(pca$scores[,1],pca$scores[,2])
or maybe several principal components:
pairs(pca$scores[,1:4])
however the points are black. How do I appropriately add color to the graphs? How many colors do I need? One for each principal component I am plotting? Or one for each row in my data matrix?
Thanks
EDIT:
my data looks like this:
> data[1:4,1:4]
patient1 patient2 patient3 patient4
2'-PDE 0.0153750 0.4669375 -0.0295625 0.7919375
7A5 2.4105000 0.3635000 1.8550000 1.4080000
A1BG 0.9493333 0.2798333 0.7486667 0.7500000
A2M 0.2420000 1.0385000 1.1605000 1.6777500
So would this be appropriate:
plot(pca$scores[,1:4], pch=20, col=rainbow(dim(data)[1]))
plot(pca$scores[,1],pca$scores[,2]), col = c("red", "blue"...))
Give us an idea of what you are doing and we can figure out an easy way to generate that vector. So your last idea is correct: one for each row in your data set. – Bryan Hansonlmdme
package. It's a bit more than your original question calls for - it puts the focus on your exptl design instead of the particular genes, but might be a helpful, different way of visualizing your results. – Bryan Hanson