Learn R Programming

rbamtools (version 2.0.1)

flag: Retrieving or setting flagged values of bamAlign objects.

Description

In the BAM-align objects, two (of the four) bytes of the core-flag integer contain 11 binary managed flags. The other two bytes contain the number of cigar items reported in the current align. The described (reading and writing) accessor functions address these flags individually while the flag function reads and writes all four bytes (=32 bits) at once. Therefore the flag function should only be used for copying all values from one existing align to another.

The binary maintained flags are (in ascending numerical value of the flag): paired properPair unmapped mateUnmapped reverseStrand mateReverseStrand firstInPair secondInPair secondaryAlign failedQC pcrORopt_duplicate

Usage

flag(object)
paired(object)
properPair(object)
unmapped(object)
mateUnmapped(object)
reverseStrand(object)
mateReverseStrand(object)
firstInPair(object)
secondInPair(object)
secondaryAlign(object)
failedQC(object)
pcrORopt_duplicate(object)

Arguments

object
An instance of class bamReader

Value

  • flag: Integer. All other reading accessors: Logical. All writing accessors: None.

Details

bamAlign flag is a 32-Bit integer in which 16 bits represent binary flag values and 16 bits give the number of cigar items. There are accessor functions for all individual flags. This function can be used to read or set all values simulaneously. The strand information is returned as "Reverse" because that's the way it is stored in the BAM-file.

References

The SAM Format Specification (v1.4-r985). The SAM Format Specification Working Group. September 7, 2011. http://www.samtools.sourceforge.net/SAM1.pdf

Examples

Run this code
library(rbamtools)
bam_file <- system.file("extdata", "accepted_hits.bam", package="rbamtools")
reader<-bamReader(bam_file)
isOpen(reader)
align<-getNextAlign(reader)

i<-flag(align)
flag(align)<-i
paired(align)
paired(align)<-FALSE
properPair(align)
properPair(align)<-FALSE
unmapped(align)
unmapped(align)<-FALSE
mateUnmapped(align)
mateUnmapped(align)<-FALSE
reverseStrand(align)
reverseStrand(align)<-FALSE
mateReverseStrand(align)
mateReverseStrand(align)<-FALSE
firstInPair(align)
firstInPair(align)<-FALSE
secondInPair(align)
secondInPair(align)<-FALSE
secondaryAlign(align)
secondaryAlign(align)<-FALSE
failedQC(align)
failedQC(align)<-FALSE
pcrORopt_duplicate(align)
pcrORopt_duplicate(align)<-FALSE

bamClose(reader)

Run the code above in your browser using DataLab