filterByFlag

Class: BioMap

Filter sequence reads by SAM flag

Syntax

Indices = filterByFlag(BioObj, FlagName, FlagValue)
Indices = filterByFlag(BioObj, Subset, FlagName, FlagValue)
Indices = filterByFlag(..., FlagName1, FlagValue1, FlagName2, FlagValue2, ...)

Description

Indices = filterByFlag(BioObj, FlagName, FlagValue) returns Indices, a vector of logical indices, indicating the read sequences in BioObj, a BioMap object, with FlagName set to FlagValue.

Indices = filterByFlag(BioObj, Subset, FlagName, FlagValue) returns Indices, a vector of logical indices, indicating the read sequences that meet the specified criteria from a subset of entries in a BioMap object.

Indices = filterByFlag(..., FlagName1, FlagValue1, FlagName2, FlagValue2, ...) applies multiple flag filters in a single statement.

Input Arguments

BioObj

Object of the BioMap class.

Subset

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

  • Vector of positive integers

  • Logical vector

FlagName

String specifying one of the following flags to filter by:

  • 'pairedInSeq' — The read is paired in sequencing, regardless if it is mapped as a pair.

  • 'pairedInMap' — The read is mapped in a proper pair.

  • 'unmappedQuery' — The read is unmapped.

  • 'unmappedMate' — The mate is unmapped.

  • 'strandQuery' — Strand direction of the read (0 = forward, 1 = reverse).

  • 'strandMate' — Strand direction of the mate (0 = forward, 1 = reverse).

  • 'readIsFirst' — The read is first in a pair.

  • 'readIsSecond' — The read is second in a pair.

  • 'alnNotPrimary' — The read's alignment is not primary.

  • 'failedQualCheck' — The read fails platform or vendor quality checks.

  • 'duplicate' — The read is a PCR or optical duplicate.

FlagValue

Logical value indicating the status of a flag. A 0 indicates false or forward, and a 1 indicates true or reverse.

Output Arguments

Indices

Vector of logical indices, indicating the read sequences in BioObj with FlagName set to FlagValue.

Examples

Construct a BioMap object, and then determine the read sequences that are both mapped in a proper pair and first in a pair:

% Construct a BioMap object from a SAM file 
BMObj1 = BioMap('ex1.sam');
% Filter the elements using 'pairedInMap' and 'readIsFirst' flags 
Indices = filterByFlag(BMObj1, 'pairedInMap', true,...
                       'readIsFirst', true);
% Return the headers of the filtered elements
filtered_Headers = BMObj1.Header(Indices);
Was this topic helpful?