annotate coverage_plot.r @ 6:626b714f72bb

add gd_ploteig
author Richard Burhans <burhans@bx.psu.edu>
date Tue, 10 Apr 2012 13:51:19 -0400
parents 2c498d40ecde
children 8997f2ca8c7a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
1 x <- read.table('coverage2.txt', skip=1, sep='\t')
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
2
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
3 individuals <- dim(x)[1]
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
4 max_cov <- dim(x)[2] - 2
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
5 max_val <- max(x[-1]) / 100
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
6 colors <- rainbow(individuals)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
7
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
8 line_width = 3
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
9 xt = t(x)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
10
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
11 xvals <- c(0:max_cov)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
12 values <- as.numeric(as.vector(xt[,1][-1]))/100
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
13
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
14 pdf(file='coverage.pdf', onefile=TRUE, width=10, height=6);
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
15
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
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")
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
17
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
18 if (individuals > 1) {
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
19 for (i in 2:individuals) {
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
20 values <- as.numeric(as.vector(xt[,i][-1]))/100;
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
21 lines(xvals, values, col=colors[i], lwd=line_width);
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
22 }
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
23 }
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
24
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
25
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
26 names <- as.vector(t(x[1]))
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
27 legend(x='topright', legend=names, fill=colors, bty='n')
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
28
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
29 dev.off()
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
30
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
31