mergeBam picard issue
Hello,
I'm having issues with the mergeBam function from Picard. I getting the following error:
Exception in thread "main" java.lang.IllegalStateException: Aligned record iterator (A00419:256:HK7NFDRXX:1:2101:10294:3850) is behind the unmapped reads (A00419:256:HK7NFDRXX:1:2101:10294:4038)
at picard.sam.AbstractAlignmentMerger.mergeAlignment(AbstractAlignmentMerger.java:557)
at picard.sam.SamAlignmentMerger.mergeAlignment(SamAlignmentMerger.java:186)
at picard.sam.MergeBamAlignment.doWork(MergeBamAlignment.java:366)
at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:305)
at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:103)
at picard.cmdline.PicardCommandLine.main(PicardCommandLine.java:113)
I saw that many people got this same error and this is potentially due to the ubam file is not sorted by queryname, however my unmapped bam files were all sorted by queryname when I converted my fastq using the function FastqToSam. I even try to sort it again using SortSam, but I am still getting the error.
My mapped files came from a two pass STAR step and they were sorted by coordinate by STAR. I don't think this is the problem because I already merge files using the same pipeline and they worked fine.
Any ideas why and what can I do about this error?
Thank you!
-
The fact that the uBAM is readname-sorted and the mapped BAM is coordinate-sorted is the exact problem causing the error you are reporting. Both uBAM and mapped BAM must be readname-sorted (since uBAM cannot be coordinate-sorted). Try to sort the mapped BAM by a read name.
"Everything worked fine previously" does not actually mean the data was the same at that time. Unless you can check the sorting order of the BAM files from your previous pipeline runs you cannot presume the error is elsewhere but in the sorting order.
Please sign in to leave a comment.
1 comment