I have the following dataframe:
Index PC1 PC2 Accession_no
1 0.037971642 -0.025406954 TKNK_MOUSE
2 -0.046295802 -0.026290312 TKN1_MOUSE
3 -0.113487427 0.06782228 GALA_MOUSE
4 -0.014441264 -0.116523664 VGF_MOUSE
5 -0.112657991 -0.089605827 CALCA_MOUSE
I want to plot PC1 vs PC2 and label points with index say 1,2 and 4 with the accession_no (also change the color of the dots).
I have the following code that plots and also colors the points accordingly.
plot(df$PC1,df$PC2, pch=19, col=ifelse(rownames(df)==c("1","2","4"),"red","black"))
However, only the first two points are showing in different color. Moreover, I also want to label the exact same points with their corresponding Accession_no
rownames(df)==c("1","2","4")byrownames(df) %in% c("1","2","4")? - fmarm