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