samFlags: Work with the sam flags field

Description Usage Arguments Value Flag descriptions Examples

View source: R/samFlags.R

Description

A sam flag field represents 12 true or false values as a 12 bit binary number. This is encoded as the integer equivalent of the binary. The samFlags function supports working with this, returning a named logical vector decoding a provided int value, or returning the encoded int value if given a logical vector or a vector of characters that correspond to flag names. A data frame of names, equivalent integer values, and a short description can be obtained by calling samFlags without a value.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
samFlags(x, ...)

## S3 method for class 'NULL'
samFlags(x, ...)

## S3 method for class 'character'
samFlags(x, ...)

## S3 method for class 'numeric'
samFlags(x, ...)

Arguments

x

Either encodes this vector of flag names (character) to a flag integer, or decodes this single integer value to a named logical vector. When encoding flag names order is unimportant. Integers to be decoded should be between 0 and 4095. Values larger than 4095 work like x By default if nothing is provided a data frame describing the flags is returned. Note that flag names can be provided as a single vector, or just specified as arguments - see examples.

...

Required for S3 formalism and future-proofing.

Value

When encoding a vector of flag names, returns a single integer value. When decoding an integer value, returns a 12 element named logical vector with the high-bit first (2048 = 2^11 = the supplementaryAlignment flag). Without a parameter to work on, returns a data frame describing the flags

Flag descriptions

The data frame returned by calling samFlags without a value has one row for each of the 12 flags with the rownames giving the flag name. The two columns are:

Using names and descriptions from the htsjdk project on github, specifically the MIT licensed file SAMFlag.java

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Get list of flag names, values, and descriptions
samFlags()
#>         flag value                                            description
#> 1 readPaired     1        Template having multiple segments in sequencing
#> 2 properPair     2 Each segment properly aligned according to the aligner
#> ...

# Encode sam flags to integer value
samFlags( "readPaired" )
#> 1
samFlags( c("readPaired", "readUnmapped" ))
#> 5
samFlags( "readPaired", "readUnmapped" )
#> 5

samFlags( 3 )
#> SUPPLEMENTARY_ALIGNMENT      DUPLICATE_READ READ_FAILS_VENDOR_QC
#>                   FALSE               FALSE                FALSE
#>   NOT_PRIMARY_ALIGNMENT      SECOND_OF_PAIR        FIRST_OF_PAIR
#>                   FALSE               FALSE                FALSE
#>     MATE_REVERSE_STRAND READ_REVERSE_STRAND        MATE_UNMAPPED
#>                   FALSE               FALSE                FALSE
#>           READ_UNMAPPED         PROPER_PAIR          READ_PAIRED
#>                   FALSE                TRUE                 TRUE

jefferys/SamSeq documentation built on Oct. 25, 2019, 8:11 a.m.