Question: Problem With Sorting Bam File: Samtools
0
gravatar for lyfsa
6.7 years ago by
lyfsa30
lyfsa30 wrote:

Hi!

I have three aligned pair end reads in BAM format. Two of them are of same sample run in different lanes. I first merged the files from same sample with read groups and added read group to third one separately. After that I merge all three bam files into one, also changing header to required one. I then tried to sort the merged bam file. But this is what I get as a sorted file. File_RG.sorted.0000.bam , File_RG.sorted.0001.bam, File_RG.sorted.0002.bam and so on....

Why am I not able to sort the BAM file? I am using samtools for merging and sorting.

merge bam samtools • 4.6k views
ADD COMMENTlink written 6.7 years ago by lyfsa30
4
gravatar for matted
6.7 years ago by
matted7.0k
Boston, United States
matted7.0k wrote:

Are you waiting for the command to finish, or is it crashing early for some reason? samtools sort will make those intermediate files (0000, 0001, etc.) since it cannot hold all reads in memory during the sort. It will do a final mergesort that produces the single bam you want, and should then delete those intermediate files.

ADD COMMENTlink written 6.7 years ago by matted7.0k
1

You don't even need to delete them, they are merged back to the output file prefix you gave, while launching the command.

ADD REPLYlink written 6.7 years ago by Sukhdeep Singh9.7k

I did not wait for command to finish. I was not aware of this piece of information for sorting. Thank you for answering :)

ADD REPLYlink written 6.7 years ago by lyfsa30

I am having the same error .I am generating 25 samples ,some of the sorted bam files get automerged after sorting,but some of them dont get merged.

Should I use the Samtools "merge" command to merge those sorted bam files ? or I have to give memory options?

ADD REPLYlink modified 5.3 years ago • written 5.3 years ago by Ron920
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1612 users visited in the last hour