getSubset

Class: GFFAnnotation

Retrieve subset of elements from GFFAnnotation object

Syntax

NewObj = getSubset(AnnotObj,StartPos,EndPos)
NewObj = getSubset(AnnotObj,Subset)
NewObj = getSubset(___,Name,Value)

Description

NewObj = getSubset(AnnotObj,StartPos,EndPos) returns NewObj, a new object containing a subset of the elements from AnnotObj that falls within each reference sequence range specified by StartPos and EndPos.

NewObj = getSubset(AnnotObj,Subset) returns NewObj, a new object containing a subset of elements specified by Subset, a vector of integers.

NewObj = getSubset(___,Name,Value) returns NewObj, a new object containing a subset of the elements from AnnotObj, using any of the input arguments from the previous syntaxes and additional options specified by one or more Name,Value pair arguments.

Input Arguments

AnnotObj

Object of the GFFAnnotation class.

StartPos

Nonnegative integer specifying the start of a range in each reference sequence in AnnotObj. The integer StartPos must be less than or equal to EndPos.

EndPos

Nonnegative integer specifying the end of a range in each reference sequence in AnnotObj. The integer EndPos must be greater than or equal to StartPos.

Subset

Vector of positive integers equal or less than the number of entries in the object. Use the vector Subset to retrieve any element or subset of the object.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'Reference'

Character vector or cell array of character vectors specifying one or more reference sequences in AnnotObj. Only annotations whose reference field matches one of the character vectors are included in NewObj.

'Feature'

Character vector or cell array of character vectors specifying one or more features in AnnotObj. Only annotations whose feature field matches one of the character vectors are included in NewObj.

'Overlap'

Minimum number of base positions that an annotation must overlap in the range, to be included in NewObj. This value can be any of the following:

  • Positive integer

  • 'full' — An annotation must be fully contained in the range to be included.

  • 'start' — An annotation’s start position must lie within the range to be included.

Default: 1

Output Arguments

NewObj

Object of the GFFAnnotation class.

Examples

Example 32. Create a Subset of Data Containing Only Protein Features from a GFF-formatted File

Construct a GFFAnnotation object using a GFF-formatted file that is provided with Bioinformatics Toolbox™.

GFFAnnotObj = GFFAnnotation('tair8_1.gff');

Create a subset of data containing only protein features.

subsetGFF1 = getSubset(GFFAnnotObj,'Feature','protein')
subsetGFF1 = 

  GFFAnnotation with properties:

    FieldNames: {1x9 cell}
    NumEntries: 200
Example 33. Retrieve Subsets of Data from a GFFAnnotation Object

Construct a GFFAnnotation object using a GFF-formatted file that is provided with Bioinformatics Toolbox.

GFFAnnotObj = GFFAnnotation('tair8_1.gff');

Retrieve a subset of data from the first to fifth elements of GFFAnnotObj.

subsetGFF2 = getSubset(GFFAnnotObj,[1:5])

subsetGFF2 = 

  GFFAnnotation with properties:

    FieldNames: {1x9 cell}
    NumEntries: 5

Retrieve only the first, fifth and eighth elements of GFFAnnotObj.

subsetGFF3 = getSubset(GFFAnnotObj,[1 5 8])

subsetGFF3 = 

  GFFAnnotation with properties:

    FieldNames: {1x9 cell}
    NumEntries: 3

Tips

  • The getSubset method selects annotations from the range specified by StartPos and EndPos for all reference sequences in AnnotObj unless you use the Reference name-value pair argument to limit the reference sequences.

  • After creating a subsetted object, you can access the number of entries, range of reference sequence covered by annotations, field names, and reference names. To access the values of all fields, create a structure of the data using the getData method.