Question: Subsetting data from BAM file using R tools
0
gravatar for Ilya IN
3.2 years ago by
Ilya IN0
Belarus/Minsk/Belarusian State University
Ilya IN0 wrote:

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!

myposts rna-seq R • 1.3k views
ADD COMMENTlink modified 3.2 years ago by karimse0720 • written 3.2 years ago by Ilya IN0
0
gravatar for karimse07
3.2 years ago by
karimse0720
Egypt
karimse0720 wrote:

you can use pmax function in R for  athreshold

ADD COMMENTlink written 3.2 years ago by karimse0720

I don't see pmax working in this case!

ADD REPLYlink written 3.2 years ago by Sukhdeep Singh9.6k

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

ADD REPLYlink written 3.2 years ago by Ilya IN0
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: 780 users visited in the last hour