|
1
|
1 <tool id="htseq_count" name="htseq-count" version="EBA2016-v1">
|
|
0
|
2 <description> - Count aligned reads in a BAM file that overlap features in a GFF file</description>
|
|
|
3 <requirements>
|
|
|
4 <requirement type="package" version="0.6.1">htseq</requirement>
|
|
|
5 <requirement type="package" version="1.7.1">numpy</requirement>
|
|
|
6 <requirement type="package" version="0.1.19">samtools</requirement>
|
|
|
7 <requirement type="package" version="0.7.7">pysam</requirement>
|
|
|
8 </requirements>
|
|
|
9
|
|
|
10 <stdio>
|
|
|
11 <exit_code range="1:" level="fatal" description="Unknown error occurred" />
|
|
|
12 <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" />
|
|
|
13 <regex match="samtools: (command ){0,1}not found" source="stderr" level="fatal" description="The samtools package is not properly installed, contact Galaxy administrators" />
|
|
|
14 <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'" />
|
|
|
15 <regex match="Error occured in line (\d+) of file" source="stderr" level="fatal" description="Unknown error parsing the GFF file" />
|
|
|
16 <regex match="Error" source="stderr" level="fatal" description="Unknown error occured" />
|
|
|
17 <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." />
|
|
|
18 </stdio>
|
|
|
19
|
|
|
20 <version_command>htseq-count -h | grep version | sed 's/^\(.*\)*\(version .*\)\./\2/'</version_command>
|
|
|
21
|
|
|
22 <command><![CDATA[
|
|
|
23 ##set up input files
|
|
|
24 #set $reference_fasta_filename = "localref.fa"
|
|
|
25 #if $samout_conditional.samout:
|
|
|
26 #if str( $samout_conditional.reference_source.reference_source_selector ) == "history":
|
|
|
27 ln -s "${samout_conditional.reference_source.ref_file}" "${reference_fasta_filename}" &&
|
|
|
28 samtools faidx "${reference_fasta_filename}" 2>&1 || echo "Error running samtools faidx for htseq-count" >&2 &&
|
|
|
29 #else:
|
|
|
30 #set $reference_fasta_filename = str( $samout_conditional.reference_source.ref_file.fields.path )
|
|
|
31 #end if
|
|
|
32 #end if
|
|
|
33 #if $force_sort:
|
|
|
34 #if $samfile.extension == 'bam':
|
|
|
35 samtools sort -n "$samfile" "name_sorted_alignment" &&
|
|
|
36 #else
|
|
|
37 samtools view -Su -t ${reference_fasta_filename}.fai "$samfile" | samtools sort -n - "name_sorted_alignment" &&
|
|
|
38 #end if
|
|
|
39 #end if
|
|
|
40 htseq-count
|
|
|
41 --mode=$mode
|
|
|
42 --stranded=$stranded
|
|
|
43 --minaqual=$minaqual
|
|
|
44 --type="$featuretype"
|
|
|
45 --idattr="$idattr"
|
|
|
46 #if $samout_conditional.samout:
|
|
|
47 --samout=$__new_file_path__/${samoutfile.id}_tmp
|
|
|
48 #end if
|
|
|
49 #if $force_sort:
|
|
|
50 --order=name
|
|
|
51 --format=bam
|
|
|
52 name_sorted_alignment.bam
|
|
|
53 #else
|
|
|
54 --order=pos
|
|
|
55 --format=$samfile.extension
|
|
|
56 $samfile
|
|
|
57 #end if
|
|
|
58 "$gfffile"
|
|
|
59 | 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
|
|
|
60 #if $samout_conditional.samout:
|
|
|
61 && samtools view -Su -t ${reference_fasta_filename}.fai $__new_file_path__/${samoutfile.id}_tmp | samtools sort -o - sorted > $samoutfile
|
|
|
62 #end if
|
|
|
63 ]]>
|
|
|
64 </command>
|
|
|
65
|
|
|
66 <inputs>
|
|
|
67 <param format="sam,bam" name="samfile" type="data" label="Aligned SAM/BAM File"/>
|
|
|
68 <param format="gff" name="gfffile" type="data" label="GFF File"/>
|
|
|
69 <param name="mode" type="select" label="Mode" help="(--mode)">
|
|
|
70 <help>Mode to handle reads overlapping more than one feature.</help>
|
|
|
71 <option value="union" selected="true">Union</option>
|
|
|
72 <option value="intersection-strict">Intersection (strict)</option>
|
|
|
73 <option value="intersection-nonempty">Intersection (nonempty)</option>
|
|
|
74 </param>
|
|
|
75 <param name="stranded" type="select" label="Stranded" help="dUTP, NSR, and NNSR (e.g.: Illumina TruSeq Stranded mRNA Library Prep) are reverse if mapping was done using fr-firstrand library type. SOLID or ligation (e.g.: Epicentre ScriptSeq) are Yes if mapping was done using fr-secondstrand library type (--stranded)">
|
|
|
76 <help>Specify whether the data is from a strand-specific assay. 'Reverse' means yes with reversed strand interpretation.dUTP, NSR, and NNSR (e.g.: Illumina TruSeq Stranded mRNA Library Prep) are reverse if mapping was done using fr-firstrand library type. SOLID or ligation (e.g.: Epicentre ScriptSeq) are Yes if mapping was done using fr-secondstrand library type.</help>
|
|
|
77 <option value="yes" selected="true">Yes</option>
|
|
|
78 <option value="no">No</option>
|
|
|
79 <option value="reverse">Reverse</option>
|
|
|
80 </param>
|
|
|
81 <param name="minaqual" type="integer" value="10" label="Minimum alignment quality">
|
|
|
82 <help>Skip all reads with alignment quality lower than the given minimum value. (-minaqual)</help>
|
|
|
83 </param>
|
|
|
84 <param name="featuretype" type="text" value="exon" label="Feature type">
|
|
|
85 <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. (--type)</help>
|
|
|
86 </param>
|
|
|
87 <param name="idattr" type="text" value="gene_id" label="ID Attribute">
|
|
|
88 <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>
|
|
|
89 </param>
|
|
|
90 <conditional name="samout_conditional">
|
|
|
91 <param name="samout" type="boolean" value="False" truevalue="True" falsevalue="False" label="Additional BAM Output">
|
|
|
92 <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>
|
|
|
93 </param>
|
|
|
94 <when value="True">
|
|
|
95 <conditional name="reference_source">
|
|
|
96 <param name="reference_source_selector" type="select" label="Choose the source for the reference list">
|
|
|
97 <option value="cached">Locally cached</option>
|
|
|
98 <option value="history">History</option>
|
|
|
99 </param>
|
|
|
100 <when value="cached">
|
|
|
101 <param name="ref_file" type="select" label="Using reference genome">
|
|
|
102 <options from_data_table="sam_fa_indexes">
|
|
|
103 <filter type="data_meta" key="dbkey" ref="samfile" column="1"/>
|
|
|
104 </options>
|
|
|
105 <validator type="no_options" message="A built-in reference genome is not available for the build associated with the selected input file"/>
|
|
|
106 </param>
|
|
|
107 </when>
|
|
|
108 <when value="history"> <!-- FIX ME!!!! -->
|
|
|
109 <param name="ref_file" type="data" format="fasta" label="Using reference file" />
|
|
|
110 </when>
|
|
|
111 </conditional>
|
|
|
112 </when>
|
|
|
113 </conditional>
|
|
|
114 <param name="force_sort" type="boolean" value="False" truevalue="True" falsevalue="False" label="Force sorting of SAM/BAM file by NAME">
|
|
|
115 <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>
|
|
|
116 </param>
|
|
|
117 </inputs>
|
|
|
118
|
|
|
119 <outputs>
|
|
|
120 <data format="tabular" name="counts" metadata_source="samfile" label="${tool.name} on ${on_string}"/>
|
|
|
121 <data format="tabular" name="othercounts" metadata_source="samfile" label="${tool.name} on ${on_string} (no feature)"/>
|
|
|
122 <data format="bam" name="samoutfile" metadata_source="samfile" label="${tool.name} on ${on_string} (BAM)">
|
|
|
123 <filter>samout_conditional['samout']</filter>
|
|
|
124 </data>
|
|
|
125 </outputs>
|
|
|
126
|
|
|
127 <tests>
|
|
|
128 <test>
|
|
|
129 <param name="samfile" value="htseq-test.sam" />
|
|
|
130 <param name="gfffile" value="htseq-test.gff" />
|
|
|
131 <param name="samout" value="False" />
|
|
|
132 <output name="counts" file="htseq-test_counts.tsv" />
|
|
|
133 <output name="othercounts" file="htseq-test_othercounts.tsv" />
|
|
|
134 </test>
|
|
|
135 <test>
|
|
|
136 <param name="samfile" value="htseq-test.sam" />
|
|
|
137 <param name="gfffile" value="htseq-test.gff" />
|
|
|
138 <param name="samout" value="False" />
|
|
|
139 <param name="force_sort" value="True" />
|
|
|
140 <output name="counts" file="htseq-test_counts.tsv" />
|
|
|
141 <output name="othercounts" file="htseq-test_othercounts.tsv" />
|
|
|
142 </test>
|
|
|
143 <test>
|
|
|
144 <param name="samfile" value="htseq-test.bam" />
|
|
|
145 <param name="gfffile" value="htseq-test.gff" />
|
|
|
146 <param name="samout" value="False" />
|
|
|
147 <output name="counts" file="htseq-test_counts.tsv" />
|
|
|
148 <output name="othercounts" file="htseq-test_othercounts.tsv" />
|
|
|
149 </test>
|
|
|
150 <test>
|
|
|
151 <param name="samfile" value="htseq-test-paired.bam" />
|
|
|
152 <param name="singlepaired" value="paired" />
|
|
|
153 <param name="gfffile" value="htseq-test.gff" />
|
|
|
154 <param name="samout" value="False" />
|
|
|
155 <output name="counts" file="htseq-test-paired_counts.tsv" />
|
|
|
156 <output name="othercounts" file="htseq-test-paired_othercounts.tsv" />
|
|
|
157 </test>
|
|
|
158 <test>
|
|
|
159 <param name="samfile" value="htseq-test-paired.bam" />
|
|
|
160 <param name="singlepaired" value="paired" />
|
|
|
161 <param name="gfffile" value="htseq-test.gff" />
|
|
|
162 <param name="samout" value="False" />
|
|
|
163 <param name="force_sort" value="True" />
|
|
|
164 <output name="counts" file="htseq-test-paired_counts.tsv" />
|
|
|
165 <output name="othercounts" file="htseq-test-paired_othercounts.tsv" />
|
|
|
166 </test>
|
|
|
167
|
|
|
168 <!-- Seems to be an issue setting the $reference_fasta_filename variable during test
|
|
|
169 <test>
|
|
|
170 <param name="samfile" value="htseq-test.sam" />
|
|
|
171 <param name="gfffile" value="htseq-test.gff" />
|
|
|
172 <param name="samout" value="True" />
|
|
|
173 <param name="reference_source_selector" value="history" />
|
|
|
174 <param name="ref_file" value="htseq-test_reference.fasta" />
|
|
|
175 <output name="counts" file="htseq-test_counts.tsv" />
|
|
|
176 <output name="othercounts" file="htseq-test_othercounts.tsv" />
|
|
|
177 <output name="samoutfile" file="htseq-test_samout.bam" />
|
|
|
178 </test>
|
|
|
179 -->
|
|
|
180 </tests>
|
|
|
181
|
|
|
182 <help>
|
|
|
183 <![CDATA[
|
|
|
184 Overview
|
|
|
185 --------
|
|
|
186
|
|
|
187 This tool takes an alignment file in SAM or BAM format and feature file in GFF format
|
|
|
188 and calculates the number of reads mapping to each feature. It uses the *htseq-count*
|
|
|
189 script that is part of the HTSeq python module. See
|
|
|
190 http://www-huber.embl.de/users/anders/HTSeq/doc/count.html for details.
|
|
|
191
|
|
|
192 A feature is an interval (i.e., a range of positions) on a chromosome or a union of
|
|
|
193 such intervals. In the case of RNA-Seq, the features are typically genes, where
|
|
|
194 each gene is considered here as the union of all its exons. One may also consider
|
|
|
195 each exon as a feature, e.g., in order to check for alternative splicing. For
|
|
|
196 comparative ChIP-Seq, the features might be binding regions from a pre-determined
|
|
|
197 list.
|
|
|
198
|
|
|
199
|
|
|
200 Overlap Modes
|
|
|
201 -------------
|
|
|
202
|
|
|
203 Special care must be taken to decide how to deal with reads that overlap more than one feature.
|
|
|
204
|
|
|
205 The htseq-count script allows to choose between three modes: *union*, *intersection-strict*, and *intersection-nonempty*.
|
|
|
206
|
|
|
207 The following figure illustrates the effect of these three modes:
|
|
|
208
|
|
|
209 .. image:: count_modes.png
|
|
|
210
|
|
|
211
|
|
|
212 Strandedness
|
|
|
213 ------------
|
|
|
214
|
|
|
215 **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!
|
|
|
216
|
|
|
217
|
|
|
218 Output
|
|
|
219 ------
|
|
|
220
|
|
|
221 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
|
|
|
222
|
|
|
223 - *no_feature*: reads which could not be assigned to any feature (set S as described above was empty).
|
|
|
224
|
|
|
225 - *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).
|
|
|
226
|
|
|
227 - *too_low_aQual*: reads which were not counted due to the -a option, see below
|
|
|
228
|
|
|
229 - *not_aligned*: reads in the SAM file without alignment
|
|
|
230
|
|
|
231 - *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.)
|
|
|
232
|
|
|
233
|
|
|
234 Options Summary
|
|
|
235 ---------------
|
|
|
236
|
|
|
237 Usage: htseq-count [options] sam_file gff_file
|
|
|
238
|
|
|
239 This script takes an alignment file in SAM format and a feature file in GFF
|
|
|
240 format and calculates for each feature the number of reads mapping to it. See
|
|
|
241 http://www-huber.embl.de/users/anders/HTSeq/doc/count.html for details.
|
|
|
242
|
|
|
243 Options:
|
|
|
244 -h, --help show this help message and exit
|
|
|
245 -m MODE, --mode=MODE mode to handle reads overlapping more than one
|
|
|
246 feature(choices: union, intersection-strict,
|
|
|
247 intersection-nonempty; default: union)
|
|
|
248 -s STRANDED, --stranded=STRANDED
|
|
|
249 whether the data is from a strand-specific assay.
|
|
|
250 Specify 'yes', 'no', or 'reverse' (default: yes).
|
|
|
251 'reverse' means 'yes' with reversed strand
|
|
|
252 interpretation
|
|
|
253 -a MINAQUAL, --minaqual=MINAQUAL
|
|
|
254 skip all reads with alignment quality lower than the
|
|
|
255 given minimum value (default: 0)
|
|
|
256 -t FEATURETYPE, --type=FEATURETYPE
|
|
|
257 feature type (3rd column in GFF file) to be used, all
|
|
|
258 features of other type are ignored (default, suitable
|
|
|
259 for Ensembl GTF files: exon)
|
|
|
260 -i IDATTR, --idattr=IDATTR
|
|
|
261 GFF attribute to be used as feature ID (default,
|
|
|
262 suitable for Ensembl GTF files: gene_id)
|
|
|
263 -o SAMOUT, --samout=SAMOUT
|
|
|
264 write out all SAM alignment records into an output SAM
|
|
|
265 file called SAMOUT, annotating each line with its
|
|
|
266 feature assignment (as an optional field with tag
|
|
|
267 'XF')
|
|
|
268 -q, --quiet suppress progress report and warnings
|
|
|
269
|
|
|
270 Written by Simon Anders (sanders@fs.tum.de), European Molecular Biology
|
|
|
271 Laboratory (EMBL). (c) 2010. Released under the terms of the GNU General
|
|
|
272 Public License v3. Part of the 'HTSeq' framework.
|
|
|
273 ]]>
|
|
|
274 </help>
|
|
|
275
|
|
|
276 <citations>
|
|
|
277 <citation type="bibtex">
|
|
|
278 @article{anders_htseqpython_2015,
|
|
|
279 title = {{HTSeq}—a {Python} framework to work with high-throughput sequencing data},
|
|
|
280 volume = {31},
|
|
|
281 issn = {1367-4803, 1460-2059},
|
|
|
282 url = {http://bioinformatics.oxfordjournals.org/content/31/2/166},
|
|
|
283 doi = {10.1093/bioinformatics/btu638},
|
|
|
284 abstract = {Motivation: A large choice of tools exists for many standard tasks in the analysis of high-throughput sequencing (HTS) data. However, once a project deviates from standard workflows, custom scripts are needed.
|
|
|
285 Results: We present HTSeq, a Python library to facilitate the rapid development of such scripts. HTSeq offers parsers for many common data formats in HTS projects, as well as classes to represent data, such as genomic coordinates, sequences, sequencing reads, alignments, gene model information and variant calls, and provides data structures that allow for querying via genomic coordinates. We also present htseq-count, a tool developed with HTSeq that preprocesses RNA-Seq data for differential expression analysis by counting the overlap of reads with genes.
|
|
|
286 Availability and implementation: HTSeq is released as an open-source software under the GNU General Public Licence and available from http://www-huber.embl.de/HTSeq or from the Python Package Index at https://pypi.python.org/pypi/HTSeq.
|
|
|
287 Contact: sanders\{at\}fs.tum.de},
|
|
|
288 language = {en},
|
|
|
289 number = {2},
|
|
|
290 urldate = {2015-04-21},
|
|
|
291 journal = {Bioinformatics},
|
|
|
292 author = {Anders, Simon and Pyl, Paul Theodor and Huber, Wolfgang},
|
|
|
293 month = jan,
|
|
|
294 year = {2015},
|
|
|
295 pmid = {25260700},
|
|
|
296 pages = {166--169},
|
|
|
297 file = {Full Text PDF:/Users/lparsons/Library/Application Support/Firefox/Profiles/thd2t4je.default/zotero/storage/84XQB8V6/Anders et al. - 2015 - HTSeq—a Python framework to work with high-through.pdf:application/pdf;Snapshot:/Users/lparsons/Library/Application Support/Firefox/Profiles/thd2t4je.default/zotero/storage/JKUAUCKB/166.html:text/html}
|
|
|
298 }
|
|
|
299 </citation>
|
|
|
300 </citations>
|
|
|
301 </tool>
|