bamRange-class: Class '"bamRange"': Representation of genomic alignments in...

Description Details Objects from the Class Slots Methods Author(s) Examples

Description

bamRange represents a double linked list of bamAlign objects which overlap with a defined region in a BAM-file. The bamRange-function retrieves all alignments in the depicted Range from BAM-File into a bamRange object. A bamRange object maintains a double-linked list of aligns. The list keeps a pointer to a current align structure for iteration purposes. Addidionally there are some summarizing values stored (which are displayed by show) which describe the range inside the reference from which the bamRange object was read (seqid, qrBegin, qrEnd, complex) and some statistis (size, qSeqMinLen, qSeqMaxLen).

Details

bamRange objects internally keep the following values:

1 seqid 0-based index of reference sequence
2 qrBegin 0-based left boundary of query region (query range begin)
3 qrEnd 0-based right boundary of query region (query range end)
4 complex 0= all aligns included, 1= only aligns with n_cigar > 1 included
5 rSeqLen Length of reference sequence
6 qSeqMinLen Minimum of query sequence length (= read length)
7 qSeqMaxLen Maximum of query sequence length (= read length)

For the bamRange class exists a rudimentary subsetting ('[') operator. '[' allows only for indexes > 0 and <= size(x). Index values are sorted in ascending order before values are extracted.

Objects from the Class

Objects can be created by calls of the form range<-bamRange(reader, coords).

Slots

range:

External pointer. Points to double linked list of bamAligns.

Methods

as.data.frame

signature(x="bamRange"): Returns data.frame representation of aligns.

coerce

signature(from="bamRange", to="data.frame"): Coercion of bamRange to data.frame.

bamSave

signature(object="bamRange"): Saves aligns stored in this list to BAM-file via a bamWriter object.

getAlignRange

signature(object="bamRange"): Iterates through the list and returns 0-based position of the leftmost and rightmost matching nucleotide in range.

getNextAlign

signature(object="bamRange"): Returns next align from current position and shifts current position to next one.

getParams

signature(object="bamRange"): Returns named vector of stored parameters

getPrevAlign

signature(object="bamRange"): Returns previous align from current position and shifts current position to previous one.

getRefName

signature(.Object="bamRange"): Returns the reference sequence name from which the range was retrieved.

getQualDf

signature(object="bamRange", prob="logical"): Returns position dependent counts of phred quality values.

getQualQuantiles

signature(object="bamRange", quantiles="numeric"): Returns position dependent quantile values for phred scores.

plotQualQuant

signature(object="bamRange"): Plots phred quality quantiles for sequence positions.

initialize

signature(.Object="bamRange"): Initializes bamRange object.

insertPastCurrent

signature(object="bamRange"): Inserts align past current position into list.

insertPreCurrent

signature(object="bamRange"): Insert align before current position into list.

pop_back

signature(object="bamRange"): Removes last align from list.

pop_front

signature(object="bamRange"): Removes first align from list.

push_back

signature(object="bamRange"): Adds align at the end of the list.

push_front

signature(object="bamRange"): Adds align at the front of the list.

rewind

signature(object="bamRange"): Shifts current align to position before first align.

size

signature(object="bamRange"): Returns number of aligns in list.

writeCurrentAlign

signature(object="bamRange"): Overwrites current align with given align.

Author(s)

Wolfgang Kaisers

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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
## + + + + + + + + + + + + + + + + + + + + + + + + + + + ##
## A) Open reader
## + + + + + + + + + + + + + + + + + + + + + + + + + + + ##
bam <- system.file("extdata", "accepted_hits.bam", package="rbamtools")
idx<-paste(bam,"bai",sep=".")
# Open BAM file
reader<-bamReader(bam)
createIndex(reader,idx)
# Load BAM index file
loadIndex(reader,idx)
indexInitialized(reader)   # Should return 'TRUE'

## + + + + + + + + + + + + + + + + + + + + + + + + + + + ##
## B) Read range
## + + + + + + + + + + + + + + + + + + + + + + + + + + + ##
#  Find appropriate refid (=ID)
#  Returns a data.frame with three columns:
#  ID=refid, SN=Sequence Name, LN=Sequence length

rdf<-getRefData(reader)
head(rdf)

## + + + + + + + + + + + + + + + + + + + + + + + + + + + ##
# The sequence length (LN) also determines valid
# range for start and stop coordinates
# Invalid refid-, start- or stop-coordinates will
# release an error.
# coords: refid=0, start=0, stop=249250621
## + + + + + + + + + + + + + + + + + + + + + + + + + + + ##
coords <- as.integer(c(0, 0, 249250621))
range <- bamRange(reader, coords)
size(range)
range <- bamRange(reader, coords, complex=TRUE)
dfr <- as.data.frame(range)
size(range)
align <- getNextAlign(range)
cigarData(align)
rewind(range)

# Alterative way of reading Range
range <- readRange(reader, "chr1", c(0,249250621))
size(range)
range <- readRange(reader, "chr1", c(0,249250621), complex=TRUE)
size(range)

# Print align positions

while(!is.null(align))
{
    print(position(align))
    align<-getNextAlign(range)
}

bamClose(reader)

## + + + + + + + + + + + + + + + + + + + + + + + + + + + ##
## C) Get print message and some other values
## + + + + + + + + + + + + + + + + + + + + + + + + + + + ##
range
getCoords(range)
getSeqLen(range)
getParams(range)
getRefName(range)
getAlignRange(range)

## + + + + + + + + + + + + + + + + + + + + + + + + + + + ##
## D) Rudimentary subsetting
## + + + + + + + + + + + + + + + + + + + + + + + + + + + ##
range[1:5]

rbamtools documentation built on Nov. 11, 2019, 5:09 p.m.