Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • ElMichael
    Member
    • Jun 2009
    • 31

    Changing BAM header makes BAMs "unindexable"

    Hi,
    I'm working with GTEx RNA-Seq BAM files. Their general trouble is that somehow many of them if not all have different headers. The differences are only in the number of those elements like GL000195.1 etc.
    Different headers lead to inability of several programs to work with the batch of such BAMs.
    I focus only in a couple of genes on one chromosome. So I decided to filter only the reads mapped to the genomic region of interest. Then I changed the headers of the new filtered BAMs via 'samtools reheader' removing all that GL000... lines. As a result, all the new BAMs have the same header in terms of @SQ lines. And here is a problem. I can't index these BAMs. Samtools simply produces one line of output: Segmentation fault.
    I have two questions:
    1) Could you advise me how to get indexed BAMs with the uniform (@SQ lines) headers.
    2) I don't understand why samtools couldn't index reheaded BAMs? Even if I keep in such BAMs only those reads that were mapped only to chr5 to the specific gene. What might cause a problem if in the alignment info for every read in these reheaded BAMs there are no information at all about any GL... elements (or, actually, any other chromosomes). What is so critical in the header @SQ lines for other elements that are not represented among the reads in the BAMs?

    Thanks!
  • ElMichael
    Member
    • Jun 2009
    • 31

    #2
    The problem itself was solved by converting BAM->SAM->cat header SAM->new BAM (not convenient but at least something). But the question still remains.

    Comment

    • dpryan
      Devon Ryan
      • Jul 2011
      • 3478

      #3
      You can't just arbitrarily remove entries in the header and have it work. Alignments in a BAM file don't directly store the name of the chromosome/contig to which they align. Instead, they store an index that says, "I map to the 15th entry in the header" and things like that. So, if you shorten the header such that it only has 14 entries then the program is going to crash.

      samtools reheader should probably always display a big warning stating, "You're probably going to screw your file up! Are you sure you know what you're doing?", since it's very easy to mess things up by using it.

      Comment

      • lh3
        Senior Member
        • Feb 2008
        • 686

        #4
        Don't touch the @SQ lines unless you thoroughly understand the BAM structure.

        Comment

        • ElMichael
          Member
          • Jun 2009
          • 31

          #5
          Thank you for the explanation!
          But if I convert a BAM file to SAM format and then change a header and then convert it back to BAM format I will get a correct file, right?

          Comment

          Latest Articles

          Collapse

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, 06-05-2026, 10:09 AM
          0 responses
          11 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-04-2026, 08:59 AM
          0 responses
          23 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-02-2026, 12:03 PM
          0 responses
          28 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-02-2026, 11:40 AM
          0 responses
          22 views
          0 reactions
          Last Post SEQadmin2  
          Working...