Differences between two SAM/BAM files with samtools
1
0
Entering edit mode
9.1 years ago
dshulgin ▴ 260

Hi everyone. I'd like to compare two bam files from two different aligners to find overlaps, multiple alignments, unique reads in each bam file etc. I was looking for simple tutorial of samtools to do that, but it is still unclear for me (there are to many options and flags and I'm puzzled with it).

Could someone help me? What is the best way to compare outputs of different aligners?

Thanks a lot

SNP alignment • 7.0k views
ADD COMMENT
2
Entering edit mode
9.1 years ago

comparing the first in pair using the RNAME,CHROM,POS, columns:

samtools view -f 64 -F 2304 method1.bam | cut -f1,3,4 | LC_ALL=C sort -t '\t' -k1,1 > method1.txt
samtools view -f 64 -F 2304 method2.bam | cut -f1,3,4 | LC_ALL=C sort -t '\t' -k1,1 > method2.txt
join -t '\t' -1 1 -2 1 method1.txt method2.txt > R1.comparaison
ADD COMMENT
0
Entering edit mode

I performed this but got empty file at each steps. Could you help me?

ADD REPLY
0
Entering edit mode

'\t' in sort is a TAB. Did you replace this?

ADD REPLY
0
Entering edit mode

I wrote this way t$'\t'. Sorry for interrupting you. There is something wrong with my file. It works fine on another .bam file. Thanks.

ADD REPLY
0
Entering edit mode

Hi Pierre, I am trying to compare two bam files just like dsulgin did, but I am getting empty file out of this step -

samttools view -f 64 -F 2304 input1.bam | cut -f1,3,4 | LC_ALL=C sort -t `\t` -k1,1  > method1.txt

Can you please share what columns should I expect in this method1.txt file? I am also getting this error -

sort: multi-character tab `\\t'

thanks!

ADD REPLY

Login before adding your answer.

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