I'm trying to analyze bam files using the csaw package. One of the first steps is to provide your the path to individual bam files, as shown in the csaw manual, page 8. Here is a screen cap from the csaw manual illustrating the expected format of the bam.files variable:
I have created a csv file, "bamdata.csv' using bash. It contains two columns with headers "Name" and "Path". The complete path to each bam file is provided under Path, and resemble /path/to/file/sample1.bam
bam.csv <- read.csv("bamdata.csv", header=TRUE)
bam.files <- head(bam.data$Path, -11) # skip controls
bam.files
[1] /Volumes/EasyStore/2019-07-01QUESTAnalysis/BAMSorted/ACT20minSorted.bam
[2] /Volumes/EasyStore/2019-07-01QUESTAnalysis/BAMSorted/ACT212minSorted.bam
...
[75] /Volumes/EasyStore/2019-07-01QUESTAnalysis/BAMSorted/REP13minSorted.bam
86 Levels: /Volumes/EasyStore/2019-07-01QUESTAnalysis/BAMSorted/ACT20minSorted.bam
max.delay <- 2000
dedup.param <- reform(discard.param, dedup=TRUE)
frag.avg <- correlateReads(bam.files, max.delay, param=dedup.param)
Output: Error in path.expand(bam.file) : invalid 'path' argument
I also tried adding " " around the path, such as:
[1] "/Volumes/EasyStore/2019-07-01QUESTAnalysis/BAMSorted/ACT20minSorted.bam"
[2] "/Volumes/EasyStore/2019-07-01QUESTAnalysis/BAMSorted/ACT212minSorted.bam"
...
[75] "/Volumes/EasyStore/2019-07-01QUESTAnalysis/BAMSorted/REP13minSorted.bam"
86 Levels: "/Volumes/EasyStore/2019-07-01QUESTAnalysis/BAMSorted/ACT20minSorted.bam"
Output: Error in value[3L] : failed to open BamFile: file(s) do not exist: '"/Volumes/EasyStore/2019-07-01QUESTAnalysis/BAMSorted/ACT20minSorted.bam"'
However, this is a valid path. I've tried moving my working directory to the location of bam files - no luck.
Does anyone see an issue with the way I'm providing the paths to my bam files?
Thanks Martin, this was the issue; I needed my data frame content to be "character" type.
For anyone else that might come upon this issue, you can use the following code to convert your read-in csv file to character form:
Output: Name Path "character" "character"