Gatk Complains That Picard'S Sortsam Doesn'T Sort A Bam...
1
1
Entering edit mode
13.7 years ago
Pablo ★ 1.9k

I'm having a problem trying to use GATK on an alignment performed by BWA and sorted by Picard's SortSam. The error message I get is:

Alignments added out of order in SAMFileWriterImpl.addAlignment for s_1_gC2T.realign.bam. Sort order is coordinate. Offending records are at [Group4.3:96] and [Group4.3:85]

I've sorted the BAM file using Picard, as suggested by GATK's documentation. I've also checked that whether the BAM is "properly sorted" using three simple methods:

  1. Inspect header: Marked as "SO:coordinate"

    $ samtools view -H s.sort.bam | head -n 1

    @HD VN:1.0 SO:coordinate

  2. Indexed the BAM file: No errors, suggesting that it is sorted.

  3. Simple visual inspection: Looks like it is sorted.

Here are the offending records:

seq_118999365   65      Group4.3        85      37      54M1D22M        *       0       106     TTTTTGAGTGTTTTTTTTATGATTTTTTGATTTTTTTGGGGGGATTTTTTTTGGTTTTTTTTGGAATGGGGTTATA    BBBCCB@CACBBCCBCCB@BB=BBBBBB>:BBBBBBC?ABBBB?BBBBBBBB<A?AABABB@594:B@;;>5A>@2
seq_46302040    73      Group4.3        87      37      52M1D24M        *       0       87      TTTGAGTGTTTTTTTTATGATTTTTTGATTTTTTTGGGGGGATTTTTTTTGGTTTTTTTTGGAATGACGTTATATG    BBB=?:=><><ABBA@69A>@@?@@@6=7':@@<?;<??;615==91<=:0599978(>?7533<###########
seq_185000411   147     Group4.3        96      29      52S9M1D7M2D7M1S *       0       12      TAACACAAAAAAAAAAAAAAAAAAAAAAAAAAATGAATAAAGTAAAAATAAATTTGTTTGTATTTTTTTTTTTTTT    ############################################################################

I'm assuming that I'm missing something obvious here...any ideas?

gatk picard bwa • 6.3k views
ADD COMMENT
0
Entering edit mode

You could try bamtools sort, and see if the problem persists.

ADD REPLY
0
Entering edit mode

That's what tried first and didn't work, so I used picard (as recommended in GATK pages)

ADD REPLY
1
Entering edit mode
12.8 years ago
nnutter ▴ 210

It may be that the order of the alignments/reads and @SQ headers are different. I ran into a similar problem recently and used Picard's ReorderSam against a reference FASTA to get the @SQ headers and alignments/reads in the correct order.

EDIT: I found that ReorderSam did not work properly with SAM files but seemed OK with BAM files. When I tried outputting a SAM file it had stripped the RNAME values from the reads.

ADD COMMENT

Login before adding your answer.

Traffic: 1535 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6