Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • newfie
    Junior Member
    • Feb 2016
    • 8

    Probelem with SAM file created by Bowtie2

    Hello everyone,

    I created a bowtie index from a fasta file which was merged from 4 individual fasta file. One is from miRBase, two from RFAM coressponding to tRNA and other non coding RNA and the final one is repeat masker fasta sequences downloaded from UCSC.

    Then i aligned the reads using bowtie2 with index created from above fasta files under local mode with the following options:

    bowtie2 --local -N 1 -L 20 -p 20 -x ~/Downloads/index/superfasta.index -f -U input_E1.fa -S output.sam

    After the run i got the alignment rate as follow:

    2599066 reads; of these:
    2599066 (100.00%) were unpaired; of these:
    1730189 (66.57%) aligned 0 times
    265716 (10.22%) aligned exactly 1 time
    603161 (23.21%) aligned >1 times
    33.43% overall alignment rate


    Then i converted the sam file to bam using

    samtools view -bS output_E1.sam > output_E1.bam

    Then i checked the falgstats using:

    samtools flagstat output_E1.bam'

    and got the following results

    0 + 0 in total (QC-passed reads + QC-failed reads)
    0 + 0 secondary
    0 + 0 supplementary
    0 + 0 duplicates
    0 + 0 mapped (N/A : N/A)
    0 + 0 paired in sequencing
    0 + 0 read1
    0 + 0 read2
    0 + 0 properly paired (N/A : N/A)
    0 + 0 with itself and mate mapped
    0 + 0 singletons (N/A : N/A)
    0 + 0 with mate mapped to a different chr
    0 + 0 with mate mapped to a different chr (mapQ>=5)

    The flagstat output says that none of the sequences mapped, whereas it should be 33.43% as shown in the first output.

    Then, i also checked the number of sequences that mapped using this command
    samtools view -F 4 output.bam | wc -l
    and again i got 0.

    When i used tail command for the SAM file, everything seems fine i can see the flag value of 0 or 4 or 16. But why isn't the samtools showing weird results. is there an issue with the SAM file? I actually used another genome with another file of reads and i when i analysed using SAM tools, everything is fine and all the numbers are concordant. So the only likely explanation is that there must be a problem with the reference index or the fasta file that is used to create the reference index. There were some white spaces in the header of few fasta sequecnes and i removed them, then tried it again with the new index and the problem still persists. What could be the problem behind this? Whether the SAM file has a malformed line? or could be something else. If someone could suggest a solution, that would be awesome. I have an fast approaching deadline to complete the data analysis and i am stuck here. if anyone could help find a solution, that would be great.

    thanks!
    Last edited by newfie; 09-21-2016, 09:25 AM. Reason: one output file name was not mentioned correctly
  • Michael.Ante
    Senior Member
    • Oct 2011
    • 127

    #2
    Hi,

    did you got any error messages, while doing:
    Originally posted by newfie View Post
    samtools view -bS output_E1.sam > output_E1.bam
    ?
    You forgot to include the header which should lead to a non-functional bam file.
    Please try
    Code:
    samtools view -bS[B]h[/B] output_E1.sam > output_E1.bam
    this should produce a working bam file.

    Comment

    • newfie
      Junior Member
      • Feb 2016
      • 8

      #3
      Originally posted by Michael.Ante View Post
      Hi,

      did you got any error messages, while doing:

      ?
      You forgot to include the header which should lead to a non-functional bam file.
      Please try
      Code:
      samtools view -bS[B]h[/B] output_E1.sam > output_E1.bam
      this should produce a working bam file.
      I tried it again with samtools view -bSh output_E1.sam > output_E1.bam , but the problem is not solved, it just keeps on giving the same output

      Comment

      • Michael.Ante
        Senior Member
        • Oct 2011
        • 127

        #4
        Maybe you have also the wrong file:

        bowtie2 --local -N 1 -L 20 -p 20 -x ~/Downloads/index/superfasta.index -f -U input_E1.fa -S output.sam
        vs.
        samtools view -bSh output_E1.sam > output_E1.bam

        Comment

        • newfie
          Junior Member
          • Feb 2016
          • 8

          #5
          Originally posted by Michael.Ante View Post
          Maybe you have also the wrong file:


          vs.
          Actually there are two output files output.sam and output_E1.sam in the home directory. both of them gives the same output as i had mentioned earlier. Out of curiosity, i tired with fastq files instead of fasta files and now the sam files are okay, the statistics number are all now concordant. It seems that there was a problem when fastq files were converted to fasta format. But thank you very much for your time and help that you have rendered

          Michael Ante, i wanted to ask a favor. Do you know how to subset the sam files based on the fasta headers of the reference fasta file?. In my case, there are four different types of fasta headers (as i used a merged fasta file from four different ones) and actually i can see them in the third tab (chromosome). if there is an alignment, it inputs which fasta header the read aligns to. if there is no alignment there is * there. Already, i sorted out my sam files based on reads that mapped and which didn't map. Now i want to further sort the mapped ones based on which fasta header they align to. If you know, how to do it. could you please provide me the code?

          Thanks in advance

          Comment

          • GenoMax
            Senior Member
            • Feb 2008
            • 7142

            #6
            @newfie: You can use some of the suggestions in this thread to split your sam file https://www.biostars.org/p/46327/

            Comment

            Latest Articles

            Collapse

            • SEQadmin2
              Cancer Drug Resistance: The Lingering Barrier to Rising Survival
              by SEQadmin2



              Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

              There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
              Yesterday, 05:17 AM
            • GATTACAT
              Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
              by GATTACAT
              Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
              07-01-2026, 11:43 AM
            • SEQadmin2
              Nine Things a Sample Prep Scientist Thinks About Before Sequencing
              by SEQadmin2


              I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

              Here are nine questions we think about, in roughly the order they matter, before...
              06-18-2026, 07:11 AM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by SEQadmin2, Yesterday, 10:08 AM
            0 responses
            6 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 07-07-2026, 11:05 AM
            0 responses
            8 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 07-02-2026, 11:08 AM
            0 responses
            31 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-30-2026, 05:37 AM
            0 responses
            29 views
            0 reactions
            Last Post SEQadmin2  
            Working...