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

          • 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
          • SEQadmin2
            From Collection to Sequencing: Why Sample Preparation and Preservation Define Sequencing Data
            by SEQadmin2


            Data variability is still an issue in sequencing technologies despite the advances in reproducibility and accuracy of these platforms. But the problem does not originate in the sequencing itself, but in the previous steps, before the sample reaches the sequencer.


            The first step is collection, followed by preservation and sample preparation for analysis. Most scientists overlook those steps, but not being careful might just be skewing the experiment’s results.
            ...
            06-02-2026, 10:05 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, 06-17-2026, 06:09 AM
          0 responses
          31 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-09-2026, 11:58 AM
          0 responses
          96 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-05-2026, 10:09 AM
          0 responses
          117 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-04-2026, 08:59 AM
          0 responses
          109 views
          0 reactions
          Last Post SEQadmin2  
          Working...