# HG changeset patch # User iuc # Date 1517861087 18000 # Node ID f1368427a79c9e54efacb458e78cd25096081edc # Parent 620d5603d1a871bab83090eba13be2311da249a1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/htseq_count commit 76065f751b678abf87e6c723be680fecaa8cb589 diff -r 620d5603d1a8 -r f1368427a79c README.rst --- a/README.rst Fri Jan 20 15:46:13 2017 -0500 +++ b/README.rst Mon Feb 05 15:04:47 2018 -0500 @@ -1,21 +1,19 @@ htseq-count wrapper for Galaxy ============================== -Galaxy wrapper for -`htseq-count `_ -script from python -`HTSeq `_ package. +Galaxy wrapper for `htseq-count `_ +script from the `HTSEQ `_ python package. Installation ------------ -Installation directly from the `Galaxy Toolshed `_ is -recommended. +Installation directly from the `Galaxy Toolshed `_ +is recommended. Galaxy Wrapper License ---------------------- -Copyright (c) 2012-2014, Lance R. Parsons +Copyright (c) 2012-2018, Lance R. Parsons All rights reserved. Licensed under the BSD 2-Clause License: diff -r 620d5603d1a8 -r f1368427a79c htseq-count.xml --- a/htseq-count.xml Fri Jan 20 15:46:13 2017 -0500 +++ b/htseq-count.xml Mon Feb 05 15:04:47 2018 -0500 @@ -1,8 +1,8 @@ - + - Count aligned reads in a BAM file that overlap features in a GFF file - htseq - samtools + htseq + samtools @@ -12,7 +12,6 @@ - htseq-count -h | grep version | sed 's/^\(.*\)*\(version .*\)\./\2/' @@ -20,21 +19,22 @@ &1 || echo "Error running samtools faidx for htseq-count" >&2 && - #else: - #set $reference_fasta_filename = str( $samout_conditional.reference_source.ref_file.fields.path ) + #set $name_sorted_alignment_filename = "name_sorted_alignment.sam" + #if str( $advanced_options.advanced_options_selector ) == "advanced": + #if str( $advanced_options.samout_conditional.samout ) == "Yes": + #if str( $advanced_options.samout_conditional.reference_source.reference_source_selector ) == "history": + ln -s "${advanced_options.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( $advanced_options.samout_conditional.reference_source.ref_file.fields.path ) + #end if #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 + #if $samfile.extension == 'bam': + samtools sort -n --output-fmt=SAM -o '$name_sorted_alignment_filename' '$samfile' && + #else + samtools view -Su -t '${reference_fasta_filename}.fai' '$samfile' | samtools sort -n --output-fmt=SAM -o '$name_sorted_alignment_filename' - && #end if htseq-count @@ -43,28 +43,31 @@ --minaqual=$minaqual --type='$featuretype' --idattr='$idattr' - #if $samout_conditional.samout == "Yes": - --samout='$__new_file_path__/${samoutfile.id}_tmp' + + #if str( $advanced_options.advanced_options_selector ) == "advanced": + --nonunique=$advanced_options.nonunique + --secondary-alignments=${advanced_options.secondary_alignments} + --supplementary-alignments=${advanced_options.supplementary_alignments} + #if $advanced_options.samout_conditional.samout == "Yes": + --samout='$__new_file_path__/${samoutfile.id}_tmp.sam' + #end if #end if - #if $force_sort == "True": - --order=name - --format=bam - name_sorted_alignment.bam - #else - --order=pos - --format=$samfile.extension - '$samfile' - #end if + + --order=name + --format=sam + '$name_sorted_alignment_filename' "$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' - + #if str( $advanced_options.advanced_options_selector ) == "advanced": + #if $advanced_options.samout_conditional.samout == "Yes": + && samtools view -Su + -t '${reference_fasta_filename}.fai' + '$__new_file_path__/${samoutfile.id}_tmp.sam' + | samtools sort -o '$samoutfile' - + #end if #end if ]]> @@ -72,14 +75,16 @@ - + Mode to handle reads overlapping more than one feature. - - Specify whether the data is from a strand-specific assay. 'Reverse' means yes with reversed strand interpretation. + + Specify whether the data is from a strand-specific assay. + **Be sure to choose the correct value** (see help for more + information). @@ -93,47 +98,65 @@ 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. - - - 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’). - - + + + + + - - - - - + + + + + + + + + + + + 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’). + + - - - - - - - + + + + + + + + + + + + + + + + + + - - + + - - - - - 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. - - + - + + + + + samout_conditional['samout'] == "Yes" @@ -143,45 +166,38 @@ - - - - - + + + + + + - - - - - - - - - + @@ -189,6 +205,16 @@ + + + + + + + + + + @@ -212,11 +238,42 @@ Overlap Modes ------------- -Special care must be taken to decide how to deal with reads that overlap more than one feature. +Special care must be taken to decide how to deal with reads that align to or +overlap with more than one feature. The ``htseq-count`` script allows to choose +between three modes. See also the FAQ_, if the following explanation seems too +technical. + +The three overlap resolution modes of `htseq-count` work as follows. For each +position *i* in the read, a set *S(i)* is defined as the set of all features +overlapping position *i*. Then, consider the set *S*, which is (with *i* +running through all position within the read or a read pair) + +- the union of all the sets *S(i)* for mode ``union``. This mode is + recommended for most use cases. +- the intersection of all the sets *S(i)* for mode ``intersection-strict``. +- the intersection of all non-empty sets *S(i)* for mode + ``intersection-nonempty``. -The htseq-count script allows to choose between three modes: *union*, *intersection-strict*, and *intersection-nonempty*. +If *S* contains precisely one feature, the read (or read pair) is counted for +this feature. If *S* is empty, the read (or read pair) is counted as +``no_feature``. If *S* contains more than one feature, ``htseq-count`` behaves +differently based on the ``--nonunique`` option: -The following figure illustrates the effect of these three modes: +- ``--nonunique none`` (default): the read (or read pair) is counted as + ``ambiguous`` and not counted for any features. Also, if the read (or read + pair) aligns to more than one location in the reference, it is scored as + ``alignment_not_unique``. +- ``--nonunique all``: the read (or read pair) is counted as ``ambiguous`` and + is also counted in all features to which it was assigned. Also, if the read + (or read pair) aligns to more than one location in the reference, it is + scored as ``alignment_not_unique`` and also separately for each location. + +Notice that when using ``--nonunique all`` the sum of all counts will not be +equal to the number of reads (or read pairs), because those with multiple +alignments or overlaps get scored multiple times. + +The following figure illustrates the effect of these three modes and the +``--nonunique`` option: .. image:: count_modes.png @@ -224,8 +281,11 @@ 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! +**Important: The default for strandedness is yes. Be sure to choose the correct value.** +To check which value is correct, select forward and reverse independently. If +the overall counts drop at one condition then the opposite condition is +correct, otherwise your data is not stranded. Output ------ @@ -250,38 +310,75 @@ 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. +https://htseq.readthedocs.io/en/release_0.9.1/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 + -f , --format= + + Format of the input data. Possible values are sam (for text SAM files) and bam (for binary BAM files). Default is sam. + + -r , --order= + + For paired-end data, the alignment have to be sorted either by read name or by alignment position. If your data is not sorted, use the samtools sort function of samtools to sort it. Use this option, with name or pos for to indicate how the input data has been sorted. The default is name. + + If name is indicated, htseq-count expects all the alignments for the reads of a given read pair to appear in adjacent records in the input data. For pos, this is not expected; rather, read alignments whose mate alignment have not yet been seen are kept in a buffer in memory until the mate is found. While, strictly speaking, the latter will also work with unsorted data, sorting ensures that most alignment mates appear close to each other in the data and hence the buffer is much less likely to overflow. + + --max-reads-in-buffer= + + When is paired end sorted by position, allow only so many reads to stay in memory until the mates are found (raising this number will use more memory). Has no effect for single end or paired end sorted by name. (default: 30000000) + + -s , --stranded= + + whether the data is from a strand-specific assay (default: yes) + + For stranded=no, a read is considered overlapping with a feature regardless of whether it is mapped to the same or the opposite strand as the feature. For stranded=yes and single-end reads, the read has to be mapped to the same strand as the feature. For paired-end reads, the first read has to be on the same strand and the second read on the opposite strand. For stranded=reverse, these rules are reversed. + + -a , --a= + + skip all reads with alignment quality lower than the given minimum value (default: 10 — Note: the default used to be 0 until version 0.5.4.) + + -t , --type= + + feature type (3rd column in GFF file) to be used, all features of other type are ignored (default, suitable for RNA-Seq analysis using an Ensembl GTF file: exon) + + -i , --idattr= + + 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. The default, suitable for RNA-Seq analysis using an Ensembl GTF file, is gene_id. -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. + --additional-attr= + + Additional feature attributes, which will be printed as an additional column after the primary attribute column but before the counts column(s). The default is none, a suitable value to get gene names using an Ensembl GTF file is gene_name. + + -m , --mode= + + Mode to handle reads overlapping more than one feature. Possible values for are union, intersection-strict and intersection-nonempty (default: union) + + --nonunique= + + Mode to handle reads that align to or are assigned to more than one feature in the overlap of choice (see -m option). are none and all (default: none) + + --secondary-alignments= + + Mode to handle secondary alignments (SAM flag 0x100). can be score and ignore (default: score) + + --supplementary-alignments= + + Mode to handle supplementary/chimeric alignments (SAM flag 0x800). can be score and ignore (default: score) + + -o , --samout= + + write out all SAM alignment records into an output SAM file called , annotating each line with its assignment to a feature or a special counter (as an optional field with tag ‘XF’) + + -q, --quiet + + suppress progress report and warnings + + -h, --help + + Show a usage summary and exit + +.. _FAQ: https://htseq.readthedocs.io/en/release_0.9.1/count.html#frequenctly-asked-questions + ]]> diff -r 620d5603d1a8 -r f1368427a79c static/images/count_modes.png Binary file static/images/count_modes.png has changed diff -r 620d5603d1a8 -r f1368427a79c test-data/htseq-test_counts_nonunique.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/htseq-test_counts_nonunique.tsv Mon Feb 05 15:04:47 2018 -0500 @@ -0,0 +1,127 @@ +HRA1 0 +YAL001C 3 +YAL002W 2 +YAL003W 31 +YAL004W 0 +YAL005C 31 +YAL007C 8 +YAL008W 0 +YAL009W 0 +YAL010C 0 +YAL011W 1 +YAL012W 6 +YAL013W 1 +YAL014C 0 +YAL015C 1 +YAL016C-A 0 +YAL016C-B 0 +YAL016W 4 +YAL017W 3 +YAL018C 0 +YAL019W 5 +YAL019W-A 0 +YAL020C 0 +YAL021C 1 +YAL022C 0 +YAL023C 7 +YAL024C 0 +YAL025C 3 +YAL026C 4 +YAL026C-A 0 +YAL027W 0 +YAL028W 0 +YAL029C 7 +YAL030W 2 +YAL031C 2 +YAL031W-A 0 +YAL032C 0 +YAL033W 3 +YAL034C 0 +YAL034C-B 0 +YAL034W-A 1 +YAL035W 23 +YAL036C 7 +YAL037C-A 0 +YAL037C-B 0 +YAL037W 0 +YAL038W 105 +YAL039C 3 +YAL040C 5 +YAL041W 3 +YAL042C-A 0 +YAL042W 6 +YAL043C 3 +YAL044C 2 +YAL044W-A 2 +YAL045C 0 +YAL046C 0 +YAL047C 2 +YAL047W-A 0 +YAL048C 0 +YAL049C 1 +YAL051W 1 +YAL053W 4 +YAL054C 0 +YAL055W 0 +YAL056C-A 0 +YAL056W 0 +YAL058W 1 +YAL059C-A 0 +YAL059W 2 +YAL060W 4 +YAL061W 3 +YAL062W 0 +YAL063C 0 +YAL063C-A 0 +YAL064C-A 0 +YAL064W 0 +YAL064W-B 0 +YAL065C 0 +YAL066W 0 +YAL067C 0 +YAL067W-A 0 +YAL068C 0 +YAL068W-A 0 +YAL069W 0 +YAR002C-A 2 +YAR002W 2 +YAR003W 3 +YAR007C 4 +YAR008W 1 +YAR009C 0 +YAR010C 0 +YAR014C 5 +YAR015W 5 +YAR018C 0 +YAR019C 1 +YAR019W-A 0 +YAR020C 0 +YAR023C 0 +YAR027W 2 +YAR028W 0 +YAR029W 0 +YAR030C 0 +YAR031W 0 +YAR033W 0 +YAR035C-A 0 +YAR035W 0 +YAR042W 2 +YAR047C 0 +YAR050W 0 +YAR053W 0 +YAR060C 0 +YAR061W 0 +YAR062W 0 +YAR064W 0 +YAR066W 0 +YAR068W 11 +YAR069C 0 +YAR070C 0 +YAR071W 1 +YAR073W 0 +YAR075W 0 +snR18 1 +tA(UGC)A 0 +tL(CAA)A 0 +tP(UGG)A 0 +tS(AGA)A 0 diff -r 620d5603d1a8 -r f1368427a79c test-data/htseq-test_samout.bam Binary file test-data/htseq-test_samout.bam has changed