PCA clusters color scheme
0
0
Entering edit mode
4.6 years ago
evelyn ▴ 230

Hello,

I am making PCA cluster plots. I am using different colors for each cluster. I am making PCA for two different vcf files for the same dataset and want to keep same colors for each of the clusters e.g., green for cluster 1 for both graphs. I am not sure how to keep the colors consistent throughout several graphs for each cluster.

I will appreciate any help. Thank you!

SNP • 1.6k views
ADD COMMENT
0
Entering edit mode

I am sorry... you will have to explain better what you want to do. Which program(s) are you using? Which input data are you using? Please paste examples of your code and data, if possible.

ADD REPLY
0
Entering edit mode

I am using DAPC. Here are a few lines for my input:

Sample1 Sample2 Sample3
A T A
C G G
T T A
G G C

I am using this code to make the graph:

myCol1 <- c("darkblue","purple","green")
scatter(myData1, col = myCol1)

I am making two graphs using the same colors.

myCol2 <- c("darkblue","purple","green")
scatter(myData2, col = myCol2)

I want to make Cluster 1 as darkblue color, Cluster 2 as purple color and Cluster 3 as green color in both graphs.

ADD REPLY
0
Entering edit mode

Which package in R are you using? - adegenet?

ADD REPLY
0
Entering edit mode

Yes, I am using adegenet.

ADD REPLY
0
Entering edit mode

Thank you. Can you please show the full sequence of commands that you are using?

ADD REPLY
0
Entering edit mode

Here is the full sequence of commands that I am using:

x1<-as.data.frame(t(x))
gen<-as.genlight(x1)
grp<-find.clusters(gen,max.n.clust = 10)
myData1<-dapc(gen, n.pca=3, grp$grp)
myCol1 <- c("darkblue","purple","green")
scatter(myData1, col = myCol1)
ADD REPLY
0
Entering edit mode

I have not used these functions in the past. Nevertheless, are you sure that you are using the col parameter correctly when passing it to scatter()? - does it not have to be the same length as your input variables?

ADD REPLY
0
Entering edit mode

So I have three clusters for my data and that is the reason I am using only three colors for scatter. I am just not sure how can I keep them consistent over different graphs from the same dataset.

ADD REPLY

Login before adding your answer.

Traffic: 3926 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6