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.
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.
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).
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.
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;
}
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.
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.
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
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.
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
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?