annotate population_structure.r @ 32:03c22b722882

remove BeautifulSoup dependency
author Richard Burhans <burhans@bx.psu.edu>
date Fri, 20 Sep 2013 13:54:23 -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()