How to get unmapped reads in a separate Fasta or Fastq file?
1
1
Entering edit mode
10.1 years ago
niu2rseq ▴ 90

Hi,

I have some fastq files which I mapped to the host genome and get a sam file with 80% mapping rate. Now how can I get the unmapped reads to a separate fastq or fasta file so I can play with that only? Thank you very much everybody!

RNA-Seq samtools bowtie tophat • 7.4k views
ADD COMMENT
1
Entering edit mode

I edited the title of post in case anyone is wondering about the comments/answers. Feel free to edit to be more appropriate.

ADD REPLY
1
Entering edit mode

It looks great now :)

ADD REPLY
3
Entering edit mode
10.1 years ago
Manvendra Singh ★ 2.2k

Title of your question is different from content of question, anyways,

So you ran tophat, and got bam files , both mapped and unmapped.

and you want to extract reads from unmapped bam file in fastq format, you just run bamToFastq from bedtools

Here is description from their manual :

bedtools bamtofastq (aka bamToFastq)

Summary: Convert BAM alignments to FASTQ files.

Usage: bamToFastq [OPTIONS] -i <BAM> -fq <FQ>

Options:
-fq2 FASTQ for second end. Used if BAM contains paired-end data.
BAM should be sorted by query name is creating paired FASTQ.
-tags Create FASTQ based on the mate info in the BAM R2 and Q2 tags.

Tips:
If you want to create a single, interleaved FASTQ file for paired-end data, you can just write both to /dev/stdout:
bedtools bamtofastq -i x.bam -fq /dev/stdout -fq2 /dev/stdout > x.ilv.fq

ADD COMMENT

Login before adding your answer.

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