Question: Paired-End Bam Files
1
gravatar for sarahmanderni
6.7 years ago by
sarahmanderni70 wrote:

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 • 8.1k views
ADD COMMENTlink modified 4.7 years ago by Shicheng Guo8.4k • written 6.7 years ago by sarahmanderni70
1

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 REPLYlink written 6.7 years ago by Devon Ryan97k

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 REPLYlink written 6.7 years ago by ancient_learner630

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 REPLYlink written 6.7 years ago by lomereiter460
6
gravatar for Devon Ryan
6.7 years ago by
Devon Ryan97k
Freiburg, Germany
Devon Ryan97k wrote:

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 COMMENTlink written 6.7 years ago by Devon Ryan97k
3

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 REPLYlink written 6.7 years ago by Chris Cole760

Ok thanks I will ask.

ADD REPLYlink written 6.7 years ago by sarahmanderni70
1

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 REPLYlink modified 9 months ago by RamRS30k • written 4.7 years ago by Chris Fields2.1k

The option exists for moderators :)

ADD REPLYlink written 4.7 years ago by Devon Ryan97k
1
gravatar for Shicheng Guo
4.7 years ago by
Shicheng Guo8.4k
Shicheng Guo8.4k wrote:

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 COMMENTlink modified 9 months ago by RamRS30k • written 4.7 years ago by Shicheng Guo8.4k
0
gravatar for Chris Cole
6.7 years ago by
Chris Cole760
Scotland
Chris Cole760 wrote:

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 COMMENTlink written 6.7 years ago by Chris Cole760

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 REPLYlink written 6.7 years ago by sarahmanderni70
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: 1191 users visited in the last hour