I would like to color points in a pairs plot based of certain row indexes. Here is the code I used for plotting 1 variable against another.
cases<-which(rownames(data_no_na) %in% colnames(tumor_data))
controls<-which(rownames(data_no_na) %in% colnames(control_data))
plot(y=range(pca[,1]),x=range(pca[,2]),type='n',xlab="Principle Component 2",ylab="Principle Component 1", main="Iterative Thresholding Sparse PCA")
points(y=pca[cases,1], x=pca[cases,2], col = 'red' )
points(y=pca[controls,1], x=pca[controls,2], col = 'blue' );
A simple pairs plot is something like:
pairs(pca[,1:3])
EDIT: EXAMPLE:
cases<-1:10
controls<-11:20
pca<-matrix(c(rnorm(3*10,0,1),rnorm(3*10,5,1)),nrow=20,ncol=3)