Damn, I love bbtools. They always have whatever weird processing I'm trying to do already baked in. Thanks for responding.
How to extract unmapped reads if you have paired end reads (fastq) and mapped BAM file?
I have the following files:
- sampleA_1.fastq.gz - Forward reads
- sampleA_2.fastq.gz - Reverse reads
- mapped.sorted.bam - Sorted BAM file of mapped reads (doesn't contain unmapped reads)
How can I use these 3 files to get the following files:
- sampleA_1.unmapped.fastq.gz
- sampleA_2.unmapped.fastq.gz
Can I use anything from the following tools I have installed in my current environment?
- bbmap (and all the software in this suite)
- samtools
- seqkit
• 2,614 views
•
link
1 answer
If your BAM file contains the unmapped reads (not all aligners include them) then you can use bbmap (reformat.sh) and samtools to get the unmapped reads (search for samtools threads here or look at inline help for reformat.sh).
If your BAM file does not contain unmapped reads then you will need to get the read headers from your BAM (mapped reads) and then use filterbyname.sh to get the unmapped reads from your original data files.
• 0 views
•
link
Log in to answer this question.