MetadataActionTabular: Metadata action: tabular

MetadataActionTabularR Documentation

Metadata action: tabular

Description

Metadata action: tabular

Metadata action: tabular

Details

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.

Super class

SpectraMapping::MetadataActionBase -> MetadataActionTabular

Methods

Public methods

Inherited methods

Method process_read()

read implementation

Usage
MetadataActionTabular$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
MetadataActionTabular$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
MetadataActionTabular$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

 
# 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)


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