Skip to content
Snippets Groups Projects
Unverified Commit 9413f221 authored by Todor Kondic's avatar Todor Kondic
Browse files

api: Add sort_spectra

* R/api.R(sort_spectra): New function to sort the spectral table.

* R/resources.R(DEF_ORDER_SPECTRA): New parameter defining the default
order of the spectral table.

* NAMESPACE: Update exports.
parent 5a661fc6
No related branches found
No related tags found
No related merge requests found
# Generated by roxygen2: do not edit by hand # Generated by roxygen2: do not edit by hand
export(concurrency)
export(conf_trans) export(conf_trans)
export(extr_data) export(extr_data)
export(extract) export(extract)
...@@ -9,8 +10,10 @@ export(load_compound_input) ...@@ -9,8 +10,10 @@ export(load_compound_input)
export(load_data_input) export(load_data_input)
export(load_inputs) export(load_inputs)
export(mk_comp_tab) export(mk_comp_tab)
export(mk_tol_funcs)
export(prescreen) export(prescreen)
export(run) export(run)
export(run_in_dir) export(run_in_dir)
export(sort_spectra)
import(data.table) import(data.table)
importFrom(shiny,validate) importFrom(shiny,validate)
...@@ -172,7 +172,7 @@ verify_data <- function(conf,all_sets) { ...@@ -172,7 +172,7 @@ verify_data <- function(conf,all_sets) {
return(conf) return(conf)
} }
## @export #' @export
concurrency <- function(m) { concurrency <- function(m) {
## Reads the concurrency entry in the config. It is optional, if ## Reads the concurrency entry in the config. It is optional, if
## not given, then it is up to the user to define the plan of the ## not given, then it is up to the user to define the plan of the
...@@ -204,6 +204,7 @@ concurrency <- function(m) { ...@@ -204,6 +204,7 @@ concurrency <- function(m) {
m m
} }
#' @export
mk_tol_funcs <- function(m) { mk_tol_funcs <- function(m) {
## Depending on units given when the user specified the errors, ## Depending on units given when the user specified the errors,
## generate functions that calculate errors given the concrete ## generate functions that calculate errors given the concrete
...@@ -277,7 +278,7 @@ extr_data <- function(m) { ...@@ -277,7 +278,7 @@ extr_data <- function(m) {
msk <- sapply(tmp,future::resolved) msk <- sapply(tmp,future::resolved)
curr_done <- which(msk) curr_done <- which(msk)
names(msk) <- files names(msk) <- ftags$Files
for (x in curr_done) { for (x in curr_done) {
message("Done extraction for ", names(msk)[[x]]) message("Done extraction for ", names(msk)[[x]])
...@@ -324,3 +325,13 @@ prescreen <- function(m) { ...@@ -324,3 +325,13 @@ prescreen <- function(m) {
m$out$tab$ftab <- merge(m$out$tab$comp,m$qa$ms[,..fields],by=c("Files","adduct","ID")) m$out$tab$ftab <- merge(m$out$tab$comp,m$qa$ms[,..fields],by=c("Files","adduct","ID"))
m m
} }
##' @export
sort_spectra <- function(m) {
## Sorts the spectral table (ftab) in order specified either in
## `order spectra` sublist of m$conf, or if that is null, the
## DEF_ORDER_SPECTRA.
order <- if (!is.null(m$conf[["order spectra"]])) m$conf[["order spectra"]] else DEF_ORDER_SPECTRA
data.table::setkeyv(m$out$tab$ftab,order)
m
}
...@@ -183,3 +183,5 @@ QA_NUM_INT <- c("sel_ms2","ind_ms1_rt") ...@@ -183,3 +183,5 @@ QA_NUM_INT <- c("sel_ms2","ind_ms1_rt")
QA_COLS <- c(QA_FLAGS,QA_NUM_REAL,QA_NUM_INT) QA_COLS <- c(QA_FLAGS,QA_NUM_REAL,QA_NUM_INT)
## Default order of spectra in spectral table
DEF_ORDER_SPECTRA <- c("set","qa_pass","int_ms1","adduct","mz","tag")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment