Question: merge BAM files from different lanes
0
gravatar for e.amiri79
15 months ago by
e.amiri790
e.amiri790 wrote:

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 • 1.5k views
ADD COMMENTlink modified 15 months ago by Nicolas Rosewick7.9k • written 15 months ago by e.amiri790

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

ADD REPLYlink written 15 months ago by genomax70k
0
gravatar for Nicolas Rosewick
15 months ago by
Belgium, Brussels
Nicolas Rosewick7.9k wrote:

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 COMMENTlink modified 15 months ago • written 15 months ago by Nicolas Rosewick7.9k

Thanks Nicolas, I was thinking about :

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

what do you think?

ADD REPLYlink written 15 months ago by e.amiri790
1

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 REPLYlink written 15 months ago by Nicolas Rosewick7.9k
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: 1207 users visited in the last hour