Question: PCA analysis using GRM and showing with different colors
gravatar for SheelS
3.3 years ago by
SheelS40 wrote:

I have built up a Genomic Relationship Martrix based on my SNP dataset.

And I want to assess the population structure using PCA. The R package I used is called prcomp.

Now I have made a PCA plot looks like link below, but all dots are with black dots.

I wonder how can I make them as different colors based on the 'GROUP' column in my example dataset.

Can anyone show me how to make it looks good step by step based on my GRM and SAMPLE file?

# Example dataset. 5 samples.
GRM <- read.table(textConnection("
1.63650789764753 0.340509314443612 0.226099930201148 0.376620916053879 0.158254769681645
0.340509314443612 1.83400749362486 0.717660112084021 0.92036913092054 0.765351049567537
0.226099930201148 0.717660112084021 1.76647251391584 0.589245058579147 0.735155682954209
0.376620916053879 0.92036913092054 0.589245058579147 1.74051192016634 0.56761339005198
0.158254769681645 0.765351049567537 0.735155682954209 0.56761339005198 1.66126870690556
 "), header = F)

SAMPLE <- read.table(textConnection("
1 A
2 A
3 B
4 C
5 D
 "), header = F)
population genetics prcomp pca R • 1.2k views
ADD COMMENTlink modified 3.3 years ago • written 3.3 years ago by SheelS40

This is an R programming question, you should probably be searching/asking on StackOverflow.
You don't show how you plot so it's not easy to help you because there are different ways of specifying colors depending on the graphics system you're using. If using the base R plot() function then have a look at the col option.

ADD REPLYlink written 3.3 years ago by Jean-Karim Heriche23k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1092 users visited in the last hour