Main Content

variableNames

Class: bioma.data.MetaData
Namespace: bioma.data

Retrieve or set variable names for samples in MetaData object

Syntax

VarNames = variableNames(MDObj)
VarNames = variableNames(MDObj, Subset)
NewMDObj = variableNames(MDObj, Subset, NewVarNames)

Description

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

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.

Input Arguments

MDObj

Object of the bioma.data.MetaData class.

Subset

One of the following to specify a subset of the variable names in a MetaData object:

  • 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

NewVarNames

New variable names for specific sample or feature variable names within a MetaData object, specified by one of the following:

  • 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, etc.

The number of variable names in NewVarNames must equal the number of variable names specified by Subset.

Output Arguments

VarNames

Cell array of character vectors specifying all variable names in a MetaData object.

NewMDObj

Object of the bioma.data.MetaData class, returned after replacing the variable names.

Examples

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

% Import the bioma.data namespace to make constructor function
% available
import bioma.data.*
% Construct MetaData object from .txt file
MDObj2 = MetaData('File', 'mouseSampleData.txt', 'VarDescChar', '#');
% Retrieve the sample variable names
VNames = variableNames(MDObj2)