Is the error (failed to open BamFile) I'm getting a result of corrupted files? Or could there be an issue with my code?

Viewed 445
#---> Locate and read in the bam files

bamfiles <- dir(file.path("C:/Users/Desktop/Research/Summer 2020/BAMRnaSeq1/Local alignment"), ".bam")
file.exists(bamfiles)

Output: [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

#---> Define bam files for count step on Rsamtools

library("Rsamtools")
bamfiles <- BamFileList(bamfiles, yieldSize=2000000)


#---> Check correct chr names

seqinfo(bamfiles[1])

Output:

Error in value[[3L]](cond) : 
  failed to open BamFile: failed to open SAM/BAM file
  file: 'CD8-O-Hi_21_II_19_local.bam'

Could there be something wrong with my code, or is it most likely the file that isn't working? Given the fact that it first said All True for the file.exists, I don't see why the seqinfo isn't reading the bamfiles.

0 Answers
Related