MetadataActionTabular | R Documentation |
Metadata action: tabular
Metadata action: tabular
Converts a metadata column into a column of data frames. This can be used
either to get a "subtag-style" column into a key-value store, or to actually
read a table like the MassBank peak annotations.
Note: in some cases, this is probably best prepended with split
, e.g. for NIST comments.
SpectraMapping::MetadataActionBase
-> MetadataActionTabular
process_read()
read implementation
MetadataActionTabular$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
MetadataActionTabular$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.
MetadataActionTabular$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Key-value store reading
backend <- get_proto_backend(COMMENT = list(c("INTERNAL_ID 1234", "MYNAME Michele", "formless_nosplit"),
c("formless nosplit"),
c(),
c("INTERNAL_ID 1232", "MYNAME something")))
action <- get_proto_action(
"tabular",
source = "COMMENT",
target = "commentData",
regex = "([A-Z_-]*)\\s?(.*)",
write = "{key} {value}"
)
fw <- action$execute_read(backend)
fw@variables <- fw@variables %>% select(-COMMENT)
bw <- action$execute_write(fw)
Table reading with colnames
backend <- get_proto_backend(
PKANNOT = list(
c("index m/z tentative_formula formula_count mass error(ppm)",
"1 78.9189 Br- 1 78.9189 -0.33",
"2 193.9252 C7HBrNO- 1 193.9247 2.32",
"3 273.8506 C7H2Br2NO- 1 273.8509 -1.06"),
c("index m/z tentative_formula formula_count mass error(ppm)",
"1 78.9188 Br- 1 78.9189 -0.71",
"2 193.9246 C7HBrNO- 1 193.9247 -0.56",
"3 273.8512 C7H2Br2NO- 1 273.8509 1.16"),
c(),
c("index m/z tentative_formula formula_count mass error(ppm)")
))
action <- get_proto_action(
"tabular",
source = "PKANNOT",
target = "annotation",
sep= " ",
header= 1
)
fw <- action$execute_read(backend)
fw@variables <- fw@variables %>% select(-PKANNOT)
bw <- action$execute_write(fw)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.