Entering edit mode
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!!
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.
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.
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)
Can you figure out what is wrong with this problem??
As before, set `bamfile` to the path of your actual file, "c:/Users/..."