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.
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?
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:
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.
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.
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?you can use sam2fastq @ MAPK
Is it 4 or 12 for paired ends? @ genomax
4 would be 'read unmapped', and 12 'read and its mate unmapped'. Here is a nice tool to decode flags.