Separate unaligned reads in fastq format using bowtie
3
0
Entering edit mode
6.3 years ago
MAPK ★ 2.1k

I can separate unaligned reads through a much convoluted process mentioned here( https://github.com/alvaralmstedt/Tutorials/wiki/Separating-mapped-and-unmapped-reads-from-libraries), but is there a easier way to separate unaligned reads in fastq format using bowtie? Would appreciate if someone could guide me through the process of separating both single end reads and paired end reads in fastq format.

bowtie fastq • 6.9k views
ADD COMMENT
3
Entering edit mode
6.3 years ago
GenoMax 147k

Did you look at the bowtie (or botwie2) manual's relevant section?

If you used bbmap.sh to align the reads then outu=file.fq will collect unaligned reads.

If you have aligned bam files containing unaliged reads then you can easily separate them by samtools view -f 4 file.bam > unmapped.sam

ADD COMMENT
0
Entering edit mode

Thanks for your answer. I took a look at bowtie manual and they have --un option which I think only generates .sam format file. Can we save it as fastq file instead?

ADD REPLY
0
Entering edit mode

you can use sam2fastq @ MAPK

Is it 4 or 12 for paired ends? @ genomax

ADD REPLY
0
Entering edit mode

4 would be 'read unmapped', and 12 'read and its mate unmapped'. Here is a nice tool to decode flags.

ADD REPLY
3
Entering edit mode
6.3 years ago
ATpoint 85k

I think the simplest solution is using SAMBLASTER. It is actually a tool for marking duplicates and extracting split/discordant reads for structural variant analysis, but has also the option to output unmapped reads as fastq. To make the tool only outputting the unmapped reads without any further manipulation of the bowtie output, I would do:

bowtie --sam (...) | samblaster -a --ignoreUnmated -u reads_unmapped.fastq --quiet | samtools view -b -o alignment.bam

The -a turns off the duplicate detection and --ignoreUnmated turns off the detection of unmated reads. alignment.bam is then your bowtie output in BAM format. You can also directly pipe the whole thing into samtools sort to save disk space and time.

ADD COMMENT
2
Entering edit mode
6.3 years ago
MAPK ★ 2.1k

I tried it saving as fastq using bowtie and that does the job done. So if you save the output as fastq, it loses the SAM features and saves only the aligned reads. Here is what I have done: bowtie -q -p 18 -v 1 index_out infile.fastq --un unaligned_output.fastq --al aligned_output.fastq

This gives you both aligned and unaligned reads. The index_out is the bowtie index file from bowtie-build without extension.

ADD COMMENT
0
Entering edit mode

Thanks for sharing. Nice to see that bowtie is indeed a smart suffix-aware tool as one would expect from an elaborate piece of software as this one.

ADD REPLY

Login before adding your answer.

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