Question: Placing labels in the plot
0
2.9 years ago by
akang90
akang90 wrote:

Hi all! I made an admixture plot and now i want to place the population names along the x-axis of the plot. I want to place the labels in he centre of the number of samples that belong to a particular population. If I have 5 populations with sample size 10, 20,20,35,100 then label should be at 10/2 for population 1, 20/2 for population 2 and so on. I tried the following but it doesnt work. Ill appreciate any further help!

``````pop<-c("pop1", "pop2", "pop3", "pop4", "pop5")
n<-c(10, 20,20,35,100)
at <- n/2
barplot(t(as.matrix(tbl)),col=rainbow(5),width=1,space=1)
mtext(1,at=at,text=pop,cex=1, las=2)
for{....
}
``````
plot admixture label R • 1.4k views
written 2.9 years ago by akang90

See this post, it may help

ADMIXTURE and R, color meaning on barplot in studing population ancestry, K value

The guide looks useful too:

Or these examples:

Thank's Natasha! In my case all what i am looking for is to place my labels with respect to my populations and their sample size..

Could you show us what you have and what you would like to have? An example?

I have a plot like this(without the labels on X-axis)..http://journals.plos.org/plosgenetics/article/figure/image?size=medium&id=info:doi/10.1371/journal.pgen.1004254.g006 To a barplot like this i want to add population labels(Like how you see in the plot). For plotting without population labels i did this but i dont know how to put population labels. Each row corresponds to each sample in the population. There are ~500 total samples belonging to 5 different populations. Each population has different number of samples. Example Input file is like below

``````test.5.Q
0.364957    0.00001 1.00E-05    0.00001 1.00E-05
0.485423    0.017426    1.00E-05    0.00001 1.00E-05
0.399289    0.00001 1.00E-05    0.002894    1.00E-05
0.579652    0.00001 1.00E-05    0.00001 1.00E-05
0.578574    0.00001 1.00E-05    0.00001 1.00E-05
0.597478    0.00001 1.00E-05    0.00001 1.00E-05