Learn R Programming

rbamtools (version 2.16.17)

alignDepth-class: Class "alignDepth": Alignment depth information from bamRange objects.

Description

The alignDepth class represents data and provides plot functions for alignment depth for genomic regions (represented by bamRange objects).

Arguments

Objects from the Class

Objects can be created by calls of the form alignDepth(object,gap)) on bamRange objects. From the bamRange object, the range is extracted and for each nucleotide position whithin this range the numbers of align matches are calculated. When alignDepth is called wich gap=TRUE, the function counts aligns solely for gap-adjacent match regions (cigar-op's).

Slots

depth:

"integer". Align depth values.

%
pos:

"integer". Corresponding (1-based) positions

%
params:

"numeric". Set of internally used parameters

%
refname:

"character". Name of reference sequence from which bamRange was extracted.

Methods

show

signature(object="alignDepth"): Prints a short message with some summarizing data.

%
plotAlignDepth

signature(object="alignDepth", main, xlab, ylab, start, end, transcript, xlim, strand,"..."): Plots align depth in a line-plot.

%
getDepth

signature(object="alignDepth"): Returns numeric align depth values.

%
getPos

signature(object="alignDepth"): Returns numeric position values for align depth.

%
getParams

signature(object="alignDepth"): Returns numeric parameter values.

Details

The params vector contains 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)

Examples

Run this code
# NOT RUN {
# Open (indexed) BAM file
bam<-system.file("extdata", "accepted_hits.bam", package="rbamtools")
reader<-bamReader(bam,idx=TRUE)

# Extract reads from BAM file
xlim = c(10000, 30000)
coords<-c(0,xlim[1], xlim[2])
range<-bamRange(reader,coords)
bamClose(reader)

# Calculate align depth
ad<-alignDepth(range)
ad
getParams(ad)

# Prepare plotting parameter
gene<-"WASH7P"
ensg_id <- "ENSG00000227232"
enst_id <- "ENST00000538476"

# Get exon positions
start<-c(14411,15000,15796,15904,16607,16748,16858,17233,17602,17915,18268,24737,29534)
end <- c(14502,15038,15901,15947,16745,16765,17055,17364,17742,18061,18366,24891,29806)

# Do plot
plotAlignDepth(ad, lwd = 2, xlim = xlim,
            main = paste("Align depth for gene",gene),
            ylab = "Align depth", start = start,
            end = end, strand = "-",
            transcript = paste("Chromosome 1",
            "\tGene", ensg_id, 
            "\tTranscript ",enst_id)
)
# }

Run the code above in your browser using DataLab