A key is a variable that is used to identify features within an object. These features can refer to spectra in a Spectra object, peptide-spectrum matches in a PSM object, or PSMs, peptides of proteins in a SummarizedExperiment or QFeatures object. They do not need to be unique.

The goal of a key is to identify matching features across data types, such as for example to match de MS spectra to the PSMs and peptides. These different data types can be stored together in an MsExperiment object, and matched through one or multiple keys.

There are two general functions to work with keys across objects:

  • addKey(object, vars, key, force, sep) will add a key named key to an object based on user-defined variables vars.

  • filterKey(object, value, key, keep) will subset object based on a value in key.

  • getKey(object, key, drop) will return the values of variable key in object.

# S4 method for SummarizedExperiment
addKey(object, vars = NULL, key = ".KEY", force = FALSE, sep = ".")

# S4 method for Spectra
addKey(object, vars = NULL, key = ".KEY", force = FALSE, sep = ".")

# S4 method for PSM
addKey(object, vars = NULL, key = ".KEY", force = FALSE, sep = ".")

# S4 method for QFeatures
addKey(object, vars = NULL, key = ".KEY", force = FALSE, sep = ".")

# S4 method for Spectra
filterKey(object, value, key = ".KEY")

# S4 method for PSM
filterKey(object, value, key = ".KEY")

# S4 method for SummarizedExperiment
filterKey(object, value, key = ".KEY")

# S4 method for QFeatures
filterKey(object, value, key = ".KEY", keep = FALSE)

# S4 method for MsExperiment
filterKey(
  object,
  value,
  key = ".KEY",
  data = c("spectra", "qdata"),
  otherdata = NULL,
  keep = FALSE
)

# S4 method for PSM
getKey(object, key = ".KEY")

# S4 method for Spectra
getKey(object, key = ".KEY")

# S4 method for SummarizedExperiment
getKey(object, key = ".KEY")

# S4 method for QFeatures
getKey(object, key = ".KEY", drop = TRUE)

Arguments

object

An instance of class SummarizedExperiment, QFeatures, PSM or Spectra.

vars

character() referencing the variables to use to create the key. These are to be found in the object's rowData (for SummarizedExperiment and QFeatures objects) or spectraData (for Spectra objects) or in the object itself (for PSM objects). Throws an error if the variables aren't found. Default is NULL.

key

character(1) defining the key's name. Default is ".KEY".

force

logical(1) that defines is an existing key should be overwritten. Default is FALSE and an error is thrown if the key is already present.

sep

character(1) specifying the separator when multiple variables are pasted together to generate the key. Default is ".".

value

character() containing the value of key of the feature(s) of interest.

keep

logical(1) that defines whether to keep assays that didn't contain the key of interest. If TRUE, these are returned as empty assays (i.e. with zero rows/features). Default is FALSE`; only assays containing matching keys are returned.

data

character() defining what data type to subset by key. Default are "spectra" and "qdata". Note that these data are ignored if their slot is NULL.

otherdata

character() listing the name(s) of the additional data types in otherData(.) to run filterKey() on.

drop

logical(1) defining whether to drop assays that don't have the key variable. Default is TRUE.