From 88390173f09421f0c551cd5c17b4bb6f98f5dca8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Todor=20Kondi=C4=87?= <todor.kondic@uni.lu>
Date: Tue, 25 Jun 2019 08:49:39 +0200
Subject: [PATCH] Add README.org

* README.org: New file.
---
 DESCRIPTION                    |   4 +-
 NAMESPACE                      |   5 +
 R/mix.R                        | 299 ++++++++++++++++++++++++++++++++-
 R/run.R                        |  25 +++
 README.org                     |  84 ++++++---
 man/RMB_EIC_prescreen_df.Rd    |  29 ++++
 man/RMB_EIC_prescreen_intrn.Rd |  28 +++
 man/gen_cmpdl_and_load.Rd      |  24 +++
 man/gen_file_table.Rd          |  24 +++
 man/gen_stgs_and_load.Rd       |  24 +++
 man/presc.do.Rd                |  27 +++
 man/presc.p.Rd                 |  31 ++++
 man/presc.plot.Rd              |  24 +++
 man/presc.single.Rd            |  34 ++++
 man/presc.v.Rd                 |  28 +++
 15 files changed, 660 insertions(+), 30 deletions(-)
 create mode 100644 man/RMB_EIC_prescreen_df.Rd
 create mode 100644 man/RMB_EIC_prescreen_intrn.Rd
 create mode 100644 man/gen_cmpdl_and_load.Rd
 create mode 100644 man/gen_file_table.Rd
 create mode 100644 man/gen_stgs_and_load.Rd
 create mode 100644 man/presc.do.Rd
 create mode 100644 man/presc.p.Rd
 create mode 100644 man/presc.plot.Rd
 create mode 100644 man/presc.single.Rd
 create mode 100644 man/presc.v.Rd

diff --git a/DESCRIPTION b/DESCRIPTION
index 1587c58..5e2ea25 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -22,4 +22,6 @@ Collate:
 Imports: 
     RMassBank,
     parallel,
-    yaml
+    yaml,
+    mzR,
+    RColorBrewer
diff --git a/NAMESPACE b/NAMESPACE
index 3965026..0f870cc 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -2,4 +2,9 @@
 
 export(mb.do)
 export(mb.prep)
+export(presc.do)
+export(presc.p)
+export(presc.plot)
+export(presc.single)
+export(presc.v)
 export(sw.do)
diff --git a/R/mix.R b/R/mix.R
index 2e5483e..b4716b5 100644
--- a/R/mix.R
+++ b/R/mix.R
@@ -86,12 +86,103 @@ gen_comp_list<-function(src_fn,dest_fn) {
     ## CAS
     casvals<-if ("CASRN" %in% names(df)) df$CASRN else rep(NA,sz)
     if (is.null(haha)) stop("Unable to read SMILES from the input compound list.")
-
     outdf<-data.frame(ID=1:sz,Name=nms,SMILES=haha,CAS=casvals,RT=rep(NA,sz))
     write.csv(outdf,file=dest_fn,row.names=F,na="")
     length(nms)
 }
 
