| ScanBamParam {Rsamtools} | R Documentation |
Use ScanBamParam() to create a parameter object influencing
what fields and which records are imported from a (binary) BAM file.
Use of which requires that a BAM index file
(<filename>.bai) exists.
# Constructor
ScanBamParam(flag = scanBamFlag(), simpleCigar = FALSE,
reverseComplement = FALSE, tag = character(0),
what = character(0), which)
# Constructor helpers
scanBamFlag(isPaired = NA, isProperPair = NA, isUnmappedQuery = NA,
hasUnmappedMate = NA, isMinusStrand = NA, isMateMinusStrand = NA,
isFirstMateRead = NA, isSecondMateRead = NA, isNotPrimaryRead = NA,
isValidVendorRead = NA, isDuplicate = NA)
scanBamWhat()
# Accessors
bamFlag(object, asInteger=FALSE)
bamFlag(object) <- value
bamReverseComplement(object)
bamReverseComplement(object) <- value
bamSimpleCigar(object)
bamSimpleCigar(object) <- value
bamTag(object)
bamTag(object) <- value
bamWhat(object)
bamWhat(object) <- value
bamWhich(object)
bamWhich(object) <- value
## S4 method for signature 'ScanBamParam'
show(object)
# Flag utils
bamFlagAsBitMatrix(flag)
bamFlagAND(flag1, flag2)
bamFlagTest(flag, value)
flag |
For For |
simpleCigar |
A logical(1) vector which, when TRUE, returns only
those reads for which the cigar (run-length encoded representation
of the alignment) is missing or contains only matches / mismatches
( |
reverseComplement |
A logical(1) vector which, when TRUE, returns the sequence and quality scores of reads mapped to the minus strand in the reverse complement (sequence) and reverse (quality) of the read as stored in the BAM file. |
tag |
A character vector naming tags to be extracted. A tag is an
optional field, with arbitrary information, stored with each
record. Tags are identified by two-letter codes, so all elements of
|
what |
A character vector naming the fields to
return. |
which |
A |
isPaired |
A logical(1) indicating whether unpaired (FALSE), paired (TRUE), or any (NA) read should be returned. |
isProperPair |
A logical(1) indicating whether improperly paired (FALSE), properly paired (TRUE), or any (NA) read should be returned. A properly paired read is defined by the alignment algorithm and might, e.g., represent reads aligning to identical reference sequences and with a specified distance. |
isUnmappedQuery |
A logical(1) indicating whether unmapped (TRUE), mapped (FALSE), or any (NA) read should be returned. |
hasUnmappedMate |
A logical(1) indicating whether reads with mapped (FALSE), unmapped (TRUE), or any (NA) mate should be returned. |
isMinusStrand |
A logical(1) indicating whether reads aligned to the plus (FALSE), minus (TRUE), or any (NA) strand should be returned. |
isMateMinusStrand |
A logical(1) indicating whether mate reads aligned to the plus (FALSE), minus (TRUE), or any (NA) strand should be returned. |
isFirstMateRead |
A logical(1) indicating whether the first mate read should be returned (TRUE) or not (FALSE), or whether mate read number should be ignored (NA). |
isSecondMateRead |
A logical(1) indicating whether the second mate read should be returned (TRUE) or not (FALSE), or whether mate read number should be ignored (NA). |
isNotPrimaryRead |
A logical(1) indicating whether reads that are primary (FALSE), are not primary (TRUE) or whose primary status does not matter (NA) should be returned. A non-primary read might result when portions of a read aligns to multiple locations, e.g., when spanning splice junctions). |
isValidVendorRead |
A logical(1) indicating whether invalid (FALSE), valid (TRUE), or any (NA) read should be returned. A 'valid' read is one flagged by the vendor as passing quality control criteria. |
isDuplicate |
A logical(1) indicating that un-duplicated (FALSE), duplicated (TRUE), or any (NA) reads should be returned. 'Duplicated' reads may represent PCR or optical duplicates. |
object |
An instance of class |
value |
An instance of the corresponding slot, to be assigned to
|
asInteger |
logical(1) indicating whether ‘flag’ should be
returned as an encoded integer vector ( |
flag1, flag2 |
Integer vectors containing ‘flag’ entries. |
Objects are created by calls of the form ScanBamParam().
flagObject of class integer encoding flags
to be kept when they have their '0' (keep0) or '1'
(keep1) bit set.
simpleCigarObject of class logical
indicating, when TRUE, that only 'simple' cigars (empty or 'M') are
returned.
reverseComplementObject of class logical
indicating, when TRUE, that reads on the minus strand are to be
reverse complemented (sequence) and reversed (quality).
tagObject of class character indicating what
tags are to be returned.
whatObject of class character indicating
what fields are to be returned.
whichObject of class RangesList indicating
which reference sequence and coordinate reads must overlap.
See 'Usage' for details on invocation.
Constructor:
Returns a ScanBamParam object. The
which argument to the constructor can be one of several
different types, as documented above.
Accessors:
Returns or sets a character vector of
tags to be extracted.
Returns or sets a character vector
of fields to be extracted.
Returns or sets a RangesList of
bounds on reads to be extracted. A length 0 RangesList
represents all reads.
Returns or sets an integer(2)
representation of reads flagged to be kept or excluded.
Returns or sets a
logical(1) vector indicating whether reads without indels
or clipping be kept.
Returns or sets
a logical(1) vector indicating whether reads on the minus
strand will be returned with sequence reverse complemented and
quality reversed.
Methods:
Compactly display the object.
Martin Morgan
## defaults
p0 <- ScanBamParam()
## subset of reads based on genomic coordinates
which <- RangesList(seq1=IRanges(1000, 2000),
seq2=IRanges(c(100, 1000), c(1000, 2000)))
p1 <- ScanBamParam(which=which)
## subset of reads based on 'flag' value
p2 <- ScanBamParam(flag=scanBamFlag(isMinusStrand=FALSE))
## subset of fields
p3 <- ScanBamParam(what=c("rname", "strand", "pos", "qwidth"))
## use
fl <- system.file("extdata", "ex1.bam", package="Rsamtools")
res <- scanBam(fl, param=p2)[[1]]
lapply(res, head)
## tags; NM: edit distance; H1: 1-difference hits
p4 <- ScanBamParam(tag=c("NM", "H1"), what="flag")
bam4 <- scanBam(fl, param=p4)
str(bam4[[1]][["tag"]])
## flag utils
flag <- scanBamFlag(isUnmappedQuery=FALSE, isMinusStrand=TRUE)
flag
bamFlagAsBitMatrix(flag)
flag4 <- bam4[[1]][["flag"]]
bamFlagAsBitMatrix(flag4[1:9])