expandFeatureVars {MSnbase} | R Documentation

## Expand or merge feature variables

### Description

The `expandFeatureVars` and `mergeFeatureVars` respectively expand and merge groups of feature variables. Using these functions, a set of columns in a feature data can be merged into a single new data.frame-column variables and a data.frame-column can be expanded into single feature columns. The original feature variables are removed.

### Usage

    expandFeatureVars(x, fcol, prefix)

    mergeFeatureVars(x, fcol, fcol2)

### Arguments

`x` | An object of class `MSnSet`.
`fcol` | A `character()` of feature variables to expand (for `expandFeatureVars`) or merge (for `mergeFeatureVars`).
`prefix` | A `character(1)` to use as prefix to the new feature variables. If missing (default), then `fcol` is used instead. If `NULL`, then no prefix is used.
`fcol2` | A `character(1)` defining the name of the new feature variable.

### Value

An `MSnSet` for expanded (merged) feature variables.

### Author(s)

Laurent Gatto

### Examples

    library("pRolocdata")
    data(hyperLOPIT2015)
    fvarLabels(hyperLOPIT2015)
    ## Let's merge all svm prediction feature variables
    (k <- grep("^svm", fvarLabels(hyperLOPIT2015), value = TRUE))
    hl <- mergeFeatureVars(hyperLOPIT2015, fcol = k, fcol2 = "SVM")
    fvarLabels(hl)
    head(fData(hl)$SVM)

    ## Let's expand the new SVM into individual columns
    hl2 <- expandFeatureVars(hl, "SVM")
    fvarLabels(hl2)
    ## We can set the prefix manually
    hl2 <- expandFeatureVars(hl, "SVM", prefix = "Expanded")
    fvarLabels(hl2)
    ## If we don't want any prefix
    hl2 <- expandFeatureVars(hl, "SVM", prefix = NULL)
    fvarLabels(hl2)

[Package MSnbase version 2.15.7 Index]