diff --git a/NAMESPACE b/NAMESPACE index 42788a6..defb8da 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,6 +5,7 @@ export("%>%") export(create_term_match_table) export(files_in_group) export(flatten_json) +export(generate_json) export(gradient_tables) export(group_count) export(instrument_names) @@ -13,6 +14,5 @@ export(one_gradient_table) export(one_group_match_terms) export(save_all_groups) export(save_group_table) -export(use_rawMetaAsJson) importFrom(magrittr,"%<>%") importFrom(magrittr,"%>%") diff --git a/R/additional_functions.R b/R/additional_functions.R index 0a9ce3e..3a52a38 100644 --- a/R/additional_functions.R +++ b/R/additional_functions.R @@ -1,6 +1,6 @@ #' Number of groups in the json file #' -#' @param json A JSON file generated by the function "use_rawMetaAsJson()" or by using rawMetaAsJson.exe externaly. +#' @param json A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly. #' #' @return Count of groups in the JSON file. #' @@ -8,7 +8,7 @@ #' data <- system.file( #' file.path('extdata', 'testfile.raw'), #' package = 'MARMoSET', mustWork = TRUE) -#' json <- use_rawMetaAsJson(data) +#' json <- generate_json(data) #' #' group_count(json) #' @@ -24,7 +24,7 @@ group_count <- function(json) #' Filenames of one group #' -#' @param json A JSON file generated by the function "use_rawMetaAsJson()" or by using rawMetaAsJson.exe externaly. +#' @param json A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly. #' @param group_number An index that determines the group. #' #' @return A list of filenames belonging to the choosen group. @@ -33,7 +33,7 @@ group_count <- function(json) #' data <- system.file( #' file.path('extdata', 'testfile.raw'), #' package = 'MARMoSET', mustWork = TRUE) -#' json <- use_rawMetaAsJson(data) +#' json <- generate_json(data) #' #' files_in_group(json, 1) #' @@ -51,7 +51,7 @@ files_in_group <- function(json, group_number) #' Get instrument names #' -#' @param json A JSON file generated by the function "use_rawMetaAsJson()" or by using rawMetaAsJson.exe externaly. +#' @param json A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly. #' @param group_number An index that determines the group. #' #' @return A list of instruments used in the choosen group. @@ -60,7 +60,7 @@ files_in_group <- function(json, group_number) #' data <- system.file( #' file.path('extdata', 'testfile.raw'), #' package = 'MARMoSET', mustWork = TRUE) -#' json <- use_rawMetaAsJson(data) +#' json <- generate_json(data) #' #' instrument_names(json, 1) #' diff --git a/R/data.R b/R/data.R index 4204461..c11ca4f 100644 --- a/R/data.R +++ b/R/data.R @@ -11,3 +11,10 @@ #' ... #' } "tmt_list" + + +#' Already generated JSON example file. +#' +#' @format A JSON file, read by jsonlite::fromJSON() +#' +"testfile_json" diff --git a/R/gradient_functions.R b/R/gradient_functions.R index 7a10ed0..38ccb05 100644 --- a/R/gradient_functions.R +++ b/R/gradient_functions.R @@ -52,7 +52,7 @@ gradient_as_string <- function(flat_json, group_number) #' data <- system.file( #' file.path('extdata', 'testfile.raw'), #' package = 'MARMoSET', mustWork = TRUE) -#' json <- use_rawMetaAsJson(data) +#' json <- generate_json(data) #' #' flat_json <- flatten_json(json) #' @@ -94,7 +94,7 @@ one_gradient_table <- function(flat_json, group_number, lc_pump = "Thermo EASY-n #' data <- system.file( #' file.path('extdata', 'testfile.raw'), #' package = 'MARMoSET', mustWork = TRUE) -#' json <- use_rawMetaAsJson(data) +#' json <- generate_json(data) #' #' flat_json <- flatten_json(json) #' diff --git a/R/load_meta_functions.R b/R/load_meta_functions.R index 4d78c14..c9cf865 100644 --- a/R/load_meta_functions.R +++ b/R/load_meta_functions.R @@ -8,18 +8,18 @@ #' data <- system.file( #' file.path('extdata', 'testfile.raw'), #' package = 'MARMoSET', mustWork = TRUE) -#' json <- use_rawMetaAsJson(data) +#' json <- generate_json(data) #' #' @export -use_rawMetaAsJson <- function(path_data) +generate_json <- function(path_data) { new_file <- tempfile() - path_rawMetaAsJson <- system.file( - file.path('bin','rawMetaAsJson.exe'), + path_MARMoSET_exe <- system.file( + file.path('bin','MARMoSET.exe'), package = 'MARMoSET', mustWork = TRUE) - assertive.files::assert_all_are_executable_files(path_rawMetaAsJson, warn_about_windows = F) + assertive.files::assert_all_are_executable_files(path_MARMoSET_exe, warn_about_windows = F) path_data_is_ok <- function(x){ assertive.files::is_dir(x) || assertive.files::is_readable_file(x, warn_about_windows = F)} assertive.base::assert_engine( path_data_is_ok, path_data, @@ -32,7 +32,7 @@ use_rawMetaAsJson <- function(path_data) stop("Function is only working under windows.") } - system(command = paste(path_rawMetaAsJson, paste0('"',path_data, '"'), new_file), + system(command = paste(path_MARMoSET_exe, paste0('"',path_data, '"'), new_file), intern = T) json <- jsonlite::fromJSON(new_file) @@ -43,7 +43,7 @@ use_rawMetaAsJson <- function(path_data) #' flattening JSON #' -#' @param json A JSON file generated by the function "use_rawMetaAsJson()" or by using rawMetaAsJson.exe externaly. +#' @param json A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly. #' #' @return A flattened Json for better access. #' @@ -51,7 +51,7 @@ use_rawMetaAsJson <- function(path_data) #' data <- system.file( #' file.path('extdata', 'testfile.raw'), #' package = 'MARMoSET', mustWork = TRUE) -#' json <- use_rawMetaAsJson(data) +#' json <- generate_json(data) #' #' flat_json <- flatten_json(json) #' diff --git a/R/output_functions.R b/R/output_functions.R index 04ed81d..d66b8a2 100644 --- a/R/output_functions.R +++ b/R/output_functions.R @@ -8,7 +8,7 @@ #' data <- system.file( #' file.path('extdata', 'testfile.raw'), #' package = 'MARMoSET', mustWork = TRUE) -#' json <- use_rawMetaAsJson(data) +#' json <- generate_json(data) #' #' flat_json <- flatten_json(json) #' @@ -31,14 +31,29 @@ save_group_table <- function(groups_vector, output_path, group_number) assertive.files::assert_all_are_dirs(output_path %>% pathological::decompose_path() %>% .$dirname) assertive.strings::assert_all_are_non_empty_character(output_path %>% pathological::decompose_path() %>% .$filename) - if (output_path %>% pathological::decompose_path() %>% .$extension != "txt") + if (output_path %>% pathological::decompose_path() %>% .$extension %>% stringi::stri_endswith(fixed = "txt")) { - output_path %<>% pathological::decompose_path() %>% + output_path_txt <- output_path + }else + { + output_path_txt <- pathological::decompose_path(output_path) %>% magrittr::inset2('extension', value = paste(.$extension,'txt', sep = '')) %>% pathological::recompose_path() } - utils::write.table(groups_vector[[group_number]], file = output_path, sep = "\t") + utils::write.table(groups_vector[[group_number]], file = output_path_txt, sep = "\t") + + if (output_path %>% pathological::decompose_path() %>% .$extension %>% stringi::stri_endswith(fixed = "csv")) + { + output_path_csv <- output_path + }else + { + output_path_csv <- pathological::decompose_path(output_path) %>% + magrittr::inset2('extension', value = paste(.$extension,'csv', sep = '')) %>% + pathological::recompose_path() + } + + utils::write.csv(groups_vector[[group_number]], file = output_path_csv) } utils::globalVariables('.') @@ -53,7 +68,7 @@ utils::globalVariables('.') #' data <- system.file( #' file.path('extdata', 'testfile.raw'), #' package = 'MARMoSET', mustWork = TRUE) -#' json <- use_rawMetaAsJson(data) +#' json <- generate_json(data) #' #' flat_json <- flatten_json(json) #' diff --git a/R/reexports.R b/R/reexports.R index d846f41..557c150 100644 --- a/R/reexports.R +++ b/R/reexports.R @@ -1,6 +1,6 @@ #' magrittr forward-pipe operator #' -#' See \code{\link[magrittr]{\\\%>\\\%}}. +#' See \code{\link[magrittr]{\%>\%}}. #' @name %>% #' @importFrom magrittr %>% #' @export %>% @@ -8,7 +8,7 @@ NULL #' magrittr compound assignment pipe operator #' -#' See \code{\link[magrittr]{\\\%<>\\\%}}. +#' See \code{\link[magrittr]{\%<>\%}}. #' @name %<>% #' @importFrom magrittr %<>% #' @export %<>% diff --git a/R/term_matching_functions.R b/R/term_matching_functions.R index 427c881..fd43e47 100644 --- a/R/term_matching_functions.R +++ b/R/term_matching_functions.R @@ -9,7 +9,7 @@ #' data <- system.file( #' file.path('extdata', 'testfile.raw'), #' package = 'MARMoSET', mustWork = TRUE) -#' json <- use_rawMetaAsJson(data) +#' json <- generate_json(data) #' #' flat_json <- flatten_json(json) #' @@ -46,7 +46,7 @@ match_terms <- function(flat_json, term_matching_table) #' data <- system.file( #' file.path('extdata', 'testfile.raw'), #' package = 'MARMoSET', mustWork = TRUE) -#' json <- use_rawMetaAsJson(data) +#' json <- generate_json(data) #' #' flat_json <- flatten_json(json) #' diff --git a/README.Rmd b/README.Rmd index 13328c3..6c24e11 100644 --- a/README.Rmd +++ b/README.Rmd @@ -43,11 +43,11 @@ remotes::install_github('loosolab/MARMoSET', host='github.molgen.mpg.de/api/v3') ## Usage: -The c# command line tool can be used in R with `use_rawMetaAsJson()` to create a JSON file including only the meta data of grouped raw files. It takes as argument `path_data`, a path to a raw file or a directory containing raw files. +The c# command line tool can be used in R with `generate_json()` to create a JSON file including only the meta data of grouped raw files. It takes as argument `path_data`, a path to a raw file or a directory containing raw files. -This JSON file can also be created by using the rawMetaAsJson.exe externally. +This JSON file can also be created by using the MARMoSET.exe externally. -Due to the design of the RawFileReader the rawMetaAsJson.exe and therefore this command is running as 64 bit code on Windows only. To use this package with another operating system, it is necessarry to already have the JSON file created. +Due to the design of the RawFileReader the MARMoSET.exe and therefore this command is running as 64 bit code on Windows only. To use this package with another operating system, it is necessarry to already have the JSON file created. To open a JSON file in R the package `jsonlite` provides the function `fromJSON()`. ```{r} library(MARMoSET) @@ -59,7 +59,7 @@ if(.Platform$OS.type == 'windows') file.path('extdata', 'testfile.raw'), package = 'MARMoSET', mustWork = TRUE) - json <- use_rawMetaAsJson(path_data = data) + json <- generate_json(path_data = data) } else { # non windows user need to read in the JSON file here diff --git a/README.md b/README.md index 65bbad2..bf9fec4 100644 --- a/README.md +++ b/README.md @@ -36,11 +36,11 @@ remotes::install_github('loosolab/MARMoSET', host='github.molgen.mpg.de/api/v3') Usage: ------ -The c\# command line tool can be used in R with `use_rawMetaAsJson()` to create a JSON file including only the meta data of grouped raw files. It takes as argument `path_data`, a path to a raw file or a directory containing raw files. +The c\# command line tool can be used in R with `generate_json()` to create a JSON file including only the meta data of grouped raw files. It takes as argument `path_data`, a path to a raw file or a directory containing raw files. -This JSON file can also be created by using the rawMetaAsJson.exe externally. +This JSON file can also be created by using the MARMoSET.exe externally. -Due to the design of the RawFileReader the rawMetaAsJson.exe and therefore this command is running as 64 bit code on Windows only. To use this package with another operating system, it is necessarry to already have the JSON file created. +Due to the design of the RawFileReader the MARMoSET.exe and therefore this command is running as 64 bit code on Windows only. To use this package with another operating system, it is necessarry to already have the JSON file created. To open a JSON files in R the package `jsonlite` provides the function `fromJSON()`. ``` r library(MARMoSET) @@ -52,7 +52,7 @@ if(.Platform$OS.type == 'windows') file.path('extdata', 'testfile.raw'), package = 'MARMoSET', mustWork = TRUE) - json <- use_rawMetaAsJson(path_data = data) + json <- generate_json(path_data = data) } else { # non windows user need to read in the JSON file here diff --git a/inst/bin/rawMetaAsJson.exe b/inst/bin/MARMoSET.exe similarity index 50% rename from inst/bin/rawMetaAsJson.exe rename to inst/bin/MARMoSET.exe index 2054f36..1aa7459 100644 Binary files a/inst/bin/rawMetaAsJson.exe and b/inst/bin/MARMoSET.exe differ diff --git a/inst/bin/rawMetaAsJson.exe.config b/inst/bin/MARMoSET.exe.config similarity index 97% rename from inst/bin/rawMetaAsJson.exe.config rename to inst/bin/MARMoSET.exe.config index 00bfd11..731f6de 100644 --- a/inst/bin/rawMetaAsJson.exe.config +++ b/inst/bin/MARMoSET.exe.config @@ -1,6 +1,6 @@ - - - - - + + + + + \ No newline at end of file diff --git a/inst/bin/rawMetaAsJson.pdb b/inst/bin/MARMoSET.pdb similarity index 59% rename from inst/bin/rawMetaAsJson.pdb rename to inst/bin/MARMoSET.pdb index ea3eec8..42adcba 100644 Binary files a/inst/bin/rawMetaAsJson.pdb and b/inst/bin/MARMoSET.pdb differ diff --git a/man/files_in_group.Rd b/man/files_in_group.Rd index 6f11d35..0a569de 100644 --- a/man/files_in_group.Rd +++ b/man/files_in_group.Rd @@ -7,7 +7,7 @@ files_in_group(json, group_number) } \arguments{ -\item{json}{A JSON file generated by the function "use_rawMetaAsJson()" or by using rawMetaAsJson.exe externaly.} +\item{json}{A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly.} \item{group_number}{An index that determines the group.} } @@ -21,7 +21,7 @@ Filenames of one group data <- system.file( file.path('extdata', 'testfile.raw'), package = 'MARMoSET', mustWork = TRUE) -json <- use_rawMetaAsJson(data) +json <- generate_json(data) files_in_group(json, 1) diff --git a/man/flatten_json.Rd b/man/flatten_json.Rd index 611094b..1e340ab 100644 --- a/man/flatten_json.Rd +++ b/man/flatten_json.Rd @@ -7,7 +7,7 @@ flatten_json(json) } \arguments{ -\item{json}{A JSON file generated by the function "use_rawMetaAsJson()" or by using rawMetaAsJson.exe externaly.} +\item{json}{A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly.} } \value{ A flattened Json for better access. @@ -19,7 +19,7 @@ flattening JSON data <- system.file( file.path('extdata', 'testfile.raw'), package = 'MARMoSET', mustWork = TRUE) -json <- use_rawMetaAsJson(data) +json <- generate_json(data) flat_json <- flatten_json(json) diff --git a/man/use_rawMetaAsJson.Rd b/man/generate_json.Rd similarity index 76% rename from man/use_rawMetaAsJson.Rd rename to man/generate_json.Rd index 3f2922c..1064887 100644 --- a/man/use_rawMetaAsJson.Rd +++ b/man/generate_json.Rd @@ -1,24 +1,24 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/load_meta_functions.R -\name{use_rawMetaAsJson} -\alias{use_rawMetaAsJson} -\title{create a JSON File} -\usage{ -use_rawMetaAsJson(path_data) -} -\arguments{ -\item{path_data}{Path to raw file or directory containing raw files.} -} -\value{ -JSON object containing the meta data of the raw files. -} -\description{ -create a JSON File -} -\examples{ -data <- system.file( - file.path('extdata', 'testfile.raw'), - package = 'MARMoSET', mustWork = TRUE) -json <- use_rawMetaAsJson(data) - -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/load_meta_functions.R +\name{generate_json} +\alias{generate_json} +\title{create a JSON File} +\usage{ +generate_json(path_data) +} +\arguments{ +\item{path_data}{Path to raw file or directory containing raw files.} +} +\value{ +JSON object containing the meta data of the raw files. +} +\description{ +create a JSON File +} +\examples{ +data <- system.file( + file.path('extdata', 'testfile.raw'), + package = 'MARMoSET', mustWork = TRUE) +json <- generate_json(data) + +} diff --git a/man/gradient_tables.Rd b/man/gradient_tables.Rd index 2389d2b..7456fe6 100644 --- a/man/gradient_tables.Rd +++ b/man/gradient_tables.Rd @@ -21,7 +21,7 @@ Create a list with all gradient tables. data <- system.file( file.path('extdata', 'testfile.raw'), package = 'MARMoSET', mustWork = TRUE) -json <- use_rawMetaAsJson(data) +json <- generate_json(data) flat_json <- flatten_json(json) diff --git a/man/grapes-greater-than-grapes.Rd b/man/grapes-greater-than-grapes.Rd index 8ad1eb4..3757683 100644 --- a/man/grapes-greater-than-grapes.Rd +++ b/man/grapes-greater-than-grapes.Rd @@ -4,5 +4,5 @@ \alias{\%>\%} \title{magrittr forward-pipe operator} \description{ -See \code{\link[magrittr]{\\\%>\\\%}}. +See \code{\link[magrittr]{\%>\%}}. } diff --git a/man/grapes-less-than-greater-than-grapes.Rd b/man/grapes-less-than-greater-than-grapes.Rd index 5eb1285..7863c51 100644 --- a/man/grapes-less-than-greater-than-grapes.Rd +++ b/man/grapes-less-than-greater-than-grapes.Rd @@ -4,5 +4,5 @@ \alias{\%<>\%} \title{magrittr compound assignment pipe operator} \description{ -See \code{\link[magrittr]{\\\%<>\\\%}}. +See \code{\link[magrittr]{\%<>\%}}. } diff --git a/man/group_count.Rd b/man/group_count.Rd index dd9858d..f3c34ba 100644 --- a/man/group_count.Rd +++ b/man/group_count.Rd @@ -7,7 +7,7 @@ group_count(json) } \arguments{ -\item{json}{A JSON file generated by the function "use_rawMetaAsJson()" or by using rawMetaAsJson.exe externaly.} +\item{json}{A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly.} } \value{ Count of groups in the JSON file. @@ -19,7 +19,7 @@ Number of groups in the json file data <- system.file( file.path('extdata', 'testfile.raw'), package = 'MARMoSET', mustWork = TRUE) -json <- use_rawMetaAsJson(data) +json <- generate_json(data) group_count(json) diff --git a/man/instrument_names.Rd b/man/instrument_names.Rd index a3f198a..2942534 100644 --- a/man/instrument_names.Rd +++ b/man/instrument_names.Rd @@ -7,7 +7,7 @@ instrument_names(json, group_number) } \arguments{ -\item{json}{A JSON file generated by the function "use_rawMetaAsJson()" or by using rawMetaAsJson.exe externaly.} +\item{json}{A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly.} \item{group_number}{An index that determines the group.} } @@ -21,7 +21,7 @@ Get instrument names data <- system.file( file.path('extdata', 'testfile.raw'), package = 'MARMoSET', mustWork = TRUE) -json <- use_rawMetaAsJson(data) +json <- generate_json(data) instrument_names(json, 1) diff --git a/man/match_terms.Rd b/man/match_terms.Rd index e80cceb..1eff459 100644 --- a/man/match_terms.Rd +++ b/man/match_terms.Rd @@ -21,7 +21,7 @@ Match terms for all groups data <- system.file( file.path('extdata', 'testfile.raw'), package = 'MARMoSET', mustWork = TRUE) -json <- use_rawMetaAsJson(data) +json <- generate_json(data) flat_json <- flatten_json(json) diff --git a/man/one_gradient_table.Rd b/man/one_gradient_table.Rd index 9f12a0e..a27709e 100644 --- a/man/one_gradient_table.Rd +++ b/man/one_gradient_table.Rd @@ -23,7 +23,7 @@ Gradient. data <- system.file( file.path('extdata', 'testfile.raw'), package = 'MARMoSET', mustWork = TRUE) -json <- use_rawMetaAsJson(data) +json <- generate_json(data) flat_json <- flatten_json(json) diff --git a/man/one_group_match_terms.Rd b/man/one_group_match_terms.Rd index 35d088c..82725a0 100644 --- a/man/one_group_match_terms.Rd +++ b/man/one_group_match_terms.Rd @@ -23,7 +23,7 @@ Match terms for one group data <- system.file( file.path('extdata', 'testfile.raw'), package = 'MARMoSET', mustWork = TRUE) -json <- use_rawMetaAsJson(data) +json <- generate_json(data) flat_json <- flatten_json(json) diff --git a/man/save_all_groups.Rd b/man/save_all_groups.Rd index 5ad464c..3395e5f 100644 --- a/man/save_all_groups.Rd +++ b/man/save_all_groups.Rd @@ -18,7 +18,7 @@ write all groups to files data <- system.file( file.path('extdata', 'testfile.raw'), package = 'MARMoSET', mustWork = TRUE) -json <- use_rawMetaAsJson(data) +json <- generate_json(data) flat_json <- flatten_json(json) diff --git a/man/save_group_table.Rd b/man/save_group_table.Rd index ec06be5..774f529 100644 --- a/man/save_group_table.Rd +++ b/man/save_group_table.Rd @@ -20,7 +20,7 @@ write table of specified group to file data <- system.file( file.path('extdata', 'testfile.raw'), package = 'MARMoSET', mustWork = TRUE) -json <- use_rawMetaAsJson(data) +json <- generate_json(data) flat_json <- flatten_json(json) diff --git a/man/testfile_json.Rd b/man/testfile_json.Rd new file mode 100644 index 0000000..c746667 --- /dev/null +++ b/man/testfile_json.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{testfile_json} +\alias{testfile_json} +\title{Already generated JSON example file.} +\format{A JSON file, read by jsonlite::fromJSON()} +\usage{ +testfile_json +} +\description{ +Already generated JSON example file. +} +\keyword{datasets} diff --git a/vignettes/using_MARMoSET.Rmd b/vignettes/using_MARMoSET.Rmd index 1b32be4..20c67f9 100644 --- a/vignettes/using_MARMoSET.Rmd +++ b/vignettes/using_MARMoSET.Rmd @@ -47,11 +47,11 @@ remotes::install_github('loosolab/MARMoSET', host='github.molgen.mpg.de/api/v3') ## Usage: -The c# command line tool can be used in R with `use_rawMetaAsJson()` to create a JSON file including only the meta data of grouped raw files. It takes as argument `path_data`, a path to a raw file or a directory containing raw files. +The c# command line tool can be used in R with `generate_json()` to create a JSON file including only the meta data of grouped raw files. It takes as argument `path_data`, a path to a raw file or a directory containing raw files. -This JSON file can also be created by using the rawMetaAsJson.exe externally. +This JSON file can also be created by using the MARMoSET.exe externally. -Due to the design of the RawFileReader the rawMetaAsJson.exe and therefore this command is running as 64 bit code on Windows only. To use this package with another operating system, it is necessarry to already have the JSON file created. +Due to the design of the RawFileReader, the MARMoSET.exe and therefore this command is running as 64 bit code on Windows only. To use this package with another operating system, it is necessarry to already have the JSON file created. To open a JSON file in R the package `jsonlite` provides the function `fromJSON()`. ```{r} library(MARMoSET) @@ -63,7 +63,7 @@ if(.Platform$OS.type == 'windows') file.path('extdata', 'testfile.raw'), package = 'MARMoSET', mustWork = TRUE) - json <- use_rawMetaAsJson(path_data = data) + json <- generate_json(path_data = data) } else { # non windows user need to read in the JSON file here diff --git a/vignettes/using_MARMoSET.html b/vignettes/using_MARMoSET.html deleted file mode 100644 index 8f21ad7..0000000 --- a/vignettes/using_MARMoSET.html +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - - - - - - - - - -Using MARMoSET - - - - - - - - - - - - - - - - - - -

Using MARMoSET

-

Marina Kiweler

-

2019-01-22

- - - -

A package to extract meta data out of Thermo Fischer raw files. Meta data refers to what is found in a raw file as parts of the file header, sample information, instrument method and mass spectrometer tune data.

-

Works with the following instruments:

- -
-

Usage:

-

The c# command line tool can be used in R with use_rawMetaAsJson() to create a JSON file including only the meta data of grouped raw files. It takes as argument path_data, a path to a raw file or a directory containing raw files.

-
data <- system.file(
-    file.path('extdata', '20190116_SJ_short_for_Marina_LC_A.raw'),
-    package = 'MARMoSET', mustWork = TRUE)
-
-json <- use_rawMetaAsJson(path_data = data)
-

This JSON file can also be created by using the rawMetaAsJson.exe externally.

-

To allow an easier access to the JSON file it needs to be flattened, this works with flatten_json() which takes only one argument: json.

-
flat_json <- flatten_json(json = json)
-

Since raw files include a huge amount of meta data and only several of this information is required by journals there is the need to sort out. Therefore a table linking which information is essential and where to find it in the flattened JSON is useful. Such a here refered to as ‘term matching table’ can be created with term_matching_table() by submitting two arguments. The first, instrument_list takes a vector with the names of the instruments represented in the JSON file. The second one, origin_key specifies which requirements should be met. If it stays empty, all journals are selected. While "jpr" stands for the requirements of the Journal of Proteome Research, "mcp" chooses the requirements of the Molecular and Cellular Proteomics.

-
term_matching_table <- create_term_match_table(
-  instrument_list = c("Thermo EASY-nLC", "Q Exactive - Orbitrap_MS"),
-  origin_key = "jpr")
-

The names of the instruments can be shown for each group with instrument_names() with the json and the group number as arguments.

-
instrument_names(json = json, group_number = 1)
-#> [1] "Thermo EASY-nLC"          "Q Exactive - Orbitrap MS"
-

To combine the JSON with the created term matching table and get a clear table there are two possibilities. The function one_group_match_terms() creates one table with the information choosen in the term matching table for one group, while match_terms() creates a vector with a table for each group. Hence match_terms() takes the flattened json as first and the term matching table as second argument while one_group_match_terms() additonally has the group number as third argument. Note that for the use of match_terms() all raw files in the JSON need to be recorded by the same constellation of instruments. If this is not given each group needs a separate term matching table and therefore the use of one_group_match_terms().

-
meta_data_table <- one_group_match_terms(flat_json = flat_json,
-                                         term_matching_table = term_matching_table,
-                                         group_number = 1)
-
-vector_of_group_tables <- match_terms(flat_json = flat_json,
-                                      term_matching_table = term_matching_table)
-
-head(meta_data_table, 3)
-#>                                                       term
-#> 1 High Performance Liquid Chromatography (HPLC) Instrument
-#> 2                                              HPLC Vendor
-#> 3                                               HPLC Model
-#>               value
-#> 1   Thermo EASY-nLC
-#> 2 Thermo Scientific
-#> 3              <NA>
-