+##' Generates settings file and loads it.
+##'
+##' 
+##' @title Generate and Load the RMassBank Settings File
+##' @param fn_data The mzML filename.
+##' @param stgs Settings named list, or a settings filename.
+##' @param wd Directory under which results are archived.
+##' @return result of RMassBank::loadRmbSettings
+##' @author Todor Kondić
+gen_stgs_and_load <- function(fn_data,stgs,wd) {
+    wd <- normalizePath(wd)
+    fn_data <- normalizePath(fn_data)
+    stgs<-if (is.character(stgs)) yaml::yaml.load_file(stgs) else stgs
+    sfn<-file.path(wd,paste(basename(fn_data),".ini",sep=''))
+    mk_sett_file(stgs,sfn)
+    RMassBank::loadRmbSettings(sfn)
+}
+
+##' Generates the RMassBank compound list and loads it.
+##'
+##' 
+##' @title Generate and Load the RMassBank Compound List
+##' @param fn_data The mzML filename.
+##' @param wd Directory under which results are archived.
+##' @return Named list. The key `fn_cmpdl` is the path of the
+##'     generated compound list and the key `n` the number of
+##'     compounds.
+##' @author Todor Kondić
+gen_cmpdl_and_load <- function(fn_data,wd,fn_cmpdl) {
+    wd <- normalizePath(wd)
+    fn_data <- normalizePath(fn_data)
+    fn_comp<-file.path(wd,paste(basename(fn_data),".comp.csv",sep=''))
+    n_cmpd<-gen_comp_list(fn_cmpdl,fn_comp)
+    RMassBank::loadList(fn_comp)
+    list(fn_cmpdl=fn_comp,n=n_cmpd)
+}
+
+##' Generates file table.
+##'
+##' 
+##' @title Generate and Load the RMassBank Settings File
+##' @param fn_data The mzML filename.
+##' @param n_cmpd Number of compounds.
+##' @param wd Directory under which results are archived.
+##' @return File path of the file table.
+##' @author Todor Kondić
+gen_file_table <- function(fn_data,n_cmpd,wd) {
+    wd <- normalizePath(wd)
+    fn_data <- normalizePath(fn_data)
+    df_table<-data.frame(Files=rep(fn_data,n_cmpd),ID=1:n_cmpd)
+    fn_table<-file.path(wd,paste("fn-table.",basename(fn_data),".csv",sep=''))
+    write.csv(x=df_table,file=fn_table,row.names=F)
+    fn_table
+}
+
+##' Wrapper for a single prescreening call. Produces output in the
+##' usual mix method places.
+##'
+##' @title Wrapper for RMB_EIC_Prescreen
+##' @param fn_data The mzML filename.
+##' @param stgs_alist Settings named list, or a settings filename.
+##' @param wd Directory under which results are archived.
+##' @param mode RMB mode. 
+##' @param fn_cmpd_l Filename of the compound list.
+##' @param ppm_lim_fine The ppm_limit_fine argument to RMB_EIC_Prescreen
+##' @param EIC_limit Passed down to RMB_EIC_Prescreen.
+##' @return result of RMB_EIC_Prescreen
+##' @author Todor Kondić
+##' @export
+presc.single <- function(fn_data,stgs_alist,wd,mode,fn_cmpd_l,ppm_lim_fine=10,EIC_limit=0.001) {
+    no_drama_mkdir(wd)
+    wd <- normalizePath(wd)
+    gen_stgs_and_load(fn_data,stgs_alist,wd)
+    
+    ## Generate and load the compound list.
+    x <- gen_cmpdl_and_load(fn_data,wd,fn_cmpd_l)
+    fn_comp <- x$fn_cmpdl
+    n_cmpd <- x$n
+
+    ## Generate file table.
+    fn_table <- gen_file_table(fn_data,n_cmpd,wd)
+
+    #curd <- setwd(wd)
+    res <-RMB_EIC_prescreen_df(wd=wd,RMB_mode=mode, FileList=fn_table,
+                               cmpd_list=fn_comp,
+                               ppm_limit_fine=ppm_lim_fine,
+                               EIC_limit=EIC_limit)
+    #setwd(curd)
+    res
+
+}
+
 ##' Runs a compound mixture workflow on a single mzML file.
 ##' 
 ##' @title RMassBank Spectral Workflow on a Single Compound Mixture
@@ -196,8 +287,24 @@ mb.single<-function(mb,infodir,fn_stgs) {
     res
 }
 
-
-
+##' Vectorises presc.single.
+##'
+##' @title Vectorises presc.single
+##' @param fn_data Sequence of mzML filenames.
+##' @param fn_cmpd_l Compound list filename.
+##' @param mode RMB mode.
+##' @param ppm_lim_fine Prescreen fine limit (see ReSOLUTION prescreening function).
+##' @param EIC_limit Prescreen EIC limit (see ReSOLUTION prescreening function).
+##' @return Nothing useful.
+##' @author Todor Kondić
+##' @export
+presc.v<-function(fn_data,fn_cmpd_l,mode,ppm_lim_fine=10,EIC_limit=0.001) {
+    idir<-function(n) file.path(".",stripext(n))
+    wd <- sapply(fn_data,idir)
+    stgs_alist <- sapply(wd,function(d) {paste(d,".ini",sep='')})
+    f<-Vectorize(presc.single,vectorize.args=c("fn_data","stgs_alist","wd"),SIMPLIFY=F)
+    f(fn_data,stgs_alist,wd,mode=mode,fn_cmpd_l=fn_cmpd_l,ppm_lim_fine=ppm_lim_fine,EIC_limit=EIC_limit)
+}
 
 
 ##' Interface to vectorised spectral workflow.
