Rsamtools: system.file no file found
1
0
Entering edit mode
@seungjoonkim-13660
Last seen 7.3 years ago
Berlin

Hi, I am watching Rsamtools in Coursera and I want to get Bam file to R so I used system.file and Rsamtools.

So when I ran this command:

bamPath <- system.file("extdata", "sorted_file.bam", package = "Rsamtools", mustWork = TRUE)

It gives me error with message no file found. w/o mustWork, it just gives empty data.

I checked the path by getwd() and I checked whether there is file or not.

Can anyone solve this problem? 

Thanks in advance!!

 

 

 

rsamtools bam file • 4.2k views
ADD COMMENT
1
Entering edit mode
@martin-morgan-1513
Last seen 3 months ago
United States

Probably you want to specify the path to your file, rather than to a file installed in the Rsamtools package. Something along the lines of

bamPath <- "c:/Users/mtmorgan/my_data/sorted_file.bam"
ADD COMMENT
0
Entering edit mode

Thank you!!! It works well. But a question comes out. Then, why people do

bamPath <- system.file("extdata", "sorted_file.bam", package = "Rsamtools", mustWork = TRUE)

instead of

bamPath <- "c:/Users/mtmorgan/my_data/sorted_file.bam"

Because the latter one seems more short and convenience than former one. 

ADD REPLY
0
Entering edit mode

The command `system.file()` is used to access data that is part of the package, e.g., used in the help page or vignette to show how the package is used. It is NOT meant to be used for your own data.

ADD REPLY
0
Entering edit mode

Thanks for the advice.

Specify the path to the file works well in analyzing overlap between Bam file and gene model  but I want to sort reads into groups by start position and system.file and Rsamtools gives me empty file.

bam <- readGAlignments("Aligned.out.sorted.bam")

It gives this result:

bam Large GAlignments (192883 elements, 20.4 Mb)

But when I do this....

bamfile <- system.file("extdata", "Aligned.out.sorted.bam", package = "Rsamtools")

It gives this result:

bamfile ""

So when I conduct following procedures.....

param <- ScanBamParam(what=c("seq", "qual"))
gal <- readGAlignments(bamfile, use.names = TRUE, param=param)

It gives this error:
Error in value[[3L]](cond) : 
  failed to open BamFile: file(s) do not exist:
  ''

Can you figure out what is wrong with this problem??

 

 

 


 

ADD REPLY
0
Entering edit mode

As before, set `bamfile` to the path of your actual file, "c:/Users/..."

ADD REPLY

Login before adding your answer.

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