Mercurial > repos > rico > quote_test
diff population_structure.r @ 0:939c20789501 default tip
Uploaded
author | rico |
---|---|
date | Fri, 06 Apr 2012 10:51:28 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/population_structure.r Fri Apr 06 10:51:28 2012 -0400 @@ -0,0 +1,19 @@ +library(RColorBrewer) + +args = commandArgs(trailingOnly=TRUE) +q_file = args[[1]] +output_file = args[[2]] +populations = args[[3]] + +tbl <- read.table(q_file) + +if ( populations >= 3 && populations <= 12 ) { + colors = brewer.pal(populations, 'Paired') +} else { + colors = rainbow(populations) +} + +pdf(file=output_file, onefile=TRUE, width=7, height=3) +barplot(t(as.matrix(tbl)), col=colors, xlab="Individual #", ylab="Ancestry", border=NA) + +dev.off()