@@ -247,6 +354,191 @@ v<-function(fn_data,stgs_alist,wd,fn_cmpd_list,mode,readMethod="mzR",archdir="ar
     }
 }
 
+##' Prescreens. Writes data out. Adapted from ReSOLUTION
+##'
+##' 
+##' @title Prescreen
+##' @param wd Absolute path to the directory that will contain the
+##'     resulting data frame.
+##' @param RMB_mode ...
+##' @param FileList ...
+##' @param cmpd_list ...
+##' @param ppm_limit_fine ...
+##' @param EIC_limit ...
+##' @author Emma Schymanski, Todor Kondić
+RMB_EIC_prescreen_df <- function (wd, RMB_mode, FileList, cmpd_list,
+                                  ppm_limit_fine = 10, EIC_limit = 0.001) {
+
+
+    n_spec <- 0
+    cmpd_RT_maxI <- ""
+    msms_found <- ""
+    rts <- 0
+    max_I_prec <- ""
+    cmpd_RT_maxI_min <- ""
+    file_list <- read.csv(FileList, stringsAsFactors = FALSE)
+    cmpd_info <- read.csv(cmpd_list, stringsAsFactors = FALSE)
+    ncmpd <- nrow(cmpd_info)
+    odir=file.path(wd,"prescreen")
+    no_drama_mkdir(odir)
+    get_width <- function(maxid) {log10(maxid)+1}
+    id_field_width <- get_width(ncmpd)
+
+    fn_out<- function(id,suff) {file.path(odir,paste(formatC(id,width=id_field_width,flag=0),suff,".csv",sep=''))}
+    f <- mzR::openMSfile(file_list$Files[1])
+    for (i in 1:length(file_list$ID)) {
+        cpdID <- file_list$ID[i]
+        n_spec <- n_spec + 1
+        smiles <- tryCatch(RMassBank::findSmiles(cpdID), error = function(e) NA)
+        if (!is.na(smiles)) {
+            mz <- as.numeric(RMassBank::findMz(cpdID, RMB_mode)[3])
+        }
+        else {
+            mz <- as.numeric(RMassBank::findMz(cpdID, RMB_mode, retrieval = "unknown")[3])
+        }
+        eic <- RMassBank::findEIC(f, mz, limit = EIC_limit)
+        msms_found[n_spec] <- FALSE
+        msms <- RMassBank::findMsMsHR.mass(f, mz, 0.5, RMassBank::ppm(mz, ppm_limit_fine, 
+                                                           p = TRUE))
+        max_I_prec_index <- which.max(eic$intensity)
+        cmpd_RT_maxI[n_spec] <- eic[max_I_prec_index, 1]
+        max_I_prec[n_spec] <- eic[max_I_prec_index, 2]
+        cmpd_RT_maxI_min[n_spec] <- as.numeric(cmpd_RT_maxI[n_spec])/60
+        ## plot.new()
+        ## plot.window(range(eic$rt), range(eic$intensity))
+        ## box()
+        ## lines(eic$intensity ~ eic$rt)
+        write.csv(x=eic[c("rt","intensity")],file=fn_out(cpdID,".eic"),row.names=F)
+        cpd_df <- data.frame("rt"=c(),"intensity"=c())
+        for (specs in msms) {
+            if (specs@found == TRUE) {
+                
+                df <- do.call(rbind, lapply(specs@children, function(sp) c(sp@rt, 
+                                                                           intensity = max(sp@intensity))))
+                cpd_df <- rbind(cpd_df,df,make.row.names = F)
+                ## lines(intensity ~ retentionTime, data = df, type = "h", 
+                ##       col = "blue")
+                msms_found[n_spec] <- TRUE
+            }
+        }
+        if (nrow(cpd_df)>0) write.csv(x=cpd_df,file=fn_out(cpdID,".kids"),row.names=F)
+        ## title(main = cpdID, xlab = "RT (sec)", ylab = "Intensity")
+        ## text(as.numeric(cmpd_RT_maxI[n_spec]), as.numeric(max_I_prec[n_spec]), 
+        ##      labels = as.numeric(cmpd_RT_maxI_min[n_spec]), pos = 4)
+        ## axis(1)
+        ## axis(2)
+        ## gc()
+        rts[i] <- (cmpd_RT_maxI[n_spec])
+    }
+    # dev.off()
+    write.csv(cbind(file_list$ID, cmpd_info$mz, cmpd_info$Name, 
+                    cmpd_RT_maxI, cmpd_RT_maxI_min, max_I_prec, msms_found), 
+              file = file.path(odir,"RTs_wI.csv"), 
+              row.names = F)
+}
+
+
+
+##' Parallel version of presc.single.
+##'
+##' @title Parallel version of presc.single
+##' @param cl Cluster object.
+##' @param fn_data Sequence of mzML files.
+##' @param fn_cmpd_l Filename of the compound list.
+##' @param mode RMB mode.
+##' @param ppm_lim_fine See ReSOLUTION.
+##' @param EIC_limit See ReSOLUTION.
+##' @return Nothing useful.
+##' @author Todor Kondić
+##' @export
+presc.p<-function(cl,fn_data,fn_cmpd_l,mode,ppm_lim_fine=10,EIC_limit=0.001) {
+    idir<-function(n) file.path(".",stripext(n))
+    wd <- sapply(fn_data,idir)
+    stgs_alist <- sapply(wd,function(d) {paste(d,".ini",sep='')})
+
+    f <- function(fn_data,stgs_alist,wd) presc.single(fn_data=fn_data,stgs_alist=stgs_alist,wd=wd,mode=mode,
+                                                      fn_cmpd_l=fn_cmpd_l,ppm_lim_fine=ppm_lim_fine,EIC_limit=EIC_limit)
+    
+    parallel::clusterMap(cl,fun=f,fn_data,stgs_alist,wd)
+    
+}
+
+
+##' Plot the output of prescreen.
+##'
+##' @title Plot the Output of Prescreen
+##' @param wd Sequence of data dirs containing the prescreen subdir.
+##' @param out The name of the output file.
+##' @param pal ColorBrewer palette name.
+##' @return Nothing useful.
+##' @author Todor Kondić
+##' @export
+presc.plot <- function(wd,out="prescreen.pdf",pal="Dark2") {
+    dfdir <- file.path(wd,"prescreen")
+    pdf(out)
+    ## Get the basenames of eic files.
+    eics <- list.files(path=dfdir[[1]],patt=".*eic.csv")
+    maybekids <- sapply(strsplit(eics,split="\\."),function(x) {paste(x[[1]][1],'.kids.csv',sep='')})
+    for (i in seq(length(eics))) {
+        eic <- eics[[i]]
+        maybekid <- maybekids[[i]]
+        fn_ini <- lapply(wd,function(x) file.path(x,list.files(path=x,patt="*.ini")[[1]]))
+        
+        lbls <- lapply(fn_ini,function(x) {s <- yaml::yaml.load_file(x);s$spectraList[[1]]$ce})
+        plot.new()
+        dfs <- lapply(file.path(dfdir,eic),function(fn) {
+            tryCatch(read.csv(fn,stringsAsFactors = F),
+                     error=function(e) {message(paste(e,"; offending file:",fn))})
+        })
+        
+        dfs <- lapply(dfs,function(x) data.frame(rt=x$rt/60.,intensity=x$intensity))
+
+
+        ## Find max intensities.
+        w_max <- sapply(dfs,function (x) which.max(x$intensity))
+        rt_max <- Map(function(df,w) df$rt[[w]],dfs,w_max)
+        i_max<- Map(function(df,w) df$intensity[[w]],dfs,w_max)
+
+        
+        
+        rt_rng <- range(sapply(dfs,function(x) x$rt))
+        int_rng <- range(sapply(dfs,function(x) x$intensity)) 
+        plot.window(rt_rng,c(int_rng[[1]],1.1*int_rng[[2]]))
+        box()
+        cols <- RColorBrewer::brewer.pal(n=length(dfs),name=pal)
+        legend("top",horiz=T,legend=lbls,col=cols,fill=cols)
+
+        ## Plot eic across the directory set.
+        for (n in seq(length(dfs))) {
+            df <- dfs[[n]]
+            col <- cols[[n]]
+            lines(df$intensity ~ df$rt,col=col)
+        }
+
+        ## Find existing children and plot them across the directory
+        ## set.
+        
+        maybes <- file.path(dfdir,maybekid)
+        indkids <- which(file.exists(maybes))
+        kids <- maybes[indkids]
+
+        dfs <- lapply(kids,read.csv,stringsAsFactors=F)
+        for (df in dfs) {
+            lines(intensity ~ retentionTime,data=df,type="h",col="black")
+        }
+        title(main=i,xlab="retention time [min]",ylab="intensity")
+        for (i in seq(length(w_max))) text(rt_max[[i]],i_max[[i]],labels=rt_max[[i]],pos=4)
+        axis(1)
+        axis(2)
+        gc()
+    }
+    dev.off()
+}
+
+
+
+
+
 ##' Interface to parallel spectral workflow.
 ##'
 ##' 
