xqtl-protocol icon indicating copy to clipboard operation
xqtl-protocol copied to clipboard

avoid jumping around wd in the psichomics modules

Open hsun3163 opened this issue 2 years ago • 4 comments

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

hsun3163 avatar Oct 05 '22 21:10 hsun3163