Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PFS
    Member
    • Mar 2010
    • 55

    #1

    counting reads mapping to exons and HTseq question

    Is there a simple way to count the number of reads that map to known exons (or genes) given a SAM file with aligned reads and an annotation GTF file?

    I am aware of HTSeq, but I am not sure I am getting what I'm looking for.

    For example, if I run the following:

    htseq-count -m intersection-strict accepted_hits.sam mm9_ucsc_exon.gtf

    I get a count of 3 for a gene that by visual inspection has many more reads mapped to it.

    Any suggestion?

    Thanks.
  • mrawlins
    Member
    • Apr 2010
    • 63

    #2
    I used Picard (the Java implementation of SamTools) to create my own exon counter. It took a few hours, though I'm out of practice with Java. I know that BioScope from ABI has a known exon counter, but their pipeline is a bit frustrating. It's not particularly complicated to write one if you use SamTools, and the documentation for Picard is good, so I suspect other programs are available to do it, but I don't know what they are.

    Comment

    • Simon Anders
      Senior Member
      • Feb 2010
      • 995

      #3
      Hi

      Originally posted by PFS View Post
      I get a count of 3 for a gene that by visual inspection has many more reads mapped to it.
      Possible explanations:

      - htseq-counts assumes your RNA-Seq data to be strand-specific, i.e., it will only count those genes which map to the strand that the feature is on. If you want it to count reads on both strands, use the '--straded=no' option.

      - If a read is not fully contained in the exon, it will not get counted. If you want it to be counted even if it only partially overlaps with the feature, use '--mode=intersection-nonempty'.

      - If there are two overlapping exons from different genes, the reads overlapping both might be discarded and counted as "ambiguous".

      If neither of these explains your observations, you have found a bug. If so, please contact me by mail with more details. Thanks.

      Cheers
      Simon

      Comment

      • jorgebm
        Member
        • Feb 2010
        • 18

        #4
        I've have any discrepancies in the count of exons due to your third explanation: Some exons are cataloged as ambiguous because they (exons) belong to splice variants of the same gene. For instance,

        htseq-count -texon -iParent -sno -mintersection-nonempty reads.sam hg18_refFlat.gff3 > exoncounts.txt

        By other hands, counting by gene maps all the reads in the intra-genic region (not only exons). This is not our goal.

        For instance,

        htseq-count -t gene -i ID --stranded=no reads.sam hg18_refFlat.gff3 > genecounts.txt


        So, Is there any way (using htseq-count) to count exons grouping by gene ("Parent" attribute of "mRNA" row of refFlat file)?

        Originally posted by Simon Anders View Post
        Hi



        Possible explanations:

        - htseq-counts assumes your RNA-Seq data to be strand-specific, i.e., it will only count those genes which map to the strand that the feature is on. If you want it to count reads on both strands, use the '--straded=no' option.

        - If a read is not fully contained in the exon, it will not get counted. If you want it to be counted even if it only partially overlaps with the feature, use '--mode=intersection-nonempty'.

        - If there are two overlapping exons from different genes, the reads overlapping both might be discarded and counted as "ambiguous".

        If neither of these explains your observations, you have found a bug. If so, please contact me by mail with more details. Thanks.

        Cheers
        Simon

        Comment

        • kkamerath
          Junior Member
          • Jun 2008
          • 3

          #5
          counting reads mappint to exons and HTseq question

          Hi jorgebm,
          Were you able to resolve this question? I am interested in accomplishing the same thing and was hoping HTSeq could accommodate.

          Originally posted by jorgebm View Post
          So, Is there any way (using htseq-count) to count exons grouping by gene ("Parent" attribute of "mRNA" row of refFlat file)?

          Comment

          • Simon Anders
            Senior Member
            • Feb 2010
            • 995

            #6
            I have included a Python scripts to do something like this with DEXSeq. Maybe have a look.

            Apart from that: HTSeq is a Python package intended to facilitate programmin such stiff yourself. htseq-count was originally only intended as a demonstration for HTSeq. So, if you know some Python, just do it yourself (and if you know Java, use Picard, which is somewhat similar to HTSeq). I fully agree with mrawlins: it is not that difficult.

            Comment

            • jorgebm
              Member
              • Feb 2010
              • 18

              #7
              Hi,

              I'm sorry for the delay in my reply. I hope it isn't to late to help.....

              My goal was count gene hits to test for differential expresion. So finally I discarded "ht-seq" and use CASAVA (We've a GAIIx) couting output. CASAVA generates RPKM an a "Raw count" (sum of coverages for each base within the feature). Then I've used "Raw counts" and DEseq for differential expression testing.

              However, previously I also tried "intersectBed" (Bed Tools) to overlap alignments with a gene model (in my case RefSeq). If you don't run CASAVA It's a choice.

              Hope it helps.

              Regards

              Comment

              • emilyjia2000
                Member
                • May 2011
                • 59

                #8
                I sort of have different question. I tried to use HTseq-count to count exons, I got GFF files from NCBI mm9 and extracted the exon information to create exon.gff, but I don't know why there is 0 count in the exon output, does anyone know what's wrong with my process?

                Thanks in advance!

                Comment

                • carmeyeii
                  Senior Member
                  • Mar 2011
                  • 137

                  #9
                  I don't know if it might be due to a read mapping to different isoforms sharing the same exons... I have a GFF file of annotated transcripts, and there are of course several transcripts to most genes, some of which share some of same exons.

                  For example, gene A may have isoforms 1 and 2, both of which contain exon y. When htseq tries to assign a feature to a read that mapped to exon y, will it discard it as ambiguous since it cannot decide upon assigning it to isoform 1 or 2? Even though both isoforms come from the same gene and have a column in the GFF stating so.

                  I have a feeling it won't actually be entangled in this sort of a problem, but it could be?

                  Carmen

                  Comment

                  • dpryan
                    Devon Ryan
                    • Jul 2011
                    • 3478

                    #10
                    Originally posted by carmeyeii View Post
                    I don't know if it might be due to a read mapping to different isoforms sharing the same exons... I have a GFF file of annotated transcripts, and there are of course several transcripts to most genes, some of which share some of same exons.

                    For example, gene A may have isoforms 1 and 2, both of which contain exon y. When htseq tries to assign a feature to a read that mapped to exon y, will it discard it as ambiguous since it cannot decide upon assigning it to isoform 1 or 2? Even though both isoforms come from the same gene and have a column in the GFF stating so.

                    I have a feeling it won't actually be entangled in this sort of a problem, but it could be?

                    Carmen
                    Normally when one uses htseq-count, one tells it to group reads by gene (-i gene_id or similar), so a read will be kept regardless of how many isoforms of a single gene it can be assigned to.

                    Comment

                    • Simon Anders
                      Senior Member
                      • Feb 2010
                      • 995

                      #11
                      Originally posted by emilyjia2000 View Post
                      I sort of have different question. I tried to use HTseq-count to count exons, I got GFF files from NCBI mm9 and extracted the exon information to create exon.gff, but I don't know why there is 0 count in the exon output, does anyone know what's wrong with my process?
                      Maybe if you told us how exactly you extracted the exon information and how you called htseq-count, we might be able to help you without resorting to guessing. In any case, have a look at the Python scripts that we supply with DEXSeq. These are meant to count reads mapping to exons. Using htseq-count for this purpose is not at all straight-forward.

                      Comment

                      • carmeyeii
                        Senior Member
                        • Mar 2011
                        • 137

                        #12
                        Originally posted by dpryan View Post
                        Normally when one uses htseq-count, one tells it to group reads by gene (-i gene_id or similar), so a read will be kept regardless of how many isoforms of a single gene it can be assigned to.
                        Thanks!

                        Comment

                        • malirose
                          Junior Member
                          • Dec 2013
                          • 1

                          #13
                          Hi all,
                          do you have any idea how to separate reads(from a bam file) according to the strand they came from in an RNA-Seq paired end and strand specific data ? I tried both tophat flag and samtools flag , the two results are quite different and many reads are not affected correctly to their specific strand

                          Comment

                          • dpryan
                            Devon Ryan
                            • Jul 2011
                            • 3478

                            #14
                            Do you just want pairs that maps to the + strand in one file and those that map to the - strand in another (alternatively, separating paired-end reads by the strand to which read1 aligns)? You can do that with gawk or python (or pretty much any language for that matter). Having said that, if you're trying to count RNAseq reads, then just have htseq-count deal with this for you.

                            Also, please start a new thread next time. This one is over a year old.

                            Comment

                            • Dinesh Heisnam
                              Member
                              • Dec 2013
                              • 10

                              #15
                              HTSeq count of single reads

                              Hi all,
                              As far as we come across,it is clear that the HTSeq Count gives the count of paired reads only. Even if we included the single reads in addition to paired reads in mapping, single reads has no meaning.
                              So my question is whether there is any option in HTSeq count to consider the single read also.

                              Comment

                              Latest Articles

                              Collapse

                              • SEQadmin2
                                Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
                                by SEQadmin2



                                Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

                                Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
                                ...
                                Today, 09:55 AM
                              • SEQadmin2
                                New Genomics Technologies Take Aim at Long-Standing Limits
                                by SEQadmin2


                                Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

                                We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
                                ...
                                09-28-2026, 10:25 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by SEQadmin2, Today, 05:39 AM
                              0 responses
                              10 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, Yesterday, 09:56 AM
                              0 responses
                              11 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 10-09-2026, 11:14 AM
                              0 responses
                              25 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 09-29-2026, 09:51 AM
                              0 responses
                              77 views
                              0 reactions
                              Last Post SEQadmin2  
                              Working...