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