Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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!

  • #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


    • #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


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

        Comment


        • #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

          • seqadmin
            Best Practices for Single-Cell Sequencing Analysis
            by seqadmin



            While isolating and preparing single cells for sequencing was historically the bottleneck, recent technological advancements have shifted the challenge to data analysis. This highlights the rapidly evolving nature of single-cell sequencing. The inherent complexity of single-cell analysis has intensified with the surge in data volume and the incorporation of diverse and more complex datasets. This article explores the challenges in analysis, examines common pitfalls, offers...
            Yesterday, 07:15 AM
          • seqadmin
            Latest Developments in Precision Medicine
            by seqadmin



            Technological advances have led to drastic improvements in the field of precision medicine, enabling more personalized approaches to treatment. This article explores four leading groups that are overcoming many of the challenges of genomic profiling and precision medicine through their innovative platforms and technologies.

            Somatic Genomics
            “We have such a tremendous amount of genetic diversity that exists within each of us, and not just between us as individuals,”...
            05-24-2024, 01:16 PM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, Today, 06:58 AM
          0 responses
          13 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, Yesterday, 08:18 AM
          0 responses
          19 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, Yesterday, 08:04 AM
          0 responses
          18 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 06-03-2024, 06:55 AM
          0 responses
          13 views
          0 likes
          Last Post seqadmin  
          Working...
          X