Skip to content

Creation

marinakiweler edited this page Jun 18, 2019 · 9 revisions

Create an own combination of the available requirements

First extract a term matching table for the used instruments without specifying the origin key.

full_tmt <- create_term_match_table(
  instrument_list = c("Thermo EASY-nLC", "Q Exactive - Orbitrap_MS"))
  # no origin key set

Now it is possible to subset or delete some rows with r tools.

sub_rows <- c(1, 6:8, 10) # wanted rows
subset_tmt <- full_tmt[sub_rows,]

knitr::kable(subset_tmt)
term term_verbose origin handle_type handle example
1 hplc_instrument High Performance Liquid Chromatography (HPLC) Instrument author;miape;jpr_guidelines_ms list_path Instruments.Thermo EASY-nLC.InstrumentFriendName Thermo EASY-nLC
6 hplc_samplevolume Injected Sample Volume author;miape list_path Instruments.Thermo EASY-nLC.Method.Sample pickup.Volume [µl] 4.00
7 hplc_gradient Chromatography Gradient author;miape;jpr_guidelines_ms function document_easy_nlc_gradient NA
8 ms_instrument Mass Spectrometer (MS) author;miape;jpr_guidelines_ms list_path Instruments.Q Exactive - Orbitrap MS.InstrumentFriendName Q Exactive - Orbitrap MS
10 ms_model MS Model author;miape;jpr_guidelines_ms literal QExactive QExactive

Add new rows to the term matching table

New rows can be added. It is mandatory to fill in term_verbose, handle_type and handle in their specific column. term_verbose should be a short desription for the column as it will show up as key in the final table.

If handle contains a string that just needs to be copied to the output table the collumn handle_type should contain "literal".

# create row
new_row <- data.frame(term = "example_line",
                      term_verbose = "Example line",        # Term in the final table
                      origin = "",
                      handle_type = "literal",            
                      handle = "this will be the value",    # Value in the final table
                      example = "")
# add to subset
subset_tmt <- rbind(subset_tmt, new_row)

If the row is meant to show an entry of the json, handle_type needs to be "list_path" and handle should contain the path to the information in the flattened json after the group number. The handle can either be picked by hand and copied and pasted into the column or it can also be searched for. Important is to only take the part after the group number as handle (delete the "Group.1." part).

# create the flattened json (explained in using_MARMoSET)
flat_json <- flatten_json(json = MARMoSET::testfile_json)

'handle' is marked blue in this flat json.

# choose/search for item of the flattened list, get path without group number.
fj_path <- stringi::stri_subset(names(flat_json), regex = "Flush")  %>% 
stringi::stri_replace_all_regex(pattern = "^Group.[:digit:].", replacement = "")

# create row
new_row <- data.frame(term = "second_example_line",
                      term_verbose = "Second example, Autosampler flush volume",    # Term in the final table
                      origin = "",
                      handle_type = "list_path",            
                      handle = fj_path,                                             # Value in the final table
                      example = "")
# add to subset
subset_tmt <- rbind(subset_tmt, new_row)

This so changed term matching table can be used with the function match_terms(). Of course this table can also be exported and reused.

subset_table <- one_group_match_terms(flat_json = flat_json, 
                                         term_matching_table = subset_tmt, 
                                         group_number = 1)
knitr::kable(subset_table[5:7,])
Term Value
5 MS Model QExactive
6 Example line this will be the value
7 Second example, Autosampler flush volume 100.00