# HG changeset patch # User mvdbeek # Date 1403617791 14400 # Node ID 2025f1b016be2a48f0251e44f9a32df3d3362cee # Parent 5dd9f42f72dbbc08e29c2505f5f208354c658221 Uploaded diff -r 5dd9f42f72db -r 2025f1b016be mississippi_gcc/readmap.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mississippi_gcc/readmap.xml Tue Jun 24 09:49:51 2014 -0400 @@ -0,0 +1,225 @@ + + from sRbowtie aligment + bowtie-inspect + + + readmap.py + #if $refGenomeSource.genomeSource == "history": + --reference_fasta ## sys.argv[2] + $refGenomeSource.ownFile ## index source + #else: + #silent reference= filter( lambda x: str( x[0] ) == str( $refGenomeSource.series[0].input.dbkey ), $__app__.tool_data_tables[ 'bowtie_indexes' ].get_fields() )[0][-1] + --reference_bowtie_index + $reference + #end if + --rcode + $plotCode + --output_readmap + $readmap_dataframe + --output_size_distribution + $size_distribution_dataframe + --minquery + $minquery + --maxquery + $maxquery + --input + #for $i in $refGenomeSource.series + $i.input + #end for + --ext + #for $i in $refGenomeSource.series + $i.input.ext + #end for + --label + #for $i in $refGenomeSource.series + "$i.input.name" + #end for + --normalization_factor + #for $i in $refGenomeSource.series + $i.norm + #end for + #if $gff: + --gff + $gff + #end if + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ## Setup R error handling to go to stderr + options( show.error.messages=F, + error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) + library(RColorBrewer) + library(lattice) + library(latticeExtra) + library(grid) + library(gridExtra) + ##cheetahtemplate data frame implementation + + rm=read.delim("${readmap_dataframe}", header=T, row.names=NULL) + pdf(file="${readmap_PDF}", paper="special", height=11.69, width=8.2677) + n_samples=length(unique(rm\$sample)) + + genes=unique(levels(rm\$gene)) + per_gene_readmap=lapply(genes, function(x) subset(rm, gene==x)) + n_genes=length(per_gene_readmap) + + + par.settings.readmap=list(layout.heights=list(top.padding=0, bottom.padding=-3), fontsize = list(text=96/${rows_per_page}, points=8)) + par.settings.size=list(layout.heights=list(top.padding=-1, bottom.padding=-3), fontsize = list(text=96/${rows_per_page}, points=8)) + par.settings.combination.readmap=list(layout.heights=list(top.padding=0, bottom.padding=-3), fontsize = list(text=96/${rows_per_page}, points=8)) + par.settings.combination.size=list(layout.heights=list(top.padding=-2, bottom.padding=-0.5), fontsize = list(text=96/${rows_per_page}, points=8)) + + + plot_readmap=function(df, ...) { + combineLimits(xyplot(count~coord|factor(sample, levels=unique(sample))+reorder(gene, count, function(x) -sum(abs(x))), + data=df, + type='h', + scales= list(relation="free", x=list(rot=0, cex=0.75, axs="i", tck=0.5), y=list(tick.number=4, rot=90, cex=0.75)), + xlab=NULL, main=NULL, ylab=NULL, + as.table=T, + origin = 0, + horizontal=FALSE, + group=polarity, + col=c("red","blue"), + ...)) + } + + 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.75), + prepanel=smR.prepanel, + xlab = NULL, + ylab = NULL, +# par.settings=list(layout.heights=list(top.padding=-2, bottom.padding=-3), fontsize = list(text=8, points=8)), + main = NULL , as.table=TRUE, newpage = T, ...) + combineLimits(bc) + } + + 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="${title}", left="${ylabel}", sub="readmap coordinate")) + do.call(grid.arrange, args.list) + } + + devname=dev.off() + + size=read.delim("${size_distribution_dataframe}", header=T, row.names=NULL) + per_gene_size=lapply(genes, function(x) subset(size, gene==x)) + + pdf(file="${size_PDF}", paper="special", height=11.69, width=8.2677) + + 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="${title}", left="${ylabel}", sub="readsize in nucleotides")) + do.call(grid.arrange, args.list) + } + + devname=dev.off() + + pdf(file="${combi_PDF}", paper="special", height=11.69, width=8.2677) + + 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}, ncol=1, main="${title}", left="${ylabel}", sub="${xlabel}")) + do.call(grid.arrange, args.list) + } + + devname=dev.off() + + + + + + + + + + + + + + +**What it does** + +Takes one or more alignment files (BAM, SAM or tabular bowtie output) as input and produces a "Readmap", +where by default for each "chromosome" the position of the read is recorded on the x-axis, and the y-axis indicates +the number of reads per position. Reads that map in sense are on the top, reads that map antisense are on the bottom. + + +.. class:: warningmark + +'''TIP''' The input data can be produced using the sRbowtie tool. + +---- + +'''Example''' + +Query sequence:: +For a SAM file as the following: + + 5 16 2L_79 24393 255 17M * 0 0 CCTTCATCTTTTTTTTT IIIIIIIIIIIIIIIII XA:i:0 MD:Z:17 NM:i:0 + + 11 0 2R_1 12675 255 21M * 0 0 AAAAAAAACGCGTCCTTGTGC IIIIIIIIIIIIIIIIIIIII XA:i:0 MD:Z:21 NM:i:0 + + 2 16 2L_5 669 255 23M * 0 0 TGTTGCTGCATTTCTTTTTTTTT IIIIIIIIIIIIIIIIIIIIIII XA:i:0 MD:Z:23 NM:i:0 + +produce a plot like this: + +---- + +.. image:: static/images/readmap.png + :height: 800 + :width: 500 + + +