Question: Rsamtools: system.file no file found
0
gravatar for seungjoon.kim
2.0 years ago by
Berlin
seungjoon.kim0 wrote:

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 • 1.3k views
ADD COMMENTlink modified 2.0 years ago by Martin Morgan ♦♦ 23k • written 2.0 years ago by seungjoon.kim0
Answer: Rsamtools: system.file no file found
0
gravatar for Martin Morgan
2.0 years ago by
Martin Morgan ♦♦ 23k
United States
Martin Morgan ♦♦ 23k wrote:

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 COMMENTlink written 2.0 years ago by Martin Morgan ♦♦ 23k

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 REPLYlink written 2.0 years ago by seungjoon.kim0

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 REPLYlink written 2.0 years ago by Martin Morgan ♦♦ 23k

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 REPLYlink written 24 months ago by seungjoon.kim0

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

ADD REPLYlink written 24 months ago by Martin Morgan ♦♦ 23k
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 16.09
Traffic: 261 users visited in the last hour