setMtdField() sets or updates metadata fields within an MTD (metadata)
section. When the field already exists, the function can either replace it
entirely or append new values to the existing ones.
getMtdField() returns the information from an MTD section of the requested
field.
Arguments
- x
A MTD section that stores metadata fields. Can be a two-column
charactermatrix, a two-columndata.frameor aMzTabM()object. Defaults tomatrix(). If all values areNA, the function returnsxunchanged.- field
character(1)name of the metadata field to set or update. Must be a valid MTD field name. (e.g."publication")- value
charactervalue(s) to assign to the field. (e.g."https://pubs.acs.org/doi/10.1021/acs.analchem.8b04310")- replace
logicalflag controlling how pre-existing field metadata is handled. Valid only for indexed fields, unique fields are always replaced.FALSE(default): new values are appended to any existing values.TRUE: existing instrument metadata is discarded and replaced entirely by the supplied arguments.
Value
For
setMtdField(): the input objectxupdated to include the new or merged field metadata. Ifxis empty, the emptyx.For
getMtdField(): a namedcharacterwith the requested information, names being the field names.
Examples
x <- mtdSkeleton("001", software = "[MS, MS:1001582, xcms, 4.0.0]")
## Add a metadata field to an existing mzTab object
mtd <- setMtdField(x, field = "publication",
value = "pubmed:21063943|doi:10.1007/978-1-60761-987-1_6")
## Replace all existing values for a metadata field
mtd <- setMtdField(mtd, field = "custom",
value = "[,,MS operator, Florian]",
replace = TRUE)
getMtdField(mtd, field = "mzTab-ID")
#> mzTab-ID
#> "001"
