Subsetting data from BAM file using R tools
1
0
Entering edit mode
8.2 years ago
Ilya IN • 0

Good day to all! This is my first post in Biostars.

I have BAM file with Paired-End RNA seq reads, and I need filter this file by "isize" field: extract the reads with isize not equal to NA and with absolute value of isize lower than treshold (in this case, 642 bp). After all, I must write this subset into SAM file (because this type is required for package which I will use).

I tried use R package Rsamtools for this, but my experience in R is inadequate for solve this problem quickly. If I'm right, settings "param" of function filterBam() can help (if I get BAM file with targer subset, I'll use asSam() to convert into SAM format). Remove reads with isize == NA is possible by means scanBamFlag:

flag <- scanBamFlag(isPaired = TRUE, hasUnmappedMate = FALSE)

But I have no idea about filtration by treshold (abs(bamFile$isize) <= 642). How I can do it in R?

Thanks in advance for your help!

RNA-Seq R rna-seq • 2.5k views
ADD COMMENT
0
Entering edit mode
8.2 years ago
karimse07 ▴ 20

you can use pmax function in R for athreshold

ADD COMMENT
0
Entering edit mode

I don't see pmax working in this case!

ADD REPLY
0
Entering edit mode

Thank you for answer, but how it can help me with BAM file subsetting? Can you give an example?

ADD REPLY

Login before adding your answer.

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