This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to order Admixture (ancestry) plot in R

I created an ancestry plot in R from an Admixture analysis. But my order in is very bizarre.

This is the command I used for the plot (with K = 4):

tbl = read.table("~/path-to/my_admixture_analysis.4.Q")
 ord = tbl[order(tbl$V1,tbl$V2,tbl$V3,tbl$V4),]
 bp = barplot(t(as.matrix(ord)), 
              space = c(0.2),
              col=rainbow(4),
              xlab="Individual #", 
              ylab="Ancestry",
              border=NA)

As you can see, the purple bar is not lining properly and a couple of other bars are not OK. How can I fix that?

enter image description here

admixture r q plot

1 answer

Have you tried the R package PopHelper. I'm not involved in the tool development but looks good for what you are doing.

Log in to answer this question.