bam file merge
Hello. I have numerous bam files which I need to merge into a single bam file. How do I know whether I need to first index and sort the bam files?
• 3,431 views
•
link
1 answer
You should sort your files, as samtools merge expects sorted bam files, either by position (default) or by name (samtools merge -n). You can check if you bam are already sorted by looking at the SO flag:
samtools view -H file.bam | grep "SO:"
@HD VN:1.0 SO:coordinate
• 1 views
•
link
Log in to answer this question.
In http://www.htslib.org/doc/samtools-1.2.html, it says,
Dear genomics Newbie, Hi
Please have a look at To sort or not to Sort?.
I guess you can first use "
samtools merge" and then "samtools sort -o".