avoid jumping around wd in the psichomics modules
I wonder if the following script can be changed to get rid of setwd so that the wd will not be messed up so easily and give us a headache.
for (f in c(${_input:ar,})){
filename = gsub("^.*/", "", f)
directory = gsub(filename, "", f)
if (length(files[[directory]]) == 0){
files[[directory]] = filename
} else {
files[[directory]] = append(files[[directory]], filename)
}
}
if (length(files) == 1) {
setwd(names(files)[1])
res = prepareJunctionQuant(files[[1]])
} else {
res = list()
for (i in 1:(length(files))) {
d = names(files[i])
setwd(d)
res[[d]] = prepareJunctionQuant(files[[d]])
}
res = res %>% reduce(full_join, by = "Junction ID")
}
res[is.na(res)] <- 0
I think i know the answer to this but let me defer that to @Rhopala . The lesson here is that for unconventional behavior like this, @Rhopala you should add a line of comment in the code so others don't have to raise this question but instead can see how they can help ipmrove it.
@hsun3163 we can always let SoS change paths to absolute path eg some_dir = f"{some_dir:a}"
@hsun3163 This is for solving another headache. I am not sure if you know there once was a too-long-command problem: R R have an input length limit and the psichomics teams just write their prepareJunctionQuant() function input as (full/path/file1.bam, full/path/file2.bam, full/path/file3.bam ... full/path/file1n.bam) so the real data on BU's end can't be read in the same time. So the setwd codes there get rid of the "full/path"s and allows taking more input since now it only read file names.
@gaow Yeah I'll add comments for that problem