Mercurial > repos > drosofff > msp_sr_size_histograms
annotate size_histogram.xml @ 4:f0b489448615 draft
planemo upload for repository https://bitbucket.org/drosofff/gedtools/
author | drosofff |
---|---|
date | Mon, 29 Jun 2015 05:56:53 -0400 |
parents | afe1e306e2a8 |
children | 27c1327f5687 |
rev | line source |
---|---|
3
afe1e306e2a8
planemo upload for repository https://bitbucket.org/drosofff/gedtools/
mvdbeek
parents:
2
diff
changeset
|
1 <tool id="Size_histogram" name="Generate size histograms from alignment files" version="0.9.6"> |
0 | 2 <description>from sRbowtie aligment</description> |
3 <requirements> | |
4 <requirement type="package" version="0.12.7">bowtie</requirement> | |
5 <requirement type="package" version="0.7.7">pysam</requirement> | |
6 <requirement type="package" version="2.14">biocbasics</requirement> | |
1 | 7 <requirement type="package" version="1.9">numpy</requirement> |
0 | 8 </requirements> |
9 <command interpreter="python"> | |
10 size_histogram.py | |
11 #if $refGenomeSource.genomeSource == "history": | |
12 --reference_fasta ## sys.argv[2] | |
13 $refGenomeSource.ownFile ## index source | |
14 #else: | |
15 #silent reference= filter( lambda x: str( x[0] ) == str( $refGenomeSource.series[0].input.dbkey ), $__app__.tool_data_tables[ 'bowtie_indexes' ].get_fields() )[0][-1] | |
16 --reference_bowtie_index | |
17 $reference | |
18 #end if | |
19 --rcode | |
20 $plotCode | |
21 --output_size_distribution | |
22 $size_distribution_dataframe | |
23 --minquery | |
24 $minquery | |
25 --maxquery | |
26 $maxquery | |
27 --input | |
28 #for $i in $refGenomeSource.series | |
29 $i.input | |
30 #end for | |
31 --ext | |
32 #for $i in $refGenomeSource.series | |
33 $i.input.ext | |
34 #end for | |
35 --label | |
36 #for $i in $refGenomeSource.series | |
37 "$i.input.name" | |
38 #end for | |
39 --normalization_factor | |
40 #for $i in $refGenomeSource.series | |
41 $i.norm | |
42 #end for | |
43 #if $gff: | |
44 --gff | |
45 $gff | |
46 #end if | |
47 #if $global.value == 'yes': | |
48 --global_size | |
49 #end if | |
50 #if $collapsestrands.value == 'yes': | |
51 --collapse | |
52 #end if | |
53 | |
54 </command> | |
55 <inputs> | |
56 <conditional name="refGenomeSource"> | |
57 <param name="genomeSource" type="select" label="Will you select a reference genome from your history or use a built-in index?" help="Built-ins were indexed using default options"> | |
58 <option value="indexed">Use a built-in index</option> | |
59 <option value="history">Use one from the history</option> | |
60 </param> | |
61 <when value="indexed"> | |
62 <repeat name="series" title="Add alignment files"> | |
4
f0b489448615
planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
3
diff
changeset
|
63 <param name="input" type="data" label="Select multiple alignments to parse" format="tabular,sam,bam"> |
0 | 64 <validator type="dataset_metadata_in_data_table" table_name="bowtie_indexes" metadata_name="dbkey" metadata_column="0" message="database not set for this bowtie output. Select the database(=genome used for matching) manually, or select a reference fasta from your history."/> |
65 </param> | |
66 <param name="norm" type="float" value="1" label="Indicate a normalization factor to compare multiple aligments"/> | |
67 </repeat> | |
68 </when> | |
69 <when value="history"> | |
70 <param name="ownFile" type="data" format="fasta" label="Select a fasta file, to serve as index reference" /> | |
71 <repeat name="series" title="Add alignment files"> | |
4
f0b489448615
planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
3
diff
changeset
|
72 <param name="input" type="data" label="Select multiple alignments to parse" format="tabular,sam,bam"/> |
0 | 73 <param name="norm" type="float" value="1" label="Indicate a normalization factor to compare multiple aligments"/> |
74 </repeat> | |
75 </when> | |
76 </conditional> | |
4
f0b489448615
planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
3
diff
changeset
|
77 <param name="gff" type="data" format="gff,gff3" optional="true" label="Optional: select a GFF to investigate regions of interest" help="GFF must match genome build"/> |
0 | 78 <!-- <validator type="dataset_metadata_in_data_table" table_name="bowtie_indexes" metadata_name="dbkey" metadata_column="0" message="GFF database and alignment file databse do not match!"/> --> |
79 <param name="global" type="select" label="Generate size distribution for each item, or generate a global alignment"> | |
80 <option value="no">for each item</option> | |
81 <option value="yes">global</option> | |
82 </param> | |
83 <param name="collapsestrands" type="select" label="Whether + and - reads should be collapsed or not"> | |
84 <option value="no">Do not collapse</option> | |
85 <option value="yes">Collapse + and - reads</option> | |
86 </param> | |
87 <param name="minquery" type="integer" size="3" value="18" label="Min size of reads to plot" help="'15' = 15 nucleotides"/> | |
88 <param name="maxquery" type="integer" size="3" value="28" label="Max size of reads to plot" help="'30' = 30 nucleotides"/> | |
89 <param name="title" type="text" size="15" value="Size distribution" label="Main Titles"/> | |
90 <param name="xlabel" type="text" size="15" value="Size in nucleotides" label="x axis label"/> | |
91 <param name="ylabel" type="text" size="15" value="Number of reads" label="y axis label"/> | |
92 <param name="rows_per_page" type="text" size="9" value="8" label="How many items to display per page?"> | |
93 <validator type="in_range" min="6" max="20" message="Select between 6 and 20 rows, as the readability will suffer otherwise."/> | |
94 </param> | |
95 </inputs> | |
96 <configfiles> | |
97 <configfile name="plotCode"> | |
98 ## Setup R error handling to go to stderr | |
99 options( show.error.messages=F, | |
100 error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) | |
101 library(RColorBrewer) | |
102 library(lattice) | |
103 library(latticeExtra) | |
104 library(grid) | |
105 library(gridExtra) | |
106 | |
107 ##cheetahtemplate data frame implementation | |
108 size=read.delim("${size_distribution_dataframe}", header=T, row.names=NULL) | |
109 n_samples = length(unique (size\$sample)) | |
110 n_genes = length (unique (levels(size\$gene))) | |
111 | |
112 par.settings.size=list(layout.heights=list(top.padding=1, bottom.padding=1), | |
113 strip.background = list(col = c("lightblue", "lightgreen")) | |
114 ) | |
115 | |
116 smR.prepanel=function(x,y,...){; yscale=c(-max(abs(y)), max(abs(y)));list(ylim=yscale);} # use if one want y axis in the middle of the plot | |
117 | |
118 plot_size_distribution= function(df, ...) { | |
119 bc= barchart(count~as.factor(size)|factor(sample, levels=unique(sample))+gene, data = df, origin = 0, | |
120 horizontal=FALSE, | |
121 group=polarity, | |
122 stack=TRUE, | |
123 col=c('red', 'blue'), | |
124 cex=0.75, | |
125 scales=list(y=list(tick.number=4, rot=90, relation="free", cex=0.5, alternating=T), x=list(cex=.6 ) ), | |
126 xlab = "readsize in nucleotides", | |
127 ylab = "${ylabel}", | |
128 main="${title}" , | |
129 par.strip.text = list(cex=0.75), | |
130 as.table=TRUE, | |
131 newpage = T, | |
132 ...) | |
133 | |
134 combineLimits(update(useOuterStrips(bc, | |
135 strip.left = strip.custom(par.strip.text = list(cex=0.5)) | |
136 ), | |
137 layout=c(n_samples,${rows_per_page})), | |
138 margin.x=F, margin.y=1) | |
139 } | |
140 | |
141 # per_gene_size=lapply(genes, function(x) subset(size, gene==x)) # no object in this script | |
142 | |
143 global = "no" | |
144 #if $global.value == 'yes': | |
145 global = "yes" | |
146 #end if | |
147 | |
148 if (global=="no") { | |
149 | |
150 options(warn=-1) | |
151 pdf(file="${size_PDF}", paper="special", height=11.69, width=8.2677*n_samples/4) | |
152 plot_size_distribution(size, par.settings=par.settings.size) # removed , prepanel=smR.prepanel | |
153 | |
154 } else { | |
155 | |
156 pdf(file="${size_PDF}", paper="special", height=11.69, width=8.2677) | |
157 bc= barchart(count~as.factor(size)|factor(sample, levels=unique(sample)), data = size, origin = 0, | |
158 horizontal=FALSE, | |
159 group=polarity, | |
160 stack=TRUE, | |
161 col=c('red', 'blue'), | |
162 # par.settings=list(fontsize = list(text=8, points=8)), | |
163 scales=list(y=list(tick.number=4, rot=90, relation="same"), cex=1), | |
164 xlab = "readsize in nucleotides", | |
165 ylab = "${ylabel}", | |
166 main="${title}" , as.table=TRUE, newpage = T, | |
167 aspect=0.5, | |
168 strip = strip.custom(par.strip.text = list(cex = 1), which.given=1, bg="lightblue") | |
169 ) | |
170 bc | |
171 } | |
172 devname=dev.off() | |
173 | |
174 </configfile> | |
175 </configfiles> | |
176 | |
177 <outputs> | |
178 <data format="tabular" name="size_distribution_dataframe" label="Size_distribution_dataframe.tab"/> | |
179 <data format="pdf" name="size_PDF" label="Size_distribution.pdf"/> | |
180 </outputs> | |
181 <help> | |
182 | |
183 **What it does** | |
184 | |
185 Takes one or more alignment files (BAM, SAM or tabular bowtie output) as input and produces a histogram of read sizes, | |
186 where by default for each "chromosome" a histogram of read sizes is drawn. | |
187 Reads that map in sense are on the top (red), reads that map antisense are on the bottom (blue). | |
188 | |
189 | |
190 .. class:: warningmark | |
191 | |
192 '''TIP''' The input data can be produced using the sRbowtie tool. | |
193 | |
194 ---- | |
195 | |
196 '''Example''' | |
197 | |
198 Query sequence:: | |
199 For a SAM file as the following: | |
200 | |
201 5 16 2L_79 24393 255 17M * 0 0 CCTTCATCTTTTTTTTT IIIIIIIIIIIIIIIII XA:i:0 MD:Z:17 NM:i:0 | |
202 | |
203 11 0 2R_1 12675 255 21M * 0 0 AAAAAAAACGCGTCCTTGTGC IIIIIIIIIIIIIIIIIIIII XA:i:0 MD:Z:21 NM:i:0 | |
204 | |
205 2 16 2L_5 669 255 23M * 0 0 TGTTGCTGCATTTCTTTTTTTTT IIIIIIIIIIIIIIIIIIIIIII XA:i:0 MD:Z:23 NM:i:0 | |
206 | |
207 produce a plot like this: | |
208 | |
209 ---- | |
210 | |
211 .. image:: static/images/size_histogram.png | |
212 :height: 800 | |
213 :width: 500 | |
214 | |
215 </help> | |
1 | 216 <tests> |
0 | 217 <test> |
218 <param name="genomeSource" value="history" /> | |
1 | 219 <param name="ownFile" value="transposons.fasta" ftype="fasta" /> |
220 <param name="series_0|input" value="sample1.srbowtie_out" ftype="tabular"/> | |
221 <param name="series_0|norm" value="1" /> | |
222 <param name="series_1|input" value="sample2.srbowtie_out" ftype="tabular"/> | |
223 <param name="series_1|norm" value="1" /> | |
224 <param name="series_2|input" value="sample3.srbowtie_out" ftype="tabular"/> | |
225 <param name="series_2|norm" value="1" /> | |
0 | 226 <param name="global" value="no" /> |
227 <param name="collapsestrands" value="no" /> | |
228 <param name="minquery" value="18"/> | |
229 <param name="maxquery" value="30"/> | |
230 <param name="title" value="Size distribution"/> | |
231 <param name="xlabel" value="Size in nucleotides"/> | |
232 <param name="ylabel" value="Number of reads"/> | |
233 <param name="rows_per_page" value="10"/> | |
1 | 234 <output name="size_distribution_dataframe" ftype="tabular" file="Size_distribution_dataframe.tab" /> |
235 <output name="size_PDF" ftype="pdf" file="Size_distribution.pdf" /> | |
0 | 236 </test> |
1 | 237 </tests> |
0 | 238 </tool> |
239 |