# HG changeset patch # User mvdbeek # Date 1454435227 18000 # Node ID 44a0b0fa52a9e3c47231914b23c036b72ca693f4 # Parent 4e7f59d5ee18a293fbe285a57cebcc99d02414ac planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit e27d18d58ae095e7fad4b08b04370857a1d37964-dirty diff -r 4e7f59d5ee18 -r 44a0b0fa52a9 readmap.xml --- a/readmap.xml Tue Feb 02 11:50:13 2016 -0500 +++ b/readmap.xml Tue Feb 02 12:47:07 2016 -0500 @@ -1,4 +1,4 @@ - + from sRbowtie aligment bowtie @@ -77,145 +77,151 @@ - + - + 7) {page_height_simple = 11.69; page_height_combi=11.69; rows_per_page=${rows_per_page}; extrarow=0 } else { - rows_per_page= 8; page_height_simple = 11.69; page_height_combi=11.69; extrarow=0 } - ## rows_per_page= 8; page_height_simple = 11.69/7*n_genes; page_height_combi=11.69/9*(n_genes*2); extrarow=0 } - ## rows_per_page= n_genes; page_height_simple = 11.69/n_genes/4; page_height_combi=11.69/(n_genes*2); extrarow=1 } - if (n_samples > 4) {page_width = 8.2677*n_samples/4} else {page_width = 8.2677*n_samples/3} # to test + plot_size_distribution= function(df, ...) { + smR.prepanel=function(x,y,...){; yscale=c(-max(abs(y)), max(abs(y)));list(ylim=yscale);} + bc= barchart(count~as.factor(size)|factor(sample, levels=unique(sample))+gene, data = df, origin = 0, + horizontal=FALSE, + group=polarity, + stack=TRUE, + col=c('red', 'blue'), + cex=0.75, + scales=list(y=list(tick.number=4, rot=90, relation="free", cex=0.7), x=list(cex=0.7) ), + prepanel=smR.prepanel, + xlab = NULL, + ylab = NULL, + main = NULL, + as.table=TRUE, + newpage = T, + par.strip.text = list(cex=0.7), + ...) + combineLimits(bc) + } - pdf(file="${readmap_PDF}", paper="special", height=page_height_simple, width=page_width) - for (i in seq(1,n_genes,rows_per_page)) { - start=i - end=i+rows_per_page-1 - if (end>n_genes) {end=n_genes} - readmap_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, par.settings=par.settings.readmap)) - args.list=c(readmap_plot.list, list(nrow=rows_per_page, ncol=1, - main=textGrob("Read Maps (nucleotide coordinates)", gp=gpar(cex=1), just="top"), - left=textGrob("${ylabel}", gp=gpar(cex=1), vjust=1, rot=90) - #sub=textGrob("readmap coordinates", gp=gpar(cex=.75), just="bottom") - ) - ) - do.call(grid.arrange, args.list) - } - devname=dev.off() + ## end of functions + + ## function parameters' + + par.settings.readmap=list(layout.heights=list(top.padding=0, bottom.padding=-2.5), strip.background = list(col=c("lightblue","lightgreen")) ) + par.settings.size=list(layout.heights=list(top.padding=-1, bottom.padding=-2.5), strip.background = list(col=c("lightblue","lightgreen")) ) + par.settings.combination.readmap=list(layout.heights=list(top.padding=0, bottom.padding=-3), strip.background=list(col=c("lightblue","lightgreen")) ) + par.settings.combination.size=list(layout.heights=list(top.padding=-2, bottom.padding=-0.5), strip.background=list(col=c("lightblue", "lightgreen")) ) + + ## end of function parameters' + + ## GRAPHS + + if (n_genes > 7) {page_height_simple = 11.69; page_height_combi=11.69; rows_per_page=${rows_per_page}; extrarow=0 } else { + rows_per_page= 8; page_height_simple = 11.69; page_height_combi=11.69; extrarow=0 } + ## rows_per_page= 8; page_height_simple = 11.69/7*n_genes; page_height_combi=11.69/9*(n_genes*2); extrarow=0 } + ## rows_per_page= n_genes; page_height_simple = 11.69/n_genes/4; page_height_combi=11.69/(n_genes*2); extrarow=1 } + if (n_samples > 4) {page_width = 8.2677*n_samples/4} else {page_width = 8.2677*n_samples/3} # to test - pdf(file="${size_PDF}", paper="special", height=page_height_simple, width=page_width) - for (i in seq(1,n_genes,rows_per_page)) { - start=i - end=i+rows_per_page-1 - if (end>n_genes) {end=n_genes} - plot.list=lapply(per_gene_size[start:end], function(x) plot_size_distribution(x, par.settings=par.settings.size) ) - args.list=c(plot.list, list(nrow=rows_per_page, ncol=1, - main=textGrob("Size distributions (in nucleotides)", gp=gpar(cex=1), just="top"), - left=textGrob("${ylabel}", gp=gpar(cex=1), vjust=1, rot=90) - #sub="readsize in nucleotides" - ) - ) - do.call(grid.arrange, args.list) - } - devname=dev.off() + } - pdf(file="${combi_PDF}", paper="special", height=page_height_combi, width=page_width) - for (i in seq(1,n_genes,rows_per_page/2)) { - start=i - end=i+rows_per_page/2-1 - if (end>n_genes) {end=n_genes} - read_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, par.settings=par.settings.combination.readmap)) - size_plot.list=lapply(per_gene_size[start:end], function(x) plot_size_distribution(x, strip=FALSE, par.settings=par.settings.combination.size)) - plot.list=rbind(read_plot.list, size_plot.list ) - args.list=c(plot.list, list(nrow=rows_per_page + extrarow, ncol=1, - main=textGrob("${title}", gp=gpar(cex=1), just="top"), - left=textGrob("${ylabel}", gp=gpar(cex=1), vjust=1, rot=90), - sub=textGrob("${xlabel}", gp=gpar(cex=1), just="bottom") - ) - ) - do.call(grid.arrange, args.list) + pdf(file="${readmap_PDF}", paper="special", height=page_height_simple, width=page_width) + for (i in seq(1,n_genes,rows_per_page)) { + start=i + end=i+rows_per_page-1 + if (end>n_genes) {end=n_genes} + if ("${yrange}" != 0) { + readmap_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, par.settings=par.settings.readmap)) + } else { + readmap_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, ylim=c(-"{$yrange}", "{$yrange}"), par.settings=par.settings.readmap)) } - devname=dev.off() + args.list=c(readmap_plot.list, list(nrow=rows_per_page, ncol=1, + main=textGrob("Read Maps (nucleotide coordinates)", gp=gpar(cex=1), just="top"), + left=textGrob("${ylabel}", gp=gpar(cex=1), vjust=1, rot=90) + #sub=textGrob("readmap coordinates", gp=gpar(cex=.75), just="bottom") + ) + ) + do.call(grid.arrange, args.list) + } + devname=dev.off() - + pdf(file="${size_PDF}", paper="special", height=page_height_simple, width=page_width) + for (i in seq(1,n_genes,rows_per_page)) { + start=i + end=i+rows_per_page-1 + if (end>n_genes) {end=n_genes} + plot.list=lapply(per_gene_size[start:end], function(x) plot_size_distribution(x, par.settings=par.settings.size) ) + args.list=c(plot.list, list(nrow=rows_per_page, ncol=1, + main=textGrob("Size distributions (in nucleotides)", gp=gpar(cex=1), just="top"), + left=textGrob("${ylabel}", gp=gpar(cex=1), vjust=1, rot=90) + #sub="readsize in nucleotides" + ) + ) + do.call(grid.arrange, args.list) + } + devname=dev.off() + + pdf(file="${combi_PDF}", paper="special", height=page_height_combi, width=page_width) + for (i in seq(1,n_genes,rows_per_page/2)) { + start=i + end=i+rows_per_page/2-1 + if (end>n_genes) {end=n_genes} + read_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, par.settings=par.settings.combination.readmap)) + size_plot.list=lapply(per_gene_size[start:end], function(x) plot_size_distribution(x, strip=FALSE, par.settings=par.settings.combination.size)) + plot.list=rbind(read_plot.list, size_plot.list ) + args.list=c(plot.list, list(nrow=rows_per_page + extrarow, ncol=1, + main=textGrob("${title}", gp=gpar(cex=1), just="top"), + left=textGrob("${ylabel}", gp=gpar(cex=1), vjust=1, rot=90), + sub=textGrob("${xlabel}", gp=gpar(cex=1), just="bottom") + ) + ) + do.call(grid.arrange, args.list) + } + devname=dev.off() + + ]]>