Picard Markduplicate: Exception when processing alignment for BAM index A00187:618:HL7KKDRXY:1:1101:10077:2409 1/2 45b aligned read.
Hey, I have single cell BAM which are aligned using STAR and I wanted to run MarkDuplicate on. After about several attempts and many hours of running Picard MarkDuplicate, with the code below, I am still left with this error. Code:
java -jar -Xmx100g picard.jar MarkDuplicates INPUT=SampleEXP.bam METRICS_FILE=SampleEXP_metrics.txt REMOVE_DUPLICATES=true OUTPUT=SampleEXP_dedupped.bam CREATE_INDEX=true VALIDATION_STRINGENCY=SILENT MAX_RECORDS_IN_RAM=500000000
Error:
Runtime.totalMemory()=1467887616
To get help, see http://broadinstitute.github.io/picard/index.html#GettingHelp
Exception in thread "main" htsjdk.samtools.SAMException: Exception when processing alignment for BAM index A00187:618:HL7KKDRXY:1:1101:10077:2409 1/2 45b aligned read.
at htsjdk.samtools.BAMFileWriter.writeAlignment(BAMFileWriter.java:131)
at htsjdk.samtools.SAMFileWriterImpl.addAlignment(SAMFileWriterImpl.java:190)
at picard.sam.markduplicates.MarkDuplicates.doWork(MarkDuplicates.java:396)
at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:205)
at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:94)
at picard.cmdline.PicardCommandLine.main(PicardCommandLine.java:104)
Caused by: htsjdk.samtools.SAMException: Exception creating BAM index for record A00187:618:HL7KKDRXY:1:1101:10077:2409 1/2 45b aligned read.
at htsjdk.samtools.BAMIndexer.processAlignment(BAMIndexer.java:110)
at htsjdk.samtools.BAMFileWriter.writeAlignment(BAMFileWriter.java:128)
... 5 more
Caused by: htsjdk.samtools.SAMException: Unexpected reference -1 when constructing index for 24 for record A00187:618:HL7KKDRXY:1:1101:10077:2409 1/2 45b aligned read.
at htsjdk.samtools.BAMIndexer$BAMIndexBuilder.processAlignment(BAMIndexer.java:209)
at htsjdk.samtools.BAMIndexer.processAlignment(BAMIndexer.java:108)
... 6 more
I have the option to go back and realign my reads which might take several additional hours and/or by simply remove the read from my alignment file and rerun the step, but I want to know if there is any efficient and correct way to do it. Many thanks!
• 2,307 views
•
link
0 answers
No answers yet.
Log in to answer this question.
this error occurs when a chromosome in the bam is not defined in the SAM header (
@SQlines).Thank you for the quick reply Pierre Lindenbaum. Do you have a suggestion how I can fix my header lines? I did samtools view -H to get the header and append it to my sam/bam files. With this I assumed I keep the same header from the original bam from STAR.
show us the line(s) in your original bam containinig
00187:618:HL7KKDRXY:1:1101:10077:2409and show us the@SQlines in the bam header.The line with 00187:618:HL7KKDRXY:1:1101:10077:2409 has a in the RNAME position. And I have a few more reads that have that when I grep based on this in column 3.
The SQ line in the file:
One way I think I can fix this is to remove all reads that have * in the RNAME, and append the header from the original bam. I am testing this out. It might fix the problem.
those reads look broken. flag is 111 = read paired (0x1) read mapped in proper pair (0x2) read unmapped (0x4) mate unmapped (0x8) mate reverse strand (0x20) first in pair (0x40)
so we have read mapped in proper pair while the read is said "'unmapped". Furthermore there is a cigar string while the read is unmapped. Aren't you using an old version of the software ?
It is using STAR version 2.7.3a, yes a bit older version. I agree that there reads are problematic. I will just re-align then with a newer version of STAR.
Thank you for pointing me in the right direction.