Commit dc229aaf authored by Todor Kondic's avatar Todor Kondic

Merge branch 'devel' into 'master'

Devel

See merge request !4
parents ccf614a9 a978228c
Package: shinyscreen Package: shinyscreen
Title: Pre-screening of Mass Spectrometry Data Title: Pre-screening of Mass Spectrometry Data
Version: 0.1 Version: 0.3
Author: Todor Kondić Author: Todor Kondić
Maintainer: Todor Kondić <todor.kondic@uni.lu> Maintainer: Todor Kondić <todor.kondic@uni.lu>
Authors@R: Authors@R:
person(given = "Todor", c(person(given = "Todor",
family = "Kondić", family = "Kondić",
role = c("aut", "cre"), role = c("aut", "cre"),
email = "todor.kondic@uni.lu", email = "todor.kondic@uni.lu",
comment = c(ORCID = "https://orcid.org/0000-0001-6662-4375")) comment = c(ORCID = "https://orcid.org/0000-0001-6662-4375")),
person(given = "Hiba Mohammed",
family = "Taha",
role = c("ctb"),
email = "hiba.mohammed-taha@ext.uni.lu"),
person(given = "Jessy",
family = "Krier",
role = c("ctb"),
email = "jessy.krier@ext.uni.lu"),
person(given = "Mira",
family = "Narayanan",
role = c("ctb"),
email = "mira.narayanan@ext.uni.lu"),
person(given = "Anjana",
family = "Elapavalore",
role = c("ctb"),
email = "anjana.elapavalore@ext.uni.lu"))
Description: Pre-screening of Mass Spectrometry Data. Description: Pre-screening of Mass Spectrometry Data.
License: Apache License (>= 2.0) License: Apache License (>= 2.0)
Encoding: UTF-8 Encoding: UTF-8
......
# Generated by roxygen2: do not edit by hand # Generated by roxygen2: do not edit by hand
export(mb.do)
export(mb.prep)
export(presc.do) export(presc.do)
export(presc.plot) export(presc.plot)
export(sw.do)
export(presc.shiny) export(presc.shiny)
This diff is collapsed.
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
##' @author Todor Kondić ##' @author Todor Kondić
attch<-function(...) paste(...,sep='') attch<-function(...) paste(...,sep='')
##' Do the prescreening. ##' Do the prescreening.
##' ##'
##' @title Prescreening on bunch of files. ##' @title Prescreening on bunch of files.
...@@ -44,140 +43,3 @@ presc.do<-function(fn_data,fn_cmpd_l,mode,dest=".",proc=F,...) { ...@@ -44,140 +43,3 @@ presc.do<-function(fn_data,fn_cmpd_l,mode,dest=".",proc=F,...) {
} }
} }
##' Performs massbank workflow on multiple mzML files:
##'
##'
##' 1. Create rdir if it does not exist.
##'
##' 2. Generate data subdirectories inside `rdir` that will be used to
##' keep the processed data belonging to a particular mzML file in
##' the fileset.
##'
##' 3. Generate the full RMassBank settings files by merging the
##' sections from the `fn_cmpd_list` with the defaults and place those
##' new settings files in the appropriate data subdirs.
##'
##' 4. Finally perform the spectral workflow on each data file and
##' place the results in the data subdirs.
##'
##' @title Perform MassBank Workflow on Multiple Compound Mixtures
##' @param fn_data List of mzML data filenames to be processed.
##' @param fn_cmpd_l Compound list.
##' @param mode as in msmsRead.
##' @param dest The destination data directory.
##' @param combine If TRUE, use combineMultiplicies to merge
##' workspaces corresponding to different collisional energies.
##' @param proc Split work between this amount of processes. If FALSE
##' (or, 1), run sequential.
##' @param split This is the last step before combine
##' @return A named list of msmsWorkspace objects.
##' @author Todor Kondić
##' @export
sw.do <- function(fn_data, fn_cmpd_l, mode, dest=".", combine=F,
proc=F,split=3) {
conf(fn_data,fn_cmpd_l,dest)
fread <- function(fn_data) {
wd <- fn_data2wd(fn_data,dest)
reconf(wd)
w <- RMassBank::newMsmsWorkspace()
RMassBank::msmsRead(w=w,filetable = get_ftable_fn(wd),
mode=mode,readMethod = "mzR")
}
fwork <- Vectorize(function(w,wd,steps) {
archdir <- file.path(wd,"archive")
no_drama_mkdir(archdir)
fn_arch <- file.path(archdir,"archive")
reconf(wd)
RMassBank::msmsWorkflow(w=w,mode=mode,steps=steps,archivename = fn_arch)
}, vectorize.args = c("w","wd"),SIMPLIFY=F)
w <- if (proc) {
cl=parallel::makeCluster(proc)
parallel::clusterEvalQ(cl,library(shinyscreen))
parallel::clusterMap(cl,fread,fn_data)
} else {
lapply(fn_data,fread)
}
wd <- fn_data2wd(fn_data,dest)
w <- fwork(w,wd,steps=2:split)
if (combine) {
## Combined workflow is not based on a single file, but the
## functions that generate config are. Therefore, lets create
## a fake filename.
fakefile <- "combine.mzML"
cwd <- fn_data2wd(fakefile,dest)
xx <- get_stgs_fn(wd[[1]])
file.copy(xx,"combine.ini",overwrite = T)
# mk_combine_file(get_stgs_fn(wd),"combine.ini")
conf(fakefile,fn_cmpd_l,dest)
reconf(cwd)
w <- list(RMassBank::combineMultiplicities(w))
wd <- list(cwd)
}
w <- fwork(w,wd,steps=(split+1):8)
names(w) <- wd
w
}
##' Creates and prepares mbWorkspace objects before the full workflow
##' is performed on them. In process, create directory `info` as a
##' subdir of any particular data dir and place the starting info list
##' there.
##'
##'
##' @title Prepare mbWorkspace objects
##' @param w A list of spectral workspace inputs.
##' @return Named list of prepared mbWorkspace objects.
##' @author Todor Kondić
##' @export
mb.prep<-function(w) {
wd <- names(w)
fwork <- Vectorize(function(w,wd) {
reconf(wd)
idir <- gen_info_dir(wd)
mb <- RMassBank::newMbWorkspace(w)
RMassBank::resetInfolists(mb)
RMassBank::mbWorkflow(mb,infolist_path = get_info_fn(wd))
},vectorize.args = c("w","wd"))
mb <- fwork(w,wd)
names(mb) <- wd
mb
}
##' Perform the Mass Bank workflow on the prepared mbWorkspace
##' objects. FOR THE RECORD: writing documentation is boring. Anyway,
##' record results in the info subfolder of each data subdir.
##'
##'
##' @title Perform the Mass Bank workflow
##' @param mb The list of prepared mbWorkspace objects.
##' @param proc Split work between this amount of processes. If FALSE
##' (or, 1), run sequential.
##' @return The named list of processed mbWorkspace objects.
##' @author Todor Kondić
##' @export
mb.do<-function(mb,proc=F) {
wd <- names(mb)
infodir <- get_info_dir(wd)
fwork <- Vectorize(function(mb,id,wd) {
reconf(wd)
mb <- RMassBank::resetInfolists(mb)
mb <- RMassBank::loadInfolists(mb,id)
dcur <- setwd(id)
mb <- RMassBank::mbWorkflow(mb,step=1:8)
setwd(dcur)
mb},vectorize.args = c("mb","id","wd"))
if (proc) {
cl<-parallel::makeCluster(proc)
parallel::clusterEvalQ(cl,library("shinyscreen"))
parallel::clusterMap(cl,fwork,mb,infodir,wd)
} else {
fwork(mb,infodir,wd)
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/run.R
\name{mb.do}
\alias{mb.do}
\title{Perform the Mass Bank workflow}
\usage{
mb.do(mb, proc = F)
}
\arguments{
\item{mb}{The list of prepared mbWorkspace objects.}
\item{proc}{Split work between this amount of processes. If FALSE
(or, 1), run sequential.}
}
\value{
The named list of processed mbWorkspace objects.
}
\description{
Perform the Mass Bank workflow on the prepared mbWorkspace
objects. FOR THE RECORD: writing documentation is boring. Anyway,
record results in the info subfolder of each data subdir.
}
\author{
Todor Kondić
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mix.R
\name{mb.p}
\alias{mb.p}
\title{Parallel Mass Bank Workflow}
\usage{
mb.p(mb, infodir, fn_stgs, cl = F)
}
\arguments{
\item{mb}{List of mass bank workflow objects}
\item{infodir}{List of subdirs containing info lists.}
\item{fn_stgs}{List of settings files.}
\item{cl}{Cluster.}
}
\value{
A named list of mbWorkspace objects. The names are derived
from the input mb sequence.
}
\description{
Interface to parallelised Mass Bank workflow.
}
\author{
Todor Kondić
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/run.R
\name{mb.prep}
\alias{mb.prep}
\title{Prepare mbWorkspace objects}
\usage{
mb.prep(w)
}
\arguments{
\item{w}{A list of spectral workspace inputs.}
}
\value{
Named list of prepared mbWorkspace objects.
}
\description{
Creates and prepares mbWorkspace objects before the full workflow
is performed on them. In process, create directory \code{info} as a
subdir of any particular data dir and place the starting info list
there.
}
\author{
Todor Kondić
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mix.R
\name{mb.v}
\alias{mb.v}
\title{Vectorised Mass Bank Workflow}
\usage{
mb.v(mb, infodir, fn_stgs)
}
\arguments{
\item{mb}{List of mass bank workflow objects}
\item{infodir}{List of subdirs containing info lists.}
\item{fn_stgs}{List of settings files.}
}
\value{
A named list of mbWorkspace objects. The names are derived
from the input mb sequence.
}
\description{
Interface to vectorised Mass Bank workflow.
}
\author{
Todor Kondić
}
...@@ -4,16 +4,18 @@ ...@@ -4,16 +4,18 @@
\alias{presc.plot} \alias{presc.plot}
\title{Plot the Output of Prescreen} \title{Plot the Output of Prescreen}
\usage{ \usage{
presc.plot(wd, mode, out = "prescreen.pdf", pal = "Dark2", presc.plot(prescdf, mode, out = "prescreen.pdf", fn_cmpd_l,
cex = 0.75, rt_digits = 2, m_digits = 4) pal = "Dark2", cex = 0.75, rt_digits = 2, m_digits = 4)
} }
\arguments{ \arguments{
\item{wd}{Sequence of data dirs containing the prescreen subdir.} \item{prescdf}{File table data-frame. See presc.shiny for details.}
\item{mode}{RMB mode.} \item{mode}{RMB mode.}
\item{out}{The name of the output file.} \item{out}{The name of the output file.}
\item{fn_cmpd_l}{The compound list name.}
\item{pal}{ColorBrewer palette name.} \item{pal}{ColorBrewer palette name.}
\item{cex}{As in legend.} \item{cex}{As in legend.}
...@@ -22,6 +24,8 @@ presc.plot(wd, mode, out = "prescreen.pdf", pal = "Dark2", ...@@ -22,6 +24,8 @@ presc.plot(wd, mode, out = "prescreen.pdf", pal = "Dark2",
\item{m_digits}{Number of digits after the point for the mass.} \item{m_digits}{Number of digits after the point for the mass.}
\item{wd}{Sequence of data dirs containing the prescreen subdir.}
\item{digits}{Number of significant digits for peak ret times.} \item{digits}{Number of significant digits for peak ret times.}
} }
\value{ \value{
...@@ -32,4 +36,8 @@ Plot the output of prescreen. ...@@ -32,4 +36,8 @@ Plot the output of prescreen.
} }
\author{ \author{
Todor Kondić Todor Kondić
Mira Narayanan
Anjana Elapavalore
} }
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mix.R
\name{presc.shiny}
\alias{presc.shiny}
\title{Prescreening with Shiny}
\usage{
presc.shiny(prescdf, mode, fn_cmpd_l, pal = "Dark2", cex = 0.75,
rt_digits = 2, m_digits = 4)
}
\arguments{
\item{prescdf}{File table data-frame. Columns: Files,ID,wd,tag,set_name ...}
\item{mode}{RMassBank mode.}
\item{fn_cmpd_l}{Compound list file name.}
\item{pal}{ColorBrewer palette.}
\item{cex}{Size of fonts.}
\item{rt_digits}{Number of decimal places for the retention time.}
\item{m_digits}{Number of decimal places for the mass.}
}
\value{
Nothing useful.
}
\description{
Prescreening using shiny interface.
}
\author{
Jessy Krier
Mira Narayanan
Hiba Mohammed Taha
Anjana Elapavalore
Todor Kondić
}
...@@ -4,11 +4,13 @@ ...@@ -4,11 +4,13 @@
\alias{rendersmiles2} \alias{rendersmiles2}
\title{Turn SMILES to an Image Using Online Resource} \title{Turn SMILES to an Image Using Online Resource}
\usage{ \usage{
rendersmiles2(smiles, ...) rendersmiles2(smiles, style = "cow", ...)
} }
\arguments{ \arguments{
\item{smiles}{The SMILES string.} \item{smiles}{The SMILES string.}
\item{style}{Structure style.}
\item{...}{Hand over to renderurl.} \item{...}{Hand over to renderurl.}
} }
\value{ \value{
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/run.R
\name{sw.do}
\alias{sw.do}
\title{Perform MassBank Workflow on Multiple Compound Mixtures}
\usage{
sw.do(fn_data, fn_cmpd_l, mode, dest = ".", combine = F, proc = F,
split = 3)
}
\arguments{
\item{fn_data}{List of mzML data filenames to be processed.}
\item{fn_cmpd_l}{Compound list.}
\item{mode}{as in msmsRead.}
\item{dest}{The destination data directory.}
\item{combine}{If TRUE, use combineMultiplicies to merge
workspaces corresponding to different collisional energies.}
\item{proc}{Split work between this amount of processes. If FALSE
(or, 1), run sequential.}
\item{split}{This is the last step before combine}
}
\value{
A named list of msmsWorkspace objects.
}
\description{
Performs massbank workflow on multiple mzML files:
}
\details{
\enumerate{
\item Create rdir if it does not exist.
\item Generate data subdirectories inside \code{rdir} that will be used to
keep the processed data belonging to a particular mzML file in
the fileset.
\item Generate the full RMassBank settings files by merging the
sections from the \code{fn_cmpd_list} with the defaults and place those
new settings files in the appropriate data subdirs.
\item Finally perform the spectral workflow on each data file and
place the results in the data subdirs.
}
}
\author{
Todor Kondić
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment