Reading bam files and extratcing transcript from abm files in R
2
1
Entering edit mode
8.5 years ago
EVR ▴ 610

Hi,

I have a to read a bam file into R and extract information related to a particular transcript in bam format. In linux terminal, we can acheive this using

samtools view -bS -F 4 sorted_file.bam transcript_xx > transcript_xx.bam

How can I achieve the same thing within R. Kindly guide me. Thanks in advance

RNA-Seq bam samtools • 2.2k views
ADD COMMENT
1
Entering edit mode
8.5 years ago

You should use scanBam function from RSamtools along with GenomicRanges

E.g

what <- c("rname", "strand", "pos", "seq", "qual", "maps")
param <- ScanBamParam(what = what, flag = scanBamFlag(isUnmappedQuery = FALSE))
bam <- scanBam(bam.file, param = param)

Then use GRanges to filter for specific coordinates.

ADD COMMENT
0
Entering edit mode
8.5 years ago
venu 7.1k

First create an object with the above command and execute with system

Ex:

x="samtools view -bS -F 4 sorted_file.bam transcript_xx > transcript_xx.bam"
system(x)
ADD COMMENT
0
Entering edit mode

Hi venu,

I am aware of system() command in R. But how can can I store the output of system(x) in bam format in R.

ADD REPLY

Login before adding your answer.

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