Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmartin
    Member
    • Dec 2009
    • 78

    #1

    samtools flagstat issues w/ star, hisat2, gsnap & tophat2

    I am comparing these alignment tools:

    hisat2 (v2.0.4)
    gsnap (v2016-08-24)
    star (v2.5.2b)
    tophat2 (v2.1.1)

    by mapping a small set of RNAseq illumina samples vs. an annotated reference. And then I'm using samtools flagstat (samtools v0.1.18) to look at the % of reads that map. But the results I'm getting don't make sense.

    For hisat2 & gsnap, flagstat is reporting the input read count (the top line of the output) as being more reads than are actually in the fastq files. Are the bamfiles generated by those aligners incompatible with flagstat?

    For star & tophat2 its saying the total input read counts are equal to the # mapped in every case (i.e. 100% mapped for all samples), but I think thats simply because the output bams are only the 'hits'. So that makes sense to me. I just don't understand the hisat2 & flagstat results.

    Can anyone explain what I'm seeing for hisat2 & gsnap? Is there an alternate tool I could use to report % reads mapped?
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    You'll want to count only the primary alignments (i.e., subtract secondary alignments from the flagstat output).

    Comment

    • jmartin
      Member
      • Dec 2009
      • 78

      #3
      Is there a convenient way to make samtools report the number of secondary alignments? I actually see that hisat2 reports all the numbers I need in its STDOUT (it had been captured in my job log file so I didn't see it originally). As with bowtie2 it seems to be reporting numbers properly as part of the STDOUT it makes. But for gsnap I don't see any such report.

      So for gsnap does that mean I have to re-build the bam file using a filter for not including non-primary alignments? I guess I would use:

      samtools view -F 0x256

      Do I also have to filter out 'supplementary reads' as well? I am always a bit confused by whether the flag values given by explain flags are AND or OR combinations, but if I check both non-primary & supplementary I get 0x2304, so I guess I need to use:

      samtools view -F 0x2304

      and build a new bam and then run flagstat? I don't have a lot of confidence in using the -f/F filter of samtools view since I was told at one point that the only flag I can really rely on is '4' (not mapped).

      Comment

      • dpryan
        Devon Ryan
        • Jul 2011
        • 3478

        #4
        If "samtools flagstat" doesn't output the number of secondary alignments (I don't recall the output off-hand), then the following will give you the number of primary alignments:

        Code:
        samtools view -cF 2308 alignments.bam
        Note that "-F 2304" and "-F 0x2304" are very different things. The "0x" means, "the rest is hexadecimal", so 0x2304 is 8964 in normal numbers, which isn't what you want.

        Comment

        • jmartin
          Member
          • Dec 2009
          • 78

          #5
          I guess I'd also like to know if these aligners can be set to only report non-supplementary, primary alignments (per query) in the output sam file. I think with bwa mem you can use the -M argument (at least to only report primary alignments, not sure what that does to supplementary alignments). And I think bowtie2 by default already only gives you primary, non-supplementary hits in the output. (At least with a default bowtie2 run the STDOUT report it generates seems to match the flagstat results, which also match my # of input reads).

          This seems like something that would be generally useful. In my case I would very frequently want only primary, non-supplementary hits in the output sam files they build.

          Comment

          • dpryan
            Devon Ryan
            • Jul 2011
            • 3478

            #6
            AFAIK, "bwa mem" is the only aligner that reports supplemental alignments. Many aligners will allow you to limit the number of secondary alignments reported (generally it's an option labelled something like "maximum number of alignments to report"). Most of the more experienced folks are piping the alignments through samtools anyway (i.e., directly writing BAM or CRAM files with no SAM intermediate), so filtering with it on the fly is quite simple.

            Comment

            • jmartin
              Member
              • Dec 2009
              • 78

              #7
              Thanks thats very helpful!

              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
                ...
                10-14-2026, 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, 10-22-2026, 11:13 AM
              0 responses
              35 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 10-22-2026, 10:48 AM
              0 responses
              25 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 10-15-2026, 10:52 AM
              0 responses
              41 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 10-14-2026, 05:39 AM
              0 responses
              45 views
              0 reactions
              Last Post SEQadmin2  
              Working...