This is a test version of Biostars. For the public version, visit https://www.biostars.org.
R : File Do Not Exists Error. Isilon File Path Not Recognized In R

I am trying to run ExomeDepth R package

BAM_set1<-c("/path_to_folder/Sample1.bam")
Set1_CountData<-getBamCounts(bed.frame=exons.hg19, bam.files=BAM_set1)

Parse 1 BAM files
[1] "/path_to_folder/Sample1.bam"
Error in .io_check_exists(path(con)) : file(s) do not exist:
  "/path_to_folder/Sample1.bam"

getwd()
[1]    "/path_to_folder/"

Getting the following error. But in R I am in the right folder where my BAMs are present and also have given the entire path to the file when giving BAM list. Have uploaded all the dependent libraries for running ExomeDepth and R version 2.15.1 (2012-06-22) Platform: x86_64-redhat-linux-gnu (64-bit)

Any help much appreciated !!

Thanks, Tinu

r

Is the output from getwd() literally /path_to_folder/? That would mean you have created a folder called path_to_folder in your file system root (/), not really a conventional place to store some bam-file. Can you post the output of dir()?

And can you open a command terminal and post the output of ls -l /path_to_folder

Thanks for the response !!

Output from getwd() is not literally '/path_to_folder', for simplicity wrote so. It is actually a mount point from isilon.

dir()
Sample1.bam
Sample1.bai
Sample2.bam
Sample2.bai

And ls -l '/path_to_folder' gets me list of my BAM files

But what are the file permissions of the files in /path_to_folder?

rwxrwxrwx for all BAM files

I have the impression that the R environment you are working in has problems connecting to your isolon NAS. Can you open or import any file that is on the isolon?

I tried importing a text file in isilon path and it worked

If you type the following, do you get a number after the 2nd line? This basically just checks that R can actually open the file for reading.

fp <- file(BAM_set1,"rb")
readBin(fp, integer())
close(fp)
fp<-file(BAM_set1,"rb")
Error in file(BAM_set1, "rb") : cannot open the connection
In addition: Warning message:
In file(BAM_set1, "rb") :
  cannot open file '/path_to_folder/Sample1.bam': No such file or directory

Then as Irsan suggested, either there's a typo in BAM_set1, or there's some sort of filesystem issue going on. Can you "samtools view Sample1.bam" successfully from the command line?

I am able to see BAM file contents using samtools view command. Looks like it is an issue with the filesystem

Does seidel's example of setting BAM_set1 via a call to dir() fix the problem? If so, then this is just a typo issue. That'd be a much easier fix :)

Yes it worked. I used the following lines

BAM_set1<-dir(pattern=".bam$")
set1_CountData<-getBamCounts(bed.frame=exons.hg19, bam.files=BAM_set1)

Sounds like you had a typo then.

1 answer

If getwd() is actually:

[1]    "/path_to_folder/"

Then you don't need to put /path_to_folder/ in BAM_set1<-c("/path_to_folder/Sample1.bam") because you are already in the folder with the BAM files. This is further evident since dir() gives you:

Sample1.bam Sample1.bai Sample2.bam Sample2.bai

So

BAM_set1<- dir(pattern=".bam$")
Set1_CountData<-getBamCounts(bed.frame=exons.hg19, bam.files=BAM_set1)

should suffice.

Changing an absolute to a relative path shouldn't make a difference, though setting BAM_set1 from dir() should fix any typo issues :)

Thank you all for the support !!!

Log in to answer this question.