getSubset

Class: BioIndexedFile

Create object containing subset of elements from BioIndexedFile object

Syntax

NewObj = getSubset(BioIFObj, Indices)
NewObj = getSubset(BioIFObj, Keys)

Description

NewObj = getSubset(BioIFObj, Indices) returns NewObj, a new BioIndexedFile object that accesses a subset of entries in the source file associated with BioIFObj, a BioIndexedFile object. The entries are specified by Indices, a vector containing unique positive integers.

NewObj = getSubset(BioIFObj, Keys) returns NewObj, a new BioIndexedFile object that accesses a subset of entries in the source file associated with BioIFObj, a BioIndexedFile object. The entries are specified by Keys, a string or cell array of unique strings specifying keys.

Tips

Use this method to create a smaller, more manageable BioIndexedFile object.

Input Arguments

BioIFObj

Object of the BioIndexedFile class.

Indices

Vector containing unique positive integers that specify the entries in the source file to access with NewObj. The number of elements in Indices cannot exceed the number of entries indexed by BioIFObj. There is a one-to-one relationship between the elements in Indices and the entries that NewObj accesses.

Keys

String or cell array of unique strings specifying keys that specify the entries in the source file to access with NewObj. The number of elements in Keys is less than or equal to the number of entries indexed by BioIFObj. If the keys in the source file are not unique, then all entries that match a given key are indexed by NewObj. In this case, there is not a one-to-one relationship between the elements in Keys and the entries that NewObj accesses. If the keys in the source file are unique, then there is a one-to-one relationship between the elements in Keys and the entries that NewObj accesses.

Output Arguments

NewObj

Object of the BioIndexedFile class.

Examples

Construct a BioIndexedFile object to access a table containing cross-references between gene names and gene ontology (GO) terms:

% Create a variable containing the full absolute path of the source file.
sourcefile = which('yeastgenes.sgd');
% Create a BioIndexedFile object from the source file. Indicate
% the source file is a tab-delimited file where contiguous rows
% with the same key are considered a single entry. Store the
% index file in the Current Folder. Indicate that keys are
% located in column 3 and that header lines are prefaced with !
gene2goObj = BioIndexedFile('mrtab', sourcefile, '.', ...
                            'KeyColumn', 3, 'HeaderPrefix','!')

Create a new BioIndexedFile object that accesses only the first 1,000 cross-references and reuses the same index file as gene2goObj:

% Create a new BioIndexedFile object.
gene2goSubset = getSubset(gene2goObj,1:1000);
Was this topic helpful?