csaw: Error in path.expand(bam.file) : invalid 'path' argument
1
1
Entering edit mode
vanbelj ▴ 30
@vanbelj-21216
Last seen 10 months ago
United States

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: enter image description here

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?

csaw software error • 1.8k views
ADD COMMENT
5
Entering edit mode
@martin-morgan-1513
Last seen 5 months ago
United States

I think this is because your data frame has the file paths represented as a factor(), rather than character()

> path.expand(x)
[1] "/tmp/mylib/"
> path.expand(factor(x))
Error in path.expand(factor(x)) : invalid 'path' argument
ADD COMMENT
0
Entering edit mode

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:

#Read in csv file with sample name and path
bam.csv <- read.csv("bamdata.csv", header=TRUE)
bam.csv[, ] <- lapply(bam.csv[, ], as.character) #convert to character dataframe
sapply(bam.csv, class)

Output: Name Path "character" "character"

ADD REPLY

Login before adding your answer.

Traffic: 377 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6