view population_structure.r @ 39:e56023008e36 default tip

Changed revision of package_fisher_0_1_4 to be2fc454d121 Changed revision of package_matplotlib_1_2 to a03ee94316b5
author miller-lab
date Mon, 06 Jul 2015 10:32:24 -0400
parents 2c498d40ecde
children
line wrap: on
line source

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()