MetadataActionCrossmap: Metadata action: crossmap

MetadataActionCrossmapR Documentation

Metadata action: crossmap

Description

Metadata action: crossmap

Metadata action: crossmap

Details

This action is to join and split multientry data. For example, in NIST MSP, Name is a single compound name, and all subsequent Synon are synonyms. In MassBank data, these need to go all into CH$NAME. There are now two ways to do this:

  • one: the internal representation is the "joined" one. On reading from MSP, we merge Name and Synon to e.g. names. On writing to MassBank, names -> CH$NAME.

  • the other: the internal representation is the "separated" one. On reading from MSP, Name -> name and Synon -> synonyms On writing to MassBank, we merge name and synonyms to CH$NAME. On reading from MassBank, CH$NAME[1] to name, all other CH$NAME entries to synonyms.

This can also split a field on reading!

source: fields of origin target: target fields read_split: After joining the source fields together, how to distribute them to target? E.g. ⁠[1, *]⁠ extracts the first entry into the first target field and the rest into the second target field. write_split: Same question when writing.

Super class

SpectraMapping::MetadataActionBase -> MetadataActionCrossmap

Methods

Public methods

Inherited methods

Method process_read()

read implementation

Usage
MetadataActionCrossmap$process_read(data, params)
Arguments
data

MsBackendMapping to execute the metadata mapping step on

params

List of parameters for a single action (one params entry fully merged.)


Method process_write()

write implementation

Usage
MetadataActionCrossmap$process_write(data, params)
Arguments
data

MsBackendMapping to execute the metadata mapping step on

params

List of parameters for a single action (one params entry fully merged.)


Method clone()

The objects of this class are cloneable with this method.

Usage
MetadataActionCrossmap$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


# Split on write, join on read
 
crossmap <- get_proto_action(
   "crossmap",
   source=c('Name', 'Synon'),
   target='names',
   read_split = list(names="*"),
   write_split = list('Name' = '1', 'Synon' = '*'))

backend <-  get_proto_backend(Name=list('Anton', 'Franz', c()), Synon=list(c(), c('Francis', 'Franziskus'), c()))
fw <- crossmap$execute_read(backend)
fw@variables <- fw@variables %>% select(names)
bw <- crossmap$execute_write(fw)

# Split on read, join on write

backend <-  get_proto_backend(CHNAME=list(c('N1', 'N2', 'N3'), c('Francis', 'Franziskus'), c('Nsingle'), c()))
crossmap <- get_proto_action(
   "crossmap",
   source=c('CHNAME'),
   target=c('name', 'synonyms'),
   read_split = list(name="1", synonyms="*"),
   write_split = list(CHNAME="*")
   )
fw <- crossmap$execute_read(backend)
fw@variables <- fw@variables %>% select(-CHNAME)
bw <- crossmap$execute_write(fw)


meowcat/SpectraMapping documentation built on May 14, 2024, 6:30 p.m.