merge BAM files from different lanes
1
1
Entering edit mode
6.6 years ago
e.amiri79 ▴ 10

Hello all,

To analyze my Rna-Seq samples, I am following new Tuxedo suite pipeline (https://github.com/griffithlab/rnaseq_tutorial/wiki/Alignment)

I have paired end reads in two lanes. I used hisat2 to align the reads (of course separate for each lane) and got two sam files for the lanes.

EGG04_L004.sam
EGG04_L005.sam

Then I used

samtools sort -@ 8 -o EGG04_L004.bam EGG04_L004.sam
samtools sort -@ 8 -o EGG04_L005.bam EGG04_L005.sam

to convert the sam files to bam files and sort by aligned position. Now I am wondering whether I need to merge the files from two lanes to one using samtools merge and then merge all the bam files together as the next step to I can directly go ahead and merge all the mab files regardless to the bam files from different lanes. since the pipeline recommends to merge the files using picard.

If I need to first merge the bam files from two lanes together what would be the recommended command for samtools merge?

RNA-Seq • 8.5k views
ADD COMMENT
0
Entering edit mode

You will need to re-sort the files after you merge them.

ADD REPLY
1
Entering edit mode
6.6 years ago

If the two lanes are for the same sample then merge everything using samtools merge :

samtools merge EGG04.bam EGG04_L004.bam EGG04_L005.bam
ADD COMMENT
0
Entering edit mode

Thanks Nicolas, I was thinking about :

samtools merge -h EGG04.bam EGG04_L004.bam EGG04_L005.bam

what do you think?

ADD REPLY
1
Entering edit mode

As specified in the samtools documentation :

-h FILE Use the lines of FILE as `@' headers to be copied to out.bam, replacing any header lines that would otherwise be copied from in1.bam. (FILE is actually in SAM format, though any alignment records it may contain are ignored.)

You should then not use -h

ADD REPLY

Login before adding your answer.

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