Question: Remove singletons from bam
0
gravatar for banerjeeshayantan
12 months ago by
banerjeeshayantan110 wrote:

I have a tumor bam file and running samtools flagstat gave the following output

1020505173 + 0 in total (QC-passed reads + QC-failed reads)  
0 + 0 secondary  
0 + 0 supplementary  
0 + 0 duplicates  
1003947659 + 0 mapped (98.38% : N/A)  
1020505173 + 0 paired in sequencing  
508168252 + 0 read1  
512336921 + 0 read2  
991357546 + 0 properly paired (97.14% : N/A)  
996058067 + 0 with itself and mate mapped  
7889592 + 0 singletons (0.77% : N/A)  
3742219 + 0 with mate mapped to a different chr  
3349172 + 0 with mate mapped to a different chr (mapQ>=5)

The number of sequences in read1 and read2 differ, although they add up to the number of paired reads in sequencing. What can I do to make this right?

sequencing next-gen • 818 views
ADD COMMENTlink modified 12 months ago by RamRS21k • written 12 months ago by banerjeeshayantan110

What makes you think you have to correct this?

ADD REPLYlink written 12 months ago by WouterDeCoster38k

While aligning this will give an error, right? Or do aligners usually skip unmapped reads?

ADD REPLYlink written 12 months ago by banerjeeshayantan110

You have a bam file. Those reads are aligned.

ADD REPLYlink written 12 months ago by WouterDeCoster38k

Apologies for my confusion. If I run BWA-MEM will it matter if the number of reads are different? Thanks again!

ADD REPLYlink written 12 months ago by banerjeeshayantan110

Run bwa mem on what?

ADD REPLYlink written 12 months ago by WouterDeCoster38k

aligning read_1 and read_2 using bwamem

ADD REPLYlink written 12 months ago by banerjeeshayantan110

But the reads ARE aligned. What are you doing?

ADD REPLYlink written 12 months ago by WouterDeCoster38k

The reads were aligned using hg19 reference. I want to align them using hg38. So I converted the bam reads to paired fastq files and now I want to align them again.

ADD REPLYlink written 12 months ago by banerjeeshayantan110
1

Maybe you should have said that from the beginning?

Anyway: if you are aligning paired end reads then you need exactly as much reads in read1 as in read2, in the same order.

ADD REPLYlink written 12 months ago by WouterDeCoster38k

So is it a problem with bam2fq command? What's the way out?

ADD REPLYlink modified 12 months ago • written 12 months ago by banerjeeshayantan110

. I want to align them using hg38. So I converted the bam reads to paired fastq files and now I want to align them again.

ADD REPLYlink written 12 months ago by Pierre Lindenbaum118k
1
gravatar for Antonio R. Franco
12 months ago by
Spain. Universidad de Córdoba
Antonio R. Franco4.0k wrote:

Take a look to this page https://broadinstitute.github.io/picard/explain-flags.html

Then try to use samtools view with the -f and the -F options to select those mapped reads that are of your interest.

If you have mapped paired reads, all your BAM flags will be an odd number, meaning that they come from a paired mapping

If you check the second option (read mapped in proper pair) you will see a value of 2 that can be used with samtools view -f to extract all the mapped reads that fit that condition

samtools view -f2 -b your_original.bam > your_new.bam
ADD COMMENTlink written 12 months ago by Antonio R. Franco4.0k

Thanks for replying. So basically I am trying to read a bam file without the singletons. I tried out your suggestion but getting an error now.

[W::bgzf_read_block] EOF marker is absent. The input is probably truncated  
[main_samview] truncated file.

What to do here?

ADD REPLYlink modified 12 months ago by RamRS21k • written 12 months ago by banerjeeshayantan110
2

If you have this error when running the samtools command is that the original file is corrupted. If dealing with the final filtered file, give it a little time to finish the command. I have just tested the command and is working nicely

ADD REPLYlink written 12 months ago by Antonio R. Franco4.0k
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: 1859 users visited in the last hour