getSubset

Class: BioRead

Create object containing subset of elements from object

Syntax

NewObj = getSubset(BioObj, Subset)
NewObj = getSubset(BioObj, 'SelectReference', R)
NewObj = getSubset(..., 'ParameterName', ParameterValue)

Description

NewObj = getSubset(BioObj, Subset) returns NewObj, a new object containing a subset of the elements from BioObj. getSubset returns object elements specified by Subset. If BioObj is indexed, then NewObj is indexed. If BioObj is in memory, then NewObj is in memory.

NewObj = getSubset(BioObj, 'SelectReference', R) for BioObj objects of the BioMap class creates a subset object with only the short reads mapped to R.

NewObj = getSubset(..., 'ParameterName', ParameterValue) accepts one or more comma-separated parameter name/value pairs. Specify ParameterName inside single quotes.

Input Arguments

BioObj

Object of the BioRead or BioMap class.

Subset

One of the following to specify a subset of the elements in BioObj:

  • Vector of positive integers

  • Logical vector

  • Cell array of strings containing valid sequence headers

    Note:   If you use a cell array of header strings to specify Subset, be aware that a repeated header specifies all elements with that header.

R

Vector of positive integers indexing the SequenceDictionary property of BioObj or a cell array of strings specifying the actual names of references in objects of the BioMap class.

Name-Value Pair Arguments

'Name'

String specifying a name for NewObj. This information populates the Name property of NewObj.

Default: Empty string

'InMemory'

Logical specifying whether getSubset uses indexed access to the source file or loads the contents of the source file into memory. If the data specified for the subset is still large, set to false to use indexed access and be memory efficient. If the data specified for the subset fits in memory, set to true to load the data into memory, which lets you access NewObj faster and update its properties.

If BioObj was not constructed using indexed access and is already in memory, the InMemory name/value pair is ignored, and the data is automatically placed in memory.

Default: false

Output Arguments

NewObj

Object of the BioRead or BioMap class. If BioObj is in memory, then NewObj is in memory. If BioObj is indexed, then NewObj is indexed, unless you set the InMemory parameter name/value pair to true.

Examples

Retrieve a subset of elements from a BioRead object:

% Construct a BioRead object from a FASTQ file 
BRObj = BioRead('SRR005164_1_50.fastq');
% Retrieve the information associated with the second and third
% elements in the object
getSubset(BRObj, [2 3]);
getSubset(BRObj, [2:3]);
getSubset(BRObj, {'SRR005164.2', 'SRR005164.3'});
getSubset(BRObj, [false true true]);
% Create a new BioRead object containing the first and third elements
% from the object
NewBRObj = getSubset(BRObj, [1 3]);
Was this topic helpful?