Merging Bam Files
3
9
Entering edit mode
13.0 years ago

I have five exomes(in bam format), each a different sample, that I would like to merge into one bam. None of the bam have @RG's in the headers, I am assuming I must add this information first? I also assume this is how I can pull apart the variant information after I processes it with GATK? The Picard documentation states you must pass in a value for UNMAPPED_BAM (definition Original SAM or BAM file of unmapped reads, which must be in queryname order. Required.) I don't undstand what this file is? When I did my alignment should I have dumped the unaligned reads to a file? If so can merge them in a way that does not require unaligned reads to be present.

picard samtools • 80k views
ADD COMMENT
0
Entering edit mode

Can you explain why you want to merge these into a single bam? In my experience, it's usually easier to keep one bam per sample.

ADD REPLY
14
Entering edit mode
13.0 years ago
Frozenwithjoy ▴ 180

I've successfully used the following to merge multiple bam files:

samtools merge merged.bam in.1.bam in.2.bam ...

Although they had @SQs, none had @RGs. Do you have no headers or just no @RGs?

ADD COMMENT
6
Entering edit mode
13.0 years ago
Docroberson ▴ 310

[1] Read Groups: Use Picards AddOrReplaceReadGroups command to create new BAMs that have proper readgroup information. Picard MarkDuplicates and the GATK will appreciate it.

[2] I think the unmapped reads issue is from you confusing MergeBamAlignment and MergeSamFiles. The MergeSamFiles is what you want to use, and despite the name the command works with BAMs also. Just specify INPUT=name.bam for each BAM file. Alternatively you can use samtools merge as well as suggested by frozenwithjoy.

ADD COMMENT
3
Entering edit mode
13.0 years ago
Marvin ▴ 900

I have no idea what Picard uses the "unmapped BAM" for, samtools doesn't require anything like this. 'samtools merge' can add the RG field for you, it will assume one read group per input file. It's your responsibility to provide a BAM header that actually defines these read groups, so you'd probably run 'samtools merge' followed by 'samtools reheader'. See the BAM documentation for the correct format of the RG lines.

ADD COMMENT

Login before adding your answer.

Traffic: 1849 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