Mercurial > repos > miller-lab > genome_diversity
comparison 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 |
comparison
equal
deleted
inserted
replaced
26:91e835060ad2 | 27:8997f2ca8c7a |
---|---|
1 x <- read.table('coverage2.txt', skip=1, sep='\t') | 1 args <- commandArgs(TRUE); |
2 output_file <- args[1]; | |
2 | 3 |
3 individuals <- dim(x)[1] | 4 x <- read.table('coverage2.txt', skip=1, sep='\t'); |
4 max_cov <- dim(x)[2] - 2 | |
5 max_val <- max(x[-1]) / 100 | |
6 colors <- rainbow(individuals) | |
7 | 5 |
8 line_width = 3 | 6 individuals <- dim(x)[1]; |
9 xt = t(x) | 7 max_cov <- dim(x)[2] - 2; |
8 max_val <- max(x[-1]) / 100; | |
9 colors <- rainbow(individuals); | |
10 | 10 |
11 xvals <- c(0:max_cov) | 11 line_width = 3; |
12 values <- as.numeric(as.vector(xt[,1][-1]))/100 | 12 xt = t(x); |
13 | 13 |
14 pdf(file='coverage.pdf', onefile=TRUE, width=10, height=6); | 14 xvals <- c(0:max_cov); |
15 values <- as.numeric(as.vector(xt[,1][-1]))/100; | |
15 | 16 |
16 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") | 17 pdf(file=output_file, onefile=TRUE, width=10, height=6); |
18 | |
19 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"); | |
17 | 20 |
18 if (individuals > 1) { | 21 if (individuals > 1) { |
19 for (i in 2:individuals) { | 22 for (i in 2:individuals) { |
20 values <- as.numeric(as.vector(xt[,i][-1]))/100; | 23 values <- as.numeric(as.vector(xt[,i][-1]))/100; |
21 lines(xvals, values, col=colors[i], lwd=line_width); | 24 lines(xvals, values, col=colors[i], lwd=line_width); |
22 } | 25 } |
23 } | 26 } |
24 | 27 |
25 | 28 |
26 names <- as.vector(t(x[1])) | 29 names <- as.vector(t(x[1])); |
27 legend(x='topright', legend=names, fill=colors, bty='n') | 30 legend(x='topright', legend=names, fill=colors, bty='n'); |
28 | 31 |
29 dev.off() | 32 dev.off(); |
30 | |
31 |