Rsamtools : Extracting Unmapped Reads from BAM file
1
1
Entering edit mode
polemiraza ▴ 70
@polemiraza-11428
Last seen 3.0 years ago
Poland

Does anyone have any experience extracting unmapped reads from BAM file and saving them in a new BAM file using Rsamtools (or any other R/Bioconductor package) ?

I am analysing paired-end RNAseq data processed by Rsubread package.

If you could provide some generic code to address this problem it would be greatly appreciated.

Unmapped RNAseq Rsamtools • 2.1k views
ADD COMMENT
0
Entering edit mode

What have you tried?

ADD REPLY
0
Entering edit mode
@martin-morgan-1513
Last seen 4 months ago
United States

Use filterBam() to create a new file from a subset of the original file, using the ScanBamParam() argument to select just unmapped reads. The help page ?filterBam includes this example

     param <- ScanBamParam(
        flag=scanBamFlag(isUnmappedQuery=FALSE),
        what="seq")
     dest <- filterBam(fl, tempfile(), param=param)
     countBam(dest)  ## 3271 records

(the flags can be complicated, so verify that this selects the reads you're interested in).

ADD COMMENT
0
Entering edit mode

Thank you Martin! The code you provided worked for me!

ADD REPLY

Login before adding your answer.

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