Placing labels in the plot
0
0
Entering edit mode
8.3 years ago
akang ▴ 110

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{....
}
R Admixture Plot Label • 4.3k views
ADD COMMENT
0
Entering edit mode

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..

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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
> tbl=read.table("test.5.Q")
> barplot(t(as.matrix(tbl)), col=rainbow(3),xlab="Individual #", ylab="Ancestry", border=NA)
ADD REPLY

Login before adding your answer.

Traffic: 2677 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6