-
Notifications
You must be signed in to change notification settings - Fork 422
/
htseq-count.xml
290 lines (254 loc) · 15 KB
/
htseq-count.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<tool id="htseq_count" name="htseq-count" version="0.6.1galaxy3" profile="16.04">
<description> - Count aligned reads in a BAM file that overlap features in a GFF file</description>
<requirements>
<requirement type="package" version="0.6.1.post1">htseq</requirement>
<requirement type="package" version="1.3.1">samtools</requirement>
</requirements>
<stdio>
<exit_code range="1:" level="fatal" description="Unknown error occurred" />
<regex match="htseq-count: (command ){0,1}not found" source="stderr" level="fatal" description="The HTSeq python package is not properly installed, contact Galaxy administrators" />
<regex match="samtools: (command ){0,1}not found" source="stderr" level="fatal" description="The samtools package is not properly installed, contact Galaxy administrators" />
<regex match="Error: Feature (.+) does not contain a '(.+)' attribute" source="both" level="fatal" description="Error parsing the GFF file, at least one feature of the specified 'Feature type' does not have a value for the specified 'ID Attribute'" />
<regex match="Error occured in line (\d+) of file" source="stderr" level="fatal" description="Unknown error parsing the GFF file" />
<regex match="Error" source="stderr" level="fatal" description="Unknown error occured" />
<regex match="Warning: Read (.+) claims to have an aligned mate which could not be found. \(Is the SAM file properly sorted\?\)" source="stderr" level="warning" description="PAIRED DATA MISSING OR NOT PROPERLY SORTED. Try reruning and selecting the option to 'Force sorting of SAM/BAM file by NAME'. See stderr output of this dataset for more information." />
</stdio>
<version_command>htseq-count -h | grep version | sed 's/^\(.*\)*\(version .*\)\./\2/'</version_command>
<command><![CDATA[
##set up input files
#set $reference_fasta_filename = "localref.fa"
#if $samout_conditional.samout == "Yes":
#if str( $samout_conditional.reference_source.reference_source_selector ) == "history":
ln -s "${samout_conditional.reference_source.ref_file}" "${reference_fasta_filename}" &&
samtools faidx '${reference_fasta_filename}' 2>&1 || echo "Error running samtools faidx for htseq-count" >&2 &&
#else:
#set $reference_fasta_filename = str( $samout_conditional.reference_source.ref_file.fields.path )
#end if
#end if
#if $force_sort == "True":
#if $samfile.extension == 'bam':
samtools sort -n -o 'name_sorted_alignment.bam' '$samfile' &&
#else
samtools view -Su -t '${reference_fasta_filename}.fai' '$samfile' | samtools sort -n -o 'name_sorted_alignment.bam' - &&
#end if
#end if
htseq-count
--mode=$mode
--stranded=$stranded
--minaqual=$minaqual
--type='$featuretype'
--idattr='$idattr'
#if $samout_conditional.samout == "Yes":
--samout='$__new_file_path__/${samoutfile.id}_tmp'
#end if
#if $force_sort == "True":
--order=name
--format=bam
name_sorted_alignment.bam
#else
--order=pos
--format=$samfile.extension
'$samfile'
#end if
"$gfffile" | awk '{if ($1 ~ "no_feature|ambiguous|too_low_aQual|not_aligned|alignment_not_unique") print $0 | "cat 1>&2"; else print $0}'
> '$counts'
2> '$othercounts'
#if $samout_conditional.samout == "Yes":
&& samtools view -Su
-t '${reference_fasta_filename}.fai'
'$__new_file_path__/${samoutfile.id}_tmp'
| samtools sort -o '$samoutfile' -
#end if
]]>
</command>
<inputs>
<param format="sam,bam" name="samfile" type="data" label="Aligned SAM/BAM File"/>
<param format="gff" name="gfffile" type="data" label="GFF File"/>
<param name="mode" type="select" label="Mode" argument="(--mode)">
<help>Mode to handle reads overlapping more than one feature.</help>
<option value="union" selected="True">Union</option>
<option value="intersection-strict">Intersection (strict)</option>
<option value="intersection-nonempty">Intersection (nonempty)</option>
</param>
<param name="stranded" type="select" label="Stranded" argument="(--stranded)">
<help>Specify whether the data is from a strand-specific assay. 'Reverse' means yes with reversed strand interpretation.</help>
<option value="yes" selected="True">Yes</option>
<option value="no">No</option>
<option value="reverse">Reverse</option>
</param>
<param name="minaqual" type="integer" value="10" label="Minimum alignment quality" argument="--minaqual">
<help>Skip all reads with alignment quality lower than the given minimum value.</help>
</param>
<param name="featuretype" type="text" value="exon" label="Feature type" argument="--type">
<help>Feature type (3rd column in GFF file) to be used. All features of other types are ignored. The default, suitable for RNA-Seq and Ensembl GTF files, is exon.</help>
</param>
<param name="idattr" type="text" value="gene_id" label="ID Attribute" argument="--idattr">
<help>GFF attribute to be used as feature ID. Several GFF lines with the same feature ID will be considered as parts of the same feature. The feature ID is used to identity the counts in the output table. All features of the specified type MUST have a value for this attribute. The default, suitable for RNA-Seq and Ensembl GTF files, is gene_id.</help>
</param>
<conditional name="samout_conditional">
<param name="samout" type="select" label="Additional BAM Output">
<help>Write out all SAM alignment records into an output BAM file, annotating each line with its assignment to a feature or a special counter (as an optional field with tag ‘XF’).</help>
<option value="No" selected="True">Do not output additional BAM file</option>
<option value="Yes">Output additional BAM file</option>
</param>
<when value="Yes">
<conditional name="reference_source">
<param name="reference_source_selector" type="select" label="Choose the source for the reference list">
<option value="cached">Locally cached</option>
<option value="history">History</option>
</param>
<when value="cached">
<param name="ref_file" type="select" label="Using reference genome">
<options from_data_table="sam_fa_indexes">
<filter type="data_meta" key="dbkey" ref="samfile" column="1"/>
</options>
<validator type="no_options" message="A built-in reference genome is not available for the build associated with the selected input file"/>
</param>
</when>
<when value="history">
<param name="ref_file" type="data" format="fasta" label="Using reference file" />
</when>
</conditional>
</when>
<when value="No">
<!-- Do nothing -->
</when>
</conditional>
<param name="force_sort" type="boolean" value="False" truevalue="True" falsevalue="False" label="Force sorting of SAM/BAM file by NAME">
<help>This option can be used for for paired-end data that has many unmapped mates. Use this if you get the warning about paired end data missing or not being properly sorted.</help>
</param>
</inputs>
<outputs>
<data format="tabular" name="counts" metadata_source="samfile" label="${tool.name} on ${on_string}">
<actions>
<action name="column_names" type="metadata" default="Geneid,${samfile.name}" />
</actions>
</data>
<data format="tabular" name="othercounts" metadata_source="samfile" label="${tool.name} on ${on_string} (no feature)"/>
<data format="bam" name="samoutfile" metadata_source="samfile" label="${tool.name} on ${on_string} (BAM)">
<filter>samout_conditional['samout'] == "Yes"</filter>
</data>
</outputs>
<tests>
<test>
<param name="samfile" value="htseq-test.sam" />
<param name="gfffile" value="htseq-test.gff" />
<param name="samout" value="No" />
<output name="counts" file="htseq-test_counts.tsv" />
<output name="othercounts" file="htseq-test_othercounts.tsv" />
</test>
<test>
<param name="samfile" value="htseq-test.sam" />
<param name="gfffile" value="htseq-test.gff" />
<param name="samout" value="No" />
<param name="force_sort" value="True" />
<output name="counts" file="htseq-test_counts.tsv" />
<output name="othercounts" file="htseq-test_othercounts.tsv" />
</test>
<test>
<param name="samfile" value="htseq-test.bam" />
<param name="gfffile" value="htseq-test.gff" />
<param name="samout" value="No" />
<output name="counts" file="htseq-test_counts.tsv" />
<output name="othercounts" file="htseq-test_othercounts.tsv" />
</test>
<test>
<param name="samfile" value="htseq-test-paired.bam" />
<param name="singlepaired" value="paired" />
<param name="gfffile" value="htseq-test.gff" />
<param name="samout" value="No" />
<output name="counts" file="htseq-test-paired_counts.tsv" />
<output name="othercounts" file="htseq-test-paired_othercounts.tsv" />
</test>
<test>
<param name="samfile" value="htseq-test-paired.bam" />
<param name="singlepaired" value="paired" />
<param name="gfffile" value="htseq-test.gff" />
<param name="samout" value="No" />
<param name="force_sort" value="True" />
<output name="counts" file="htseq-test-paired_counts.tsv" />
<output name="othercounts" file="htseq-test-paired_othercounts.tsv" />
</test>
<test>
<param name="samfile" value="htseq-test.sam" />
<param name="gfffile" value="htseq-test.gff" />
<param name="samout" value="Yes" />
<param name="reference_source_selector" value="history" />
<param name="ref_file" value="htseq-test_reference.fasta" />
<output name="counts" file="htseq-test_counts.tsv" />
<output name="othercounts" file="htseq-test_othercounts.tsv" />
<output name="samoutfile" file="htseq-test_samout.bam" />
</test>
</tests>
<help>
<![CDATA[
Overview
--------
This tool takes an alignment file in SAM or BAM format and feature file in GFF format
and calculates the number of reads mapping to each feature. It uses the *htseq-count*
script that is part of the HTSeq python module. See
http://www-huber.embl.de/users/anders/HTSeq/doc/count.html for details.
A feature is an interval (i.e., a range of positions) on a chromosome or a union of
such intervals. In the case of RNA-Seq, the features are typically genes, where
each gene is considered here as the union of all its exons. One may also consider
each exon as a feature, e.g., in order to check for alternative splicing. For
comparative ChIP-Seq, the features might be binding regions from a pre-determined
list.
Overlap Modes
-------------
Special care must be taken to decide how to deal with reads that overlap more than one feature.
The htseq-count script allows to choose between three modes: *union*, *intersection-strict*, and *intersection-nonempty*.
The following figure illustrates the effect of these three modes:
.. image:: count_modes.png
Strandedness
------------
**Important**: The default for strandedness is yes. If your RNA-Seq data has not been made with a strand-specific protocol, this causes half of the reads to be lost. Hence, make sure to set the option Stranded to 'No' unless you have strand-specific data!
Output
------
The script outputs a table with counts for each feature, followed by the special counters, which count reads that were not counted for any feature for various reasons, namely
- *no_feature*: reads which could not be assigned to any feature (set S as described above was empty).
- *ambiguous*: reads which could have been assigned to more than one feature and hence were not counted for any of these (set S had mroe than one element).
- *too_low_aQual*: reads which were not counted due to the -a option, see below
- *not_aligned*: reads in the SAM file without alignment
- *alignment_not_unique*: reads with more than one reported alignment. These reads are recognized from the NH optional SAM field tag. (If the aligner does not set this field, multiply aligned reads will be counted multiple times.)
Options Summary
---------------
Usage: htseq-count [options] sam_file gff_file
This script takes an alignment file in SAM format and a feature file in GFF
format and calculates for each feature the number of reads mapping to it. See
http://www-huber.embl.de/users/anders/HTSeq/doc/count.html for details.
Options:
-h, --help show this help message and exit
-m MODE, --mode=MODE mode to handle reads overlapping more than one
feature(choices: union, intersection-strict,
intersection-nonempty; default: union)
-s STRANDED, --stranded=STRANDED
whether the data is from a strand-specific assay.
Specify 'yes', 'no', or 'reverse' (default: yes).
'reverse' means 'yes' with reversed strand
interpretation
-a MINAQUAL, --minaqual=MINAQUAL
skip all reads with alignment quality lower than the
given minimum value (default: 0)
-t FEATURETYPE, --type=FEATURETYPE
feature type (3rd column in GFF file) to be used, all
features of other type are ignored (default, suitable
for Ensembl GTF files: exon)
-i IDATTR, --idattr=IDATTR
GFF attribute to be used as feature ID (default,
suitable for Ensembl GTF files: gene_id)
-o SAMOUT, --samout=SAMOUT
write out all SAM alignment records into an output SAM
file called SAMOUT, annotating each line with its
feature assignment (as an optional field with tag
'XF')
-q, --quiet suppress progress report and warnings
Written by Simon Anders (sanders@fs.tum.de), European Molecular Biology
Laboratory (EMBL). (c) 2010. Released under the terms of the GNU General
Public License v3. Part of the 'HTSeq' framework.
]]>
</help>
<citations>
<citation type="doi">10.1093/bioinformatics/btu638</citation>
</citations>
</tool>