Mercurial > repos > miller-lab > genome_diversity
diff coverage_plot.r @ 27:8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
author | Richard Burhans <burhans@bx.psu.edu> |
---|---|
date | Mon, 15 Jul 2013 10:47:35 -0400 |
parents | 2c498d40ecde |
children |
line wrap: on
line diff
--- a/coverage_plot.r Mon Jun 03 12:29:29 2013 -0400 +++ b/coverage_plot.r Mon Jul 15 10:47:35 2013 -0400 @@ -1,19 +1,22 @@ -x <- read.table('coverage2.txt', skip=1, sep='\t') +args <- commandArgs(TRUE); +output_file <- args[1]; + +x <- read.table('coverage2.txt', skip=1, sep='\t'); -individuals <- dim(x)[1] -max_cov <- dim(x)[2] - 2 -max_val <- max(x[-1]) / 100 -colors <- rainbow(individuals) +individuals <- dim(x)[1]; +max_cov <- dim(x)[2] - 2; +max_val <- max(x[-1]) / 100; +colors <- rainbow(individuals); -line_width = 3 -xt = t(x) +line_width = 3; +xt = t(x); -xvals <- c(0:max_cov) -values <- as.numeric(as.vector(xt[,1][-1]))/100 +xvals <- c(0:max_cov); +values <- as.numeric(as.vector(xt[,1][-1]))/100; -pdf(file='coverage.pdf', onefile=TRUE, width=10, height=6); +pdf(file=output_file, onefile=TRUE, width=10, height=6); -plot(xvals, values, type='l', ylim=c(0, max_val), xlim=c(0, max_cov), col=colors[1], lwd=line_width, xlab="Coverage", ylab="Proportion") +plot(xvals, values, type='l', ylim=c(0, max_val), xlim=c(0, max_cov), col=colors[1], lwd=line_width, xlab="Coverage", ylab="Proportion"); if (individuals > 1) { for (i in 2:individuals) { @@ -23,9 +26,7 @@ } -names <- as.vector(t(x[1])) -legend(x='topright', legend=names, fill=colors, bty='n') +names <- as.vector(t(x[1])); +legend(x='topright', legend=names, fill=colors, bty='n'); -dev.off() - - +dev.off();