converting bam file to bed
1
0
Entering edit mode
5.3 years ago

Hi,

I am trying to convert a bam file to a bed file using R software however, I am currently unsuccessful. The below is what I have inputted so far in R-software can anyone help me please?

#load library
library(Rsamtools)
library(RNAseqData.HNRNPC.bam.chr14)
library(GenomicAlignments)
bamfile <- file.path("C:","Users","azzop","Desktop","I16-1144-01-esd_m1_CGCTCATT-AGGCGAAG_tophat2","accepted_hits.bam")

system(paste("bedtools bamtobed -i", bamfile, "> myBed.bed"))
library(data.table)
myData <- fread("myBed.bed")

Does anyone know how I can use the package bedtools in R? What am I doing is it correct?

Also, my goal is to combine more than 1 bam file together as I have 9 bam files and I would need to analyze the data holistically? Any suggestions?

Thanks, A

R • 4.9k views
ADD COMMENT
0
Entering edit mode

The first question would be why you are trying to do this in R... Looks you are using windows, can you use the WSL/Ubuntu?

ADD REPLY
0
Entering edit mode

Yes I am using windows as this is part of my dissertation for MSc in statistics and I will be using R stoftware to analyze the data

ADD REPLY
2
Entering edit mode

If you are using Windows 10 I recommend WSL: the Windows Subsystem for Linux. That will make your work a lot easier.

R is a programming language. While you technically can execute bedtools through R you are then no longer using R itself. It's just a vehicle to execute bedtools and it adds an unnecessary layer of complexity.

ADD REPLY
1
Entering edit mode
5.3 years ago

Via BEDOPS:

$ bam2bed < reads.bam > reads.bed
ADD COMMENT

Login before adding your answer.

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