How to get color on PCA plotting

Issue #757 new
Former user created an issue

Hi everyone, is there any way I can choose the coloring of my clusters in my PCA? I've noticed that the tutorial uses "attach(transducin)", however, my integrin protein has no correlation to any transducin data. Please feel free to reply if you know how I can incorporate different colors for my different clusters I have in my PCA graph. I have attached screenshots, thank you all!

Comments (2)

  1. Xinqiu Yao

    Provide a ‘color vector’ through the col argument of ‘plot.pca()’, and then all points will colored according to the vector. See ?plot.pca for more detail.

    Beforehand, you need to know how you want to color your data points. If you have done a clustering analysis, then the vector containing the cluster membership IDs will be a good choice (R will convert numeric values into specific colors). For example, plot(pc, col=grps), where grps is the result from the clustering.

    A typical workflow:

    # Clustering
    d <- dist(pc$z[, 1:2])
    hc <- hclust(d)
    grps <- cutree(hc, k=2)
    
    # Plot
    plot(pc, col=grps)
    

    Alternatively, you can color points based on the “state” of the structure. This is what is used in the transducin example, where data are colored based on the identity of bound ligands (GTP or GDP, for example). This information can be obtained via a careful inspection on the content of PDB files. A convenient tool that may help is pdb.annotate(). This method requires more knowledge about the system and need you to manually create a color vector matching the states of structures.

    Hope it helps.

  2. Log in to comment