Skip to Main Content Skip to Search
Product Documentation

getCoverage - Class: BioMap

Compute read coverage in BioMap object

Syntax

Cov = getCoverage(BioObj, StartPos, EndPos)
[Cov, Indices] = getCoverage(BioObj, StartPos, EndPos)
[Cov, Indices, Seqs] = getCoverage(BioObj, StartPos, EndPos)
... = getCoverage(BioObj, StartPos, EndPos, 'ParameterName', ParameterValue)

Description

Cov = getCoverage(BioObj, StartPos, EndPos) returns Cov, a nonnegative integer indicating the number of read sequences that cover (align within) a specific region of the reference sequence in BioObj, a BioMap object. The specific region of the reference sequence is defined by StartPos and EndPos. StartPos and EndPos can be two nonnegative integers such that StartPos is less than EndPos, and both are smaller than the length of the reference sequence. StartPos and EndPos can also be two column vectors representing a collection of regions of the reference sequence. In this case, Cov is a column vector of nonnegative integers indicating the number of read sequences that cover each region.

[Cov, Indices] = getCoverage(BioObj, StartPos, EndPos) also returns Indices, a vector of indices specifying the read sequences that align within a specific region of the reference sequence.

[Cov, Indices, Seqs] = getCoverage(BioObj, StartPos, EndPos) also returns Seqs, a cell array of strings containing the read sequences that align within a specific region of the reference sequence.

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

Tips

Use the Indices output from the getCoverage method as input to other BioMap methods. Doing so lets you determine other information about the read sequences in the coverage region, such as header, start position, mapping quality, etc.

Input Arguments

BioObj

Object of the BioMap class.

StartPos

Either of the following:

  • Nonnegative integer that defines the start of a region of the reference sequence. StartPos must be less than EndPos, and smaller than the total length of the reference sequence.

  • Column vector of nonnegative integers, each defining the start of a region of the reference sequence.

EndPos

Either of the following:

  • Nonnegative integer that defines the end of a region of the reference sequence. EndPos must be greater than StartPos, and smaller than the total length of the reference sequence.

  • Column vector of nonnegative integers, each defining the end of a region of the reference sequence.

Parameter Name/Value Pairs

'Base'

Specifies if the output Cov is computed base-by-base, that is determining the number of nongap symbols that align with each position in the specified region of the reference sequence. If true, Cov is a vector of positive integers corresponding to the base positions in the specified region of the reference sequence.

Default: false

'Full'

Specifies to include only the read sequences that fully align with the defined region of the reference sequence, that is, they are completely contained within the region, and do not extend beyond the region.

Default: false

Output Arguments

Cov

Either of the following:

  • Nonnegative integer indicating the number of read sequences that cover (align within) a specific region of the reference sequence in BioObj.

  • Column vector of nonnegative integers indicating the number of read sequences that cover each region specified by StartPos and EndPos, when they are both column vectors. In this case, Cov is the same length as StartPos and EndPos.

Indices

Vector of indices specifying the read sequences from BioObj that align within a specific region of the reference sequence.

Seqs

Cell array of strings containing the read sequences from BioObj that align within a specific region of the reference sequence. Each string is a sequence read without alignment information.

Examples

Construct a BioMap object, and then retrieve the coverage of the first 50 positions of the reference sequence:

% Construct a BioMap object from a SAM file 
BMObj1 = BioMap('ex1.sam');
% Retrieve the number of sequences that cover the first 50
% positions of the reference sequence
cov = getCoverage(BMObj1, 1, 50)
cov =

    20
 

Construct a BioMap object, and then retrieve the starting positions for the read sequences that cover the first 50 positions of the reference sequence:

% Construct a BioMap object from a SAM file 
BMObj1 = BioMap('ex1.sam');
% Retrieve the number of sequences that cover the first 50
% positions of the reference sequence
% Also retrieve the indices of these sequences 
[cov, idx] = getCoverage(BMObj1, 1, 50);
% Use the indices for these sequences to determine their start
% positions
startPositions = getStart(BMObj1, idx);
 

Construct a BioMap object, and then retrieve the coverage of the first 50 positions of the reference sequence, considering only read sequences that align fully within the region:

% Construct a BioMap object from a SAM file 
BMObj1 = BioMap('ex1.sam');
% Retrieve the number of sequences that cover the first 50
% positions of the reference sequence
% Consider only read sequences that align fully within the region
fullCov = getCoverage(BMObj1, 1, 50, 'full', true)
fullCov =

    8
 

Construct a BioMap object, and then retrieve the coverage for the first 10 positions of the reference sequence, on a base-by-base basis:

% Construct a BioMap object from a SAM file 
BMObj1 = BioMap('ex1.sam');
% Retrieve the number of sequences that cover each base position of
% the first 10 positions of the reference sequence
baseCov = getCoverage(BMObj1, 1, 10, 'base', true)
baseCov =

     1
     1
     2
     2
     3
     4
     4
     4
     5
     5

See Also

align2cigar | BioMap | cigar2align | getAlignment | getCompactAlignment

How To

Related Links

  


Free Computational Biology Interactive Kit

See how to analyze, visualize, and model biological data and systems using MathWorks products.

Get free kit

Trials Available

Try the latest computational biology products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS