Main Content

variableNames

Retrieve or set variable names for samples in MetaData object

Description

VarNames = variableNames(MDObj) returns a cell array of character vectors specifying all variable names in a MetaData object.

example

VarNames = variableNames(MDObj,Subset) returns a cell array of character vectors specifying a subset the variable names in a MetaData object.

NewMDObj = variableNames(MDObj,Subset,NewVarNames) replaces the variable names specified by Subset in MDObj, a MetaData object, with NewVarNames, and returns NewMDObj, a new MetaData object.

Examples

collapse all

Construct a MetaData object, and then retrieve the sample variable names from it.

Import the bioma.data namespace to make the constructor function available.

import bioma.data.*

Construct MetaData object from a text file.

MDObj2 = MetaData('File','mouseSampleData.txt','VarDescChar','#');

Retrieve the sample variable names.

VNames = variableNames(MDObj2)
VNames = 1x5 cell
    {'Gender'}    {'Age'}    {'Type'}    {'Strain'}    {'Source'}

Input Arguments

collapse all

MetaData object for which to retrieve or set variable names, specified as a MetaData object.

Subset of the variable names in MetaData object, specified as one of these values:

  • Character vector or string specifying a variable name

  • Cell array of character vectors or string vector specifying variable names

  • Positive integer

  • Vector of positive integers

  • Logical vector

New variable names for specific sample or feature variable names within a MetaData object, specified as one of these values:

  • Numeric vector

  • Cell array of character vectors or character array

  • Character vector, which variableNames uses as a prefix for the variable names, with variable numbers appended to the prefix

  • Logical true or false (default). If true, variableNames assigns unique variable names using the format Var1, Var2, and so on.

Output Arguments

collapse all

All variable names in a MetaData object, returned as a cell array of character vectors.

Resulting MetaData object after replacing the variable names, returned as a MetaData object.

Version History

Introduced in R2009b