@@ -334,3 +626,4 @@ mb.p<-function(mb,infodir,fn_stgs,cl=F) {
     names(x)<-names(mb)
     x}
 
+
diff --git a/R/run.R b/R/run.R
index 0479082..fbc3c2f 100644
--- a/R/run.R
+++ b/R/run.R
@@ -8,6 +8,31 @@
 attch<-function(...) paste(...,sep='')
 
 
+##' Do the prescreening.
+##'
+##' @title Prescreening on bunch of files.
+##' @param fn_data The mzML files. Basis for the out directory name
+##'     generation.
+##' @param fn_cmpd_list The compound list CSV.
+##' @param mode RMB mode.
+##' @param proc Amount of processors, or FALSE. 
+##' @return Nothing useful.
+##' @author Todor Kondić
+##' @export
+presc.do<-function(fn_data,fn_cmpd_list,mode,proc=F) {
+
+
+    if (proc) {
+        cl<-parallel::makeCluster(proc,type='FORK')
+        presc.p(cl=cl,fn_data,fn_cmpd_l=fn_cmpd_list,mode=mode)
+    } else {
+        presc.v(fn_data,fn_cmpd_l=fn_cmpd_list,mode)
+    }
+}
+
+
+
+
 ##' Performs massbank workflow on multiple mzML files:
 ##'
 ##'