In the meta data of the ‘Thermo EASY-nlc’ is a gradient table. This table can be grabbed either by one_gradient_table() for one specified group or with gradient_tables() for all groups at once. Output will be either one table or a vector of tables.

-
gradient_table <- one_gradient_table(flat_json = flat_json,
-                                     group_number = 1)
-
-vector_of_gradient_tables <- gradient_tables(flat_json = flat_json)
-
-head(gradient_table, 3)
-#>   Time[mm:ss] Duration[mm:ss] Flow[nl/min] Mixture[%B]
-#> 1       00:00           00:00          300           5
-#> 2       01:00           01:00          300           5
-

Finally to export all tables in a vector or one specific, the functions save_group_table() and save_all_groups()are helpful. The output of gradient_tables() or match_terms() goes in as groups_vector whereas the second argument, output_path expects a path with filename. save_all_groups() adds the group numbers automatically to each filename, save_group_table() takes it as third argument but doesn’t add.

-

The output file is a tab delimited .txt file for each group.

-
partial_path_for_output <- tempfile()
-
-save_group_table(groups_vector = vector_of_group_tables,
-                 output_path = partial_path_for_output,
-                 group_number = 1)
-
-save_all_groups(groups_vector = vector_of_group_tables,
-                output_path =  partial_path_for_output)
-

Additional functions are group_count() which just returns how many groups the json file contains. files_in_groups()returns a list of the filenames in the group determined with the second parameter group_number. Both functions work with the original JSON file, not the flattened one.

-
group_count(json)
-#> [1] 1
-
-files_in_group(json, 1)
-#> [1] "C:/Users/mkiwele/Documents/R/win-library/3.5/MARMoSET/extdata/20190116_SJ_short_for_Marina_LC_A.raw"
-
- - - - - - - -