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.
• 0 views
•
link
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
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.
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)
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.
Log in to answer this question.