This is a test version of Biostars. For the public version, visit https://www.biostars.org.
PCA clusters color scheme

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

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.

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.

Which package in R are you using? - adegenet?

Yes, I am using adegenet.

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

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)

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?

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.

0 answers

No answers yet.

Log in to answer this question.