MetadataActionCrossmap | R Documentation |
Metadata action: crossmap
Metadata action: crossmap
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.
SpectraMapping::MetadataActionBase
-> MetadataActionCrossmap
process_read()
read implementation
MetadataActionCrossmap$process_read(data, params)
data
MsBackendMapping
to execute the metadata mapping step on
params
List of parameters for a single action (one params
entry fully merged.)
process_write()
write implementation
MetadataActionCrossmap$process_write(data, params)
data
MsBackendMapping
to execute the metadata mapping step on
params
List of parameters for a single action (one params
entry fully merged.)
clone()
The objects of this class are cloneable with this method.
MetadataActionCrossmap$clone(deep = FALSE)
deep
Whether to make a deep clone.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.