Mercurial > repos > drosofff > msp_sr_readmap_and_size_histograms
annotate plot_size_readmap.r @ 9:92898cc3ea19 draft
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 3effd45f45c37a6cdaf9b7b1da1ed4d10d3b0e38
author | drosofff |
---|---|
date | Sat, 08 Oct 2016 07:18:18 -0400 |
parents | be0c6b6466cc |
children | 45df4c72a780 |
rev | line source |
---|---|
8
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
1 ## Setup R error handling to go to stderr |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
2 options( show.error.messages=F, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
3 error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
4 library(RColorBrewer) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
5 library(lattice) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
6 library(latticeExtra) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
7 library(grid) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
8 library(gridExtra) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
9 library(optparse) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
10 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
11 # Parse arguments |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
12 option_list <- list( |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
13 make_option(c("-r", "--readmap_tab"), type="character", help="Path to file with tabular readmap"), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
14 make_option(c("-s", "--size_distribution_tab"), type="character", help="Path to file with tabular size distribution"), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
15 make_option("--readmap_pdf", type="character", help="Path to file with readmap plot"), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
16 make_option("--size_distribution_pdf", type="character", help="Path to file with size distribution plot"), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
17 make_option("--combi_pdf", type="character", help="Path to file with size distribution and readmap plot"), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
18 make_option("--title", type="character", help="Title for readmaps and size distribution"), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
19 make_option("--xlabel", type="character", help="xlabel for readmaps and size distribution"), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
20 make_option("--ylabel", type="character", help="ylabel for readmaps and size distribution"), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
21 make_option("--yrange", type="integer", help="Y-axis range"), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
22 make_option("--rows_per_page", type="integer", help="rows_per_page") |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
23 ) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
24 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
25 parser <- OptionParser(usage = "%prog [options] file", option_list=option_list) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
26 args = parse_args(parser) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
27 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
28 ## data frames implementation |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
29 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
30 rm=read.delim(args$readmap_tab, header=T, row.names=NULL) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
31 n_samples=length(unique(rm$sample)) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
32 genes=unique(levels(rm$gene)) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
33 per_gene_readmap=lapply(genes, function(x) subset(rm, gene==x)) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
34 n_genes=length(per_gene_readmap) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
35 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
36 size=read.delim(args$size_distribution_tab, header=T, row.names=NULL) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
37 per_gene_size=lapply(genes, function(x) subset(size, gene==x)) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
38 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
39 ## end of data frames implementation |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
40 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
41 ## functions |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
42 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
43 plot_readmap=function(df, ...) { |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
44 combineLimits(xyplot(count~coord|factor(sample, levels=unique(sample))+reorder(gene, count, function(x) -sum(abs(x))), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
45 data=df, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
46 type='h', |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
47 scales= list(relation="free", x=list(rot=0, cex=0.7, axs="i", tck=0.5), y=list(tick.number=4, rot=90, cex=0.7)), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
48 xlab=NULL, main=NULL, ylab=NULL, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
49 as.table=T, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
50 origin = 0, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
51 horizontal=FALSE, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
52 group=polarity, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
53 col=c("red","blue"), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
54 par.strip.text = list(cex=0.7), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
55 ...)) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
56 } |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
57 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
58 plot_size_distribution= function(df, ...) { |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
59 smR.prepanel=function(x,y,...){; yscale=c(-max(abs(y)), max(abs(y)));list(ylim=yscale);} |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
60 bc= barchart(count~as.factor(size)|factor(sample, levels=unique(sample))+gene, data = df, origin = 0, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
61 horizontal=FALSE, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
62 group=polarity, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
63 stack=TRUE, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
64 col=c('red', 'blue'), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
65 cex=0.75, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
66 scales=list(y=list(tick.number=4, rot=90, relation="free", cex=0.7), x=list(cex=0.7) ), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
67 prepanel=smR.prepanel, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
68 xlab = NULL, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
69 ylab = NULL, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
70 main = NULL, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
71 as.table=TRUE, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
72 newpage = T, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
73 par.strip.text = list(cex=0.7), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
74 ...) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
75 combineLimits(bc) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
76 } |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
77 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
78 ## end of functions |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
79 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
80 ## function parameters' |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
81 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
82 par.settings.readmap=list(layout.heights=list(top.padding=0, bottom.padding=-2.5), strip.background = list(col=c("lightblue","lightgreen")) ) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
83 par.settings.size=list(layout.heights=list(top.padding=-1, bottom.padding=-2.5), strip.background = list(col=c("lightblue","lightgreen")) ) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
84 par.settings.combination.readmap=list(layout.heights=list(top.padding=0, bottom.padding=-3), strip.background=list(col=c("lightblue","lightgreen")) ) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
85 par.settings.combination.size=list(layout.heights=list(top.padding=-2, bottom.padding=-0.5), strip.background=list(col=c("lightblue", "lightgreen")) ) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
86 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
87 ## end of function parameters' |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
88 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
89 ## GRAPHS |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
90 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
91 if (n_genes > 7) {page_height_simple = 11.69; page_height_combi=11.69; rows_per_page=args$rows_per_page} else { |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
92 rows_per_page= n_genes; page_height_simple = 2.5*n_genes; page_height_combi=page_height_simple*2 } |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
93 if (n_samples > 4) {page_width = 8.2677*n_samples/4} else {page_width = 8.2677*n_samples/3} # to test |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
94 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
95 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
96 pdf(file=args$readmap_pdf, paper="special", height=page_height_simple, width=page_width) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
97 for (i in seq(1,n_genes,rows_per_page)) { |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
98 start=i |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
99 end=i+rows_per_page-1 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
100 if (end>n_genes) {end=n_genes} |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
101 if (args$yrange == 0) { readmap_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, par.settings=par.settings.readmap)) } else { |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
102 readmap_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, ylim=c(-args.yrange, args.yrange) , par.settings=par.settings.readmap)) } |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
103 args_list=c(readmap_plot.list, list(nrow=rows_per_page, ncol=1, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
104 top=textGrob("Read Maps (nucleotide coordinates)", gp=gpar(cex=1), just="top"), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
105 left=textGrob(args$ylabel, gp=gpar(cex=1), vjust=1, rot=90) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
106 ) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
107 ) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
108 do.call(grid.arrange, args_list) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
109 } |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
110 devname=dev.off() |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
111 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
112 pdf(file=args$size_distribution_pdf, paper="special", height=page_height_simple, width=page_width) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
113 for (i in seq(1,n_genes,rows_per_page)) { |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
114 start=i |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
115 end=i+rows_per_page-1 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
116 if (end>n_genes) {end=n_genes} |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
117 plot.list=lapply(per_gene_size[start:end], function(x) plot_size_distribution(x, par.settings=par.settings.size) ) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
118 args_list=c(plot.list, list(nrow=rows_per_page, ncol=1, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
119 top=textGrob("Size distributions (in nucleotides)", gp=gpar(cex=1), just="top"), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
120 left=textGrob(args$ylabel, gp=gpar(cex=1), vjust=1, rot=90) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
121 ) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
122 ) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
123 do.call(grid.arrange, args_list) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
124 } |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
125 devname=dev.off() |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
126 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
127 pdf(file=args$combi_pdf, paper="special", height=page_height_combi, width=page_width) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
128 if (rows_per_page %% 2 != 0) { rows_per_page = rows_per_page + 1} |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
129 for (i in seq(1,n_genes,rows_per_page/2)) { |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
130 start=i |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
131 end=i+rows_per_page/2-1 |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
132 if (end>n_genes) {end=n_genes} |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
133 if (args$yrange == 0) {readmap_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, par.settings=par.settings.readmap)) } else { |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
134 readmap_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, ylim=c(-args.yrange, args.yrange), par.settings=par.settings.readmap)) } |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
135 size_plot.list=lapply(per_gene_size[start:end], function(x) plot_size_distribution(x, strip=FALSE, par.settings=par.settings.combination.size)) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
136 plot.list=rbind(readmap_plot.list, size_plot.list ) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
137 args_list=c(plot.list, list(nrow=rows_per_page+1, ncol=1, |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
138 top=textGrob(args$title, gp=gpar(cex=1), just="top"), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
139 left=textGrob(args$ylabel, gp=gpar(cex=1), vjust=1, rot=90), |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
140 sub=textGrob(args$xlabel, gp=gpar(cex=1), just="bottom") |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
141 ) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
142 ) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
143 do.call(grid.arrange, args_list) |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
144 } |
be0c6b6466cc
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit 97b40d7a593cef6c3303f7baba781a84d242e454
mvdbeek
parents:
diff
changeset
|
145 devname=dev.off() |