diff --git a/README.org b/README.org
index 1df27f2..964bb46 100644
--- a/README.org
+++ b/README.org
@@ -2,30 +2,62 @@
 
 
 * Usage
-  The entire procedure,
-  #+BEGIN_SRC: R
-  pos<-rmbmix::sw.do(list.files(patt=".*pos.mzML"),fn_cmpd_list="ChemistryDashboard-Batch-Search_2019-05-15_07_27_26.csv",mode="pH")
-  pos_pmb<-rmbmix::mb.prep(pos)
-  pos_mb<-rmbmix::mb.do(pos_pmb)
-
-  neg<-rmbmix::sw.do(list.files(patt=".*neg.mzML"),fn_cmpd_list="ChemistryDashboard-Batch-Search_2019-05-15_07_27_26.csv",mode="mH")
-  neg_pmb<-rmbmix::mb.prep(neg)
-  neg_mb<-rmbmix::mb.do(neg_pmb)
-
-  #+END_SRC
+** Prescreening
+   1. Generate prescreening data frames,
+      #+BEGIN_SRC R
+      presc.do(list.files(patt=".*mzML"),"pH",fn_cmpd_list="./Pesticides.info.csv",proc=4)
+      #+END_SRC
+      This is to be carried out inside the directory containing the
+      ~mzML~ files. For sequential execution, leave out the ~proc~
+      argument.
+   2. Plot,
+      #+BEGIN_SRC R
+      require(rmbmix)
+      presc.plot(normalizePath(list.dirs(".",recursive=F,full.names=F)))
+      #+END_SRC
+      The only argument is a sequence of absolute paths to directories
+      containing the prescreen data. The resulting plot file is going
+      to be placed into the current working directory.
+      
+      
+   
+** Record generation
+   The entire sequentual procedure,
+   #+BEGIN_SRC: R
+   pos<-rmbmix::sw.do(list.files(patt=".*pos.mzML"),fn_cmpd_list="ChemistryDashboard-Batch-Search_2019-05-15_07_27_26.csv",mode="pH")
+   pos_pmb<-rmbmix::mb.prep(pos)
+   pos_mb<-rmbmix::mb.do(pos_pmb)
+   
+   neg<-rmbmix::sw.do(list.files(patt=".*neg.mzML"),fn_cmpd_list="ChemistryDashboard-Batch-Search_2019-05-15_07_27_26.csv",mode="mH")
+   neg_pmb<-rmbmix::mb.prep(neg)
+   neg_mb<-rmbmix::mb.do(neg_pmb)
   
- The ~fn_cmpd_list~ argument is the compound list, from Chemistry
- Dashboard, or in a RMassBank format. The first argument to ~sw.do~ is
- the list of /mzML/ files containing spectral data to be processed
- using the spectral workflow. Each mzML file should have an associated
- /YAML/ file with RMassBank settings describing it. The settings file
- does not need to be complete, it can only contain the settings which
- are different from the settings template.
-
- Once the spectral workflow is complete, first run the MassBank
- preparation procedure using ~mb.prep~ function. Then, finalise the
- MassBank record workflow by using the ~mb.do~ function.
-
- The resulting record files and info lists are under
- "<data-dir>/info/XX" paths, where /data-dir/ is the mzML filename
- without the mzML suffix.
+   #+END_SRC
+   
+   The entire parallel procedure,
+   #+BEGIN_SRC: R
+   pos<-rmbmix::sw.do(list.files(patt=".*pos.mzML"),fn_cmpd_list="ChemistryDashboard-Batch-Search_2019-05-15_07_27_26.csv",mode="pH",proc=4)
+   pos_pmb<-rmbmix::mb.prep(pos)
+   pos_mb<-rmbmix::mb.do(pos_pmb,proc=4)
+   
+   neg<-rmbmix::sw.do(list.files(patt=".*neg.mzML"),fn_cmpd_list="ChemistryDashboard-Batch-Search_2019-05-15_07_27_26.csv",mode="mH",proc=4)
+   neg_pmb<-rmbmix::mb.prep(neg)
+   neg_mb<-rmbmix::mb.do(neg_pmb,proc=4)
+   
+   #+END_SRC
+   
+   The ~fn_cmpd_list~ argument is the compound list, from Chemistry
+   Dashboard, or in a RMassBank format. The first argument to ~sw.do~ is
+   the list of /mzML/ files containing spectral data to be processed
+   using the spectral workflow. Each mzML file should have an associated
+   /YAML/ file with RMassBank settings describing it. The settings file
+   does not need to be complete, it can only contain the settings which
+   are different from the settings template.
+   
+   Once the spectral workflow is complete, first run the MassBank
+   preparation procedure using ~mb.prep~ function. Then, finalise the
+   MassBank record workflow by using the ~mb.do~ function.
+   
+   The resulting record files and info lists are under
+   "<data-dir>/info/XX" paths, where /data-dir/ is the mzML filename
+   without the mzML suffix.
diff --git a/man/RMB_EIC_prescreen_df.Rd b/man/RMB_EIC_prescreen_df.Rd
new file mode 100644
index 0000000..13016b1
--- /dev/null
+++ b/man/RMB_EIC_prescreen_df.Rd
@@ -0,0 +1,29 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/mix.R
+\name{RMB_EIC_prescreen_df}
+\alias{RMB_EIC_prescreen_df}
+\title{Prescreen}
+\usage{
+RMB_EIC_prescreen_df(wd, RMB_mode, FileList, cmpd_list,
+  ppm_limit_fine = 10, EIC_limit = 0.001)
+}
+\arguments{
+\item{wd}{Absolute path to the directory that will contain the
+resulting data frame.}
+
+\item{RMB_mode}{...}
+
+\item{FileList}{...}
+
+\item{cmpd_list}{...}
+
+\item{ppm_limit_fine}{...}
+
+\item{EIC_limit}{...}
+}
+\description{
+Prescreens. Writes data out. Adapted from ReSOLUTION
+}
+\author{
+Emma Schymanski, Todor Kondić
+}
diff --git a/man/RMB_EIC_prescreen_intrn.Rd b/man/RMB_EIC_prescreen_intrn.Rd
new file mode 100644
index 0000000..ef62fcf
--- /dev/null
+++ b/man/RMB_EIC_prescreen_intrn.Rd
@@ -0,0 +1,28 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/mix.R
+\name{RMB_EIC_prescreen_intrn}
+\alias{RMB_EIC_prescreen_intrn}
+\title{Prescreen}
+\usage{
+RMB_EIC_prescreen_intrn(archive_name, RMB_mode, FileList, cmpd_list,
+  ppm_limit_fine = 10, EIC_limit = 0.001)
+}
+\arguments{
+\item{archive_name}{...}
+
+\item{RMB_mode}{...}
+
+\item{FileList}{...}
+
+\item{cmpd_list}{...}
+
+\item{ppm_limit_fine}{...}
+
+\item{EIC_limit}{...}
+}
+\description{
+Prescreens. Ripped off from ReSOLUTION
+}
+\author{
+Emma Schymanski, Todor Kondić
+}
diff --git a/man/gen_cmpdl_and_load.Rd b/man/gen_cmpdl_and_load.Rd
new file mode 100644
index 0000000..eb28d78
--- /dev/null
+++ b/man/gen_cmpdl_and_load.Rd
@@ -0,0 +1,24 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/mix.R
+\name{gen_cmpdl_and_load}
+\alias{gen_cmpdl_and_load}
+\title{Generate and Load the RMassBank Compound List}
+\usage{
+gen_cmpdl_and_load(fn_data, wd, fn_cmpdl)
+}
+\arguments{
+\item{fn_data}{The mzML filename.}
+
+\item{wd}{Directory under which results are archived.}
+}
+\value{
+Named list. The key \code{fn_cmpdl} is the path of the
+generated compound list and the key \code{n} the number of
+compounds.
+}
+\description{
+Generates the RMassBank compound list and loads it.
+}
+\author{
+Todor Kondić
+}
diff --git a/man/gen_file_table.Rd b/man/gen_file_table.Rd
new file mode 100644
index 0000000..c7daf7f
--- /dev/null
+++ b/man/gen_file_table.Rd
@@ -0,0 +1,24 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/mix.R
+\name{gen_file_table}
+\alias{gen_file_table}
+\title{Generate and Load the RMassBank Settings File}
+\usage{
+gen_file_table(fn_data, n_cmpd, wd)
+}
+\arguments{
+\item{fn_data}{The mzML filename.}
+
+\item{n_cmpd}{Number of compounds.}
+
+\item{wd}{Directory under which results are archived.}
+}
+\value{
+File path of the file table.
+}
+\description{
+Generates file table.
+}
+\author{
+Todor Kondić
+}
diff --git a/man/gen_stgs_and_load.Rd b/man/gen_stgs_and_load.Rd
new file mode 100644
index 0000000..53ee0bb
--- /dev/null
+++ b/man/gen_stgs_and_load.Rd
@@ -0,0 +1,24 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/mix.R
+\name{gen_stgs_and_load}
+\alias{gen_stgs_and_load}
+\title{Generate and Load the RMassBank Settings File}
+\usage{
+gen_stgs_and_load(fn_data, stgs, wd)
+}
+\arguments{
+\item{fn_data}{The mzML filename.}
+
+\item{stgs}{Settings named list, or a settings filename.}
+
+\item{wd}{Directory under which results are archived.}
+}
+\value{
+result of RMassBank::loadRmbSettings
+}
+\description{
+Generates settings file and loads it.
+}
+\author{
+Todor Kondić
+}
diff --git a/man/presc.do.Rd b/man/presc.do.Rd
new file mode 100644
index 0000000..f001b9b
--- /dev/null
+++ b/man/presc.do.Rd
@@ -0,0 +1,27 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/run.R
+\name{presc.do}
+\alias{presc.do}
+\title{Prescreening on bunch of files.}
+\usage{
+presc.do(fn_data, fn_cmpd_list, mode, proc = F)
+}
+\arguments{
+\item{fn_data}{The mzML files. Basis for the out directory name
+generation.}
+
+\item{fn_cmpd_list}{The compound list CSV.}
+
+\item{mode}{RMB mode.}
+
+\item{proc}{Amount of processors, or FALSE.}
+}
+\value{
+Nothing useful.
+}
+\description{
+Do the prescreening.
+}
+\author{
+Todor Kondić
+}
diff --git a/man/presc.p.Rd b/man/presc.p.Rd
new file mode 100644
index 0000000..3df93cb
--- /dev/null
+++ b/man/presc.p.Rd
@@ -0,0 +1,31 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/mix.R
+\name{presc.p}
+\alias{presc.p}
+\title{Parallel version of presc.single}
+\usage{
+presc.p(cl, fn_data, fn_cmpd_l, mode, ppm_lim_fine = 10,
+  EIC_limit = 0.001)
+}
+\arguments{
+\item{cl}{Cluster object.}
+
+\item{fn_data}{Sequence of mzML files.}
+
+\item{fn_cmpd_l}{Filename of the compound list.}
+
+\item{mode}{RMB mode.}
+
+\item{ppm_lim_fine}{See ReSOLUTION.}
+
+\item{EIC_limit}{See ReSOLUTION.}
+}
+\value{
+Nothing useful.
+}
+\description{
+Parallel version of presc.single.
+}
+\author{
+Todor Kondić
+}
diff --git a/man/presc.plot.Rd b/man/presc.plot.Rd
new file mode 100644
index 0000000..4630dd7
--- /dev/null
+++ b/man/presc.plot.Rd
@@ -0,0 +1,24 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/mix.R
+\name{presc.plot}
+\alias{presc.plot}
+\title{Plot the Output of Prescreen}
+\usage{
+presc.plot(wd, out = "prescreen.pdf", pal = "Accent")
+}
+\arguments{
+\item{wd}{Sequence of data dirs containing the prescreen subdir.}
+
+\item{out}{The name of the output file.}
+
+\item{pal}{ColorBrewer palette name.}
+}
+\value{
+Nothing useful.
+}
+\description{
+Plot the output of prescreen.
+}
+\author{
+Todor Kondić
+}
diff --git a/man/presc.single.Rd b/man/presc.single.Rd
new file mode 100644
index 0000000..4263e02
--- /dev/null
+++ b/man/presc.single.Rd
@@ -0,0 +1,34 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/mix.R
+\name{presc.single}
+\alias{presc.single}
+\title{Wrapper for RMB_EIC_Prescreen}
+\usage{
+presc.single(fn_data, stgs_alist, wd, mode, fn_cmpd_l, ppm_lim_fine = 10,
+  EIC_limit = 0.001)
+}
+\arguments{
+\item{fn_data}{The mzML filename.}
+
+\item{stgs_alist}{Settings named list, or a settings filename.}
+
+\item{wd}{Directory under which results are archived.}
+
+\item{mode}{RMB mode.}
+
+\item{fn_cmpd_l}{Filename of the compound list.}
+
+\item{ppm_lim_fine}{The ppm_limit_fine argument to RMB_EIC_Prescreen}
+
+\item{EIC_limit}{Passed down to RMB_EIC_Prescreen.}
+}
+\value{
+result of RMB_EIC_Prescreen
+}
+\description{
+Wrapper for a single prescreening call. Produces output in the
+usual mix method places.
+}
+\author{
+Todor Kondić
+}
diff --git a/man/presc.v.Rd b/man/presc.v.Rd
new file mode 100644
index 0000000..2728a2e
--- /dev/null
+++ b/man/presc.v.Rd
@@ -0,0 +1,28 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/mix.R
+\name{presc.v}
+\alias{presc.v}
+\title{Vectorises presc.single}
+\usage{
+presc.v(fn_data, fn_cmpd_l, mode, ppm_lim_fine = 10, EIC_limit = 0.001)
+}
+\arguments{
+\item{fn_data}{Sequence of mzML filenames.}
+
+\item{fn_cmpd_l}{Compound list filename.}
+
+\item{mode}{RMB mode.}
+
+\item{ppm_lim_fine}{Prescreen fine limit (see ReSOLUTION prescreening function).}
+
+\item{EIC_limit}{Prescreen EIC limit (see ReSOLUTION prescreening function).}
+}
+\value{
+Nothing useful.
+}
+\description{
+Vectorises presc.single.
+}
+\author{
+Todor Kondić
+}
-- 
GitLab