Hello,
I obtained the ancestry matrix from sNMF and after that, I plot the bar plots (K2 to K4) using tess3r package as the following code line:
my.colors =c("green","yellow", "red","blue")
my.palette <- CreatePalette(my.colors, 9)
##
barplot(qq, border = NA, pace = 0,
xlab = "Individuals", ylab = "Ancestry proportions",
main = "Ancestry matrix_K4", col.palette = my.palette , sort.by.Q = F) -> bp
axis(1, at = 1:nrow(qq), labels = bp$order, las = 3, cex.axis = .4)
Results: https://i.ibb.co/K082W3H/Screen-Shot-2019-08-05-at-4-22-42-PM.png
I am interested to create 9 bar plots from K2 to K10, but my main concern is the ordered of the color, I want each cluster to have a specific color. in the link I shared (https://i.ibb.co/K082W3H/Screen-Shot-2019-08-05-at-4-22-42-PM.png) notice that in K3 the bars are flipped, the bottom ones in K2 became in the top in K3.
I don't want to have this, I want to have the same order in all K with a specific color for each cluster.
So for example, when doing from K2 (green and yellow), in K3, I would have the same two colors from the two clusters in K2 and the new color explain cluster3 .... etc
Something like this, https://i.ibb.co/D8V8hJD/Screen-Shot-2019-08-05-at-4-50-17-PM.png , where you would be able to distinguish which color belong to which cluster based on the previous K
I hope my explanation is clear.
Thanks,
Please see How to add images to a Biostars post to add your images properly. You need the direct link to the image, not the link to the webpage that has the image embedded (which is what you have used here)