Take the 2-minute tour ×
Biology Stack Exchange is a question and answer site for biology researchers, academics, and students. It's 100% free, no registration required.

I am trying to plot ADMIXTURE output in R. My output is two-dimentional (two columns, 190 rows). These rows represent individuals, and groups of them (e.g., 1-12) represent populations. I have eleven populations. What I'm hoping for is a plot with eleven different colours, basically like a STRUCTURE plot.

This code works, but plots with only two colours, not separating the populations

>tbl=read.table("filepath to file",sep=" ")
> barplot(t(as.matrix(tbl)), col=rainbow(4),
xlab="Individual #", ylab="Ancestry", border=NA)

I have tried to amend this with the following code:

>barplot(t(as.matrix(tbl[c(0:12, 13:32, 33:51, 52:69, 70:87, 88:104, 105:118, 119:137, 138:157, 158:172, 173:190), ])), 
col=c("darkgreen", "darkblue", "orange", "cyan", "yellow", "chartreuse", "blue", "cyan4", "red", "violet", "blueviolet"), 
xlab="Individual #", ylab="Ancestry", border=NA)

but this code really still says the same thing c(1:190)

Alternatively, this code separates the colours

    col=c("darkgreen", "darkblue", "orange", "cyan", "yellow", "chartreuse", "blue", "cyan4", "red", "violet", "blueviolet")
    [c(rep(1,length(1:12)),rep(2,length(13:32)), rep(3,length(33:51)), rep(4,length(52:69)), rep(5,length(70:87)), rep(6,length(88:104)), 
    rep(7,length(105:118)), rep(8,length(119:137)), rep(9,length(138:157)), rep(10,length(158:172)), rep(11,length(173:190)))],
    xlab="Individual #", ylab="Ancestry", border=NA)

But this only plots in one dimension. I've tried so many permutations of the concepts in each of these, and I just can't get it.

I've tried available code on the net, but I think my R skills aren't advanced enough to sort out their tricks. Any suggestions would be much appreciated.

Sincerely, Ella

share|improve this question
This question is off-topic as it is not about biology, but about using R. While we allow questions about tools used by biologists, this question is entirely about programming/graphing and not on-topic here. –  Mad Scientist Nov 8 '13 at 6:59
@Ella Just to clarify - you should ask this question at stackoverflow.com where it is clearly on-topic. –  fileunderwater Nov 8 '13 at 9:28
Ok, thanks for this. I've actually sorted out my problem now anyway, so I think I will not pursue it further. –  Ella Nov 12 '13 at 20:16
add comment

closed as off-topic by Mad Scientist Nov 8 '13 at 6:59

  • This question does not appear to be about biology within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.