Paired-End Bam Files
3
1
Entering edit mode
7.6 years ago

Hi,

Having two BAM files from NGS data, how can one check if they are the BAM files (left and right) from a paired end mapping of the same sample? Thanks for the help.

paired-end bam • 9.1k views
ADD COMMENT
1
Entering edit mode

The paired-ends from the same sample should (almost*) always be mapped together, producing only 1 BAM file. If you're mapping mates separately, then you're doing things wrong.

*If you were working on an exception to this, you'd already know how to do this.

ADD REPLY
0
Entering edit mode

am not much clear. but if you want to check whether those files are paired-end convert them to sam format using samtools and then see

ADD REPLY
0
Entering edit mode

I'm not sure if I understand you right, but maybe sort them by name and check if the read names are the same in the two files?

ADD REPLY
7
Entering edit mode
7.6 years ago

Mates in a pair shouldn't be mapped separately. To check if a BAM file has reads that arise from paired-end sequencing (and were mapped accordingly), just check for the 0x1 bit in the FLAG field (i.e., see if samtools view -f 0x1 something.bam prints any reads).

ADD COMMENT
3
Entering edit mode

Yup. Agree. If you have separate BAM files for each sample, then either they are separate runs or the paired-end alignment was done wrong.

Have you asked the people who generated the BAMs? They will know what they did, rather than you trying to guess from the files themselves.

ADD REPLY
0
Entering edit mode

Ok thanks I will ask.

ADD REPLY
1
Entering edit mode

Completely OT, but we really need a way to convert a comment to an answer, this would be the obvious pick for us command-line junkies.

ADD REPLY
0
Entering edit mode

The option exists for moderators :)

ADD REPLY
1
Entering edit mode
5.6 years ago
Shicheng Guo ★ 8.8k

I write a perl script to decide the bam file is paired-end or single end.

sub is_bamPE($){
  my($bamfile)=@_;
  my $is_pairedEnd;
  chomp( my $line=`samtools view $bamfile | head -n 1| awk '{print \$2}'`);
  my $remainder=$line%2;
  print "$line\t$remainder\n";
  if($remainder){
  $is_pairedEnd="--paired-end"
  }else{
  $is_pairedEnd="--single-end"
  }
  return $is_pairedEnd;
}
ADD COMMENT
0
Entering edit mode
7.6 years ago
Chris Cole ▴ 760

I'd look at the BAM in a graphical viewer. Try one of desktop viewers IGB, IGV or Tablet or online browsers such UCSC or ensembl.

ADD COMMENT
0
Entering edit mode

Actually there are BAM files for more than 70 samples. So I have two bam files for each sample and I want to check if they really are the paired-end files of the samples or are single end but technical replicates. I was wondering of a flag or something that could be checked with a python script to show it.

ADD REPLY

Login before adding your answer.

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