diff --git a/R/api.R b/R/api.R index c0a988147b9a23b51b53e537d50759f1c8d8a31a..a75128e63640f31d2d9485da8d976dfa7257266b 100644 --- a/R/api.R +++ b/R/api.R @@ -39,7 +39,7 @@ run <- function(project="",m=NULL,phases=NULL,help=F) { m <- if (nchar(project)!=0) new_project(project) else if (!is.null(m)) m else stop("(run): Either the YAML config file (project),\n or the starting state (m) must be provided\n as the argument to the run function.") ## m$conf$project <- normalizePath(m$conf$project) #FIXME: Test in all workflows! - m <- withr::with_dir(new=m$conf$paths$project,code = Reduce(function (prev,f) f(prev), + m <- withr::with_dir(new=m$run$paths$project,code = Reduce(function (prev,f) f(prev), x = the_phases, init = m)) return(invisible(m)) @@ -76,7 +76,7 @@ run_in_dir <- function(m) { load_compound_input <- function(m) { coll <- list() fields <- colnames(EMPTY_CMPD_LIST) - fns <- m$conf$paths$compounds$lists + fns <- m$run$paths$compounds$lists coltypes <- c(ID="character", SMILES="character", Formula="character", @@ -119,14 +119,14 @@ load_compound_input <- function(m) { cmpds[,("known"):=.(the_ifelse(!is.na(SMILES),"structure",the_ifelse(!is.na(Formula),"formula","mz")))] m$input$tab$cmpds <- cmpds - m$input$tab$setid <- read_setid(m$conf$paths$compounds$sets, + m$input$tab$setid <- read_setid(m$run$paths$compounds$sets, m$input$tab$cmpds) m } ##' @export load_data_input <- function(m) { - m$input$tab$mzml <- file2tab(m$conf$paths$datatab) + m$input$tab$mzml <- file2tab(m$run$paths$datatab) assert(all(unique(m$input$tab$mzml[,.N,by=c("adduct","tag")]$N)<=1),msg="Some rows in the data table contain multiple entries with same tag and adduct fields.") pref<-m$run$paths$data m$input$tab$mzml[,file:=fifelse(file.exists(file),file,file.path(..pref,file))] @@ -661,14 +661,14 @@ create_plots <- function(m) { plot_save_single(p_eic, decotab = select, figtag = "eic", - proj = m$conf$project, + proj_path = m$run$paths$project, tabl = tabl_ms1, extension = m$conf$figures$ext) plot_save_single(p_spec, decotab = select, figtag = "spec", - proj = m$conf$project, + proj_path = m$run$paths$project, tabl = tabl_spec, extension = m$conf$figures$ext) message("Plotting of figure ",n," out of ",NROW(keytab)," has been completed.") diff --git a/R/plotting.R b/R/plotting.R index 5b35684aef8239e702aa66f29d5b613e507e6b34..7ca4654025b74e0145b7f07e1f40f5362fcad565 100644 --- a/R/plotting.R +++ b/R/plotting.R @@ -298,7 +298,7 @@ table_spec <- function(pdata) { tbl } -plot_fname_prefix <- function(decotab,proj,subdir=FIG_TOPDIR) { +plot_fname_prefix <- function(decotab,proj_path,subdir=FIG_TOPDIR) { if (NROW(decotab)==0) return() adducts <- decotab[,adduct] ids <- decotab[,ID] @@ -310,7 +310,7 @@ plot_fname_prefix <- function(decotab,proj,subdir=FIG_TOPDIR) { fname <- paste(fname,chunk,sep = "_") } - ddir <- file.path(proj,subdir) + ddir <- file.path(proj_path,subdir) if (!dir.exists(ddir)) dir.create(ddir,recursive = T) fname <- paste0(fname,"__id_") @@ -321,10 +321,10 @@ plot_fname_prefix <- function(decotab,proj,subdir=FIG_TOPDIR) { } -plot_save_single <- function(plot,decotab,extension,proj,subdir=FIG_TOPDIR,tabl=NULL,figtag="") { +plot_save_single <- function(plot,decotab,extension,proj_path,subdir=FIG_TOPDIR,tabl=NULL,figtag="") { if (is.null(plot)) return() - fname <- plot_fname_prefix(decotab,proj,subdir=subdir) + fname <- plot_fname_prefix(decotab,proj_path,subdir=subdir) fnplot <- paste0(fname,"__",figtag,".",extension)