annotate population_structure.r @ 31:a631c2f6d913

Update to Miller Lab devshed revision 3c4110ffacc3
author Richard Burhans <burhans@bx.psu.edu>
date Fri, 20 Sep 2013 13:25:27 -0400
parents 2c498d40ecde
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
1 library(RColorBrewer)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
2
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
3 args = commandArgs(trailingOnly=TRUE)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
4 q_file = args[[1]]
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
5 output_file = args[[2]]
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
6 populations = args[[3]]
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
7
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
8 tbl <- read.table(q_file)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
9
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
10 if ( populations >= 3 && populations <= 12 ) {
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
11 colors = brewer.pal(populations, 'Paired')
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
12 } else {
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
13 colors = rainbow(populations)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
14 }
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
15
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
16 pdf(file=output_file, onefile=TRUE, width=7, height=3)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
17 barplot(t(as.matrix(tbl)), col=colors, xlab="Individual #", ylab="Ancestry", border=NA)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
18
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
19 dev.off()