Question: Separate unaligned reads in fastq format using bowtie
0
gravatar for MAPK
7 months ago by
MAPK1.4k
United States
MAPK1.4k wrote:

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 • 521 views
ADD COMMENTlink modified 7 months ago • written 7 months ago by MAPK1.4k
3
gravatar for genomax
7 months ago by
genomax64k
United States
genomax64k wrote:

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 COMMENTlink written 7 months ago by genomax64k

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 REPLYlink written 7 months ago by MAPK1.4k

you can use sam2fastq @ MAPK

Is it 4 or 12 for paired ends? @ genomax

ADD REPLYlink modified 7 months ago • written 7 months ago by cpad011211k

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

ADD REPLYlink written 7 months ago by ATpoint14k
3
gravatar for ATpoint
7 months ago by
ATpoint14k
Germany
ATpoint14k wrote:

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 COMMENTlink modified 7 months ago • written 7 months ago by ATpoint14k
2
gravatar for MAPK
7 months ago by
MAPK1.4k
United States
MAPK1.4k wrote:

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 COMMENTlink modified 7 months ago • written 7 months ago by MAPK1.4k

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 REPLYlink written 7 months ago by ATpoint14k
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: 1087 users visited in the last hour