Learn R Programming

GenomicAlignments (version 1.8.1)

GAlignmentPairs-class: GAlignmentPairs objects

Description

The GAlignmentPairs class is a container for genomic alignment pairs.

IMPORTANT NOTE: The GAlignmentPairs container can only hold concordant pairs at the moment, that is, pairs where the 2 alignments are on the opposite strands of the same reference sequence.

Arguments

Details

A GAlignmentPairs object is a list-like object where each element describes a pair of genomic alignment.

An "alignment pair" is made of a "first" and a "last"/"second" alignment, and is formally represented by a GAlignments object of length 2. It is typically representing a hit of a paired-end read to the reference genome that was used by the aligner. More precisely, in a given pair, the "first" alignment represents the hit of the first end of the read (aka "first segment in the template", using SAM Spec terminology), and the "last" alignment represents the hit of the second end of the read (aka "last segment in the template", using SAM Spec terminology).

In general, a GAlignmentPairs object will be created by loading records from a BAM (or SAM) file containing aligned paired-end reads, using the readGAlignmentPairs function (see below). Each element in the returned object will be obtained by pairing 2 records.

See Also

  • readGAlignmentPairsfor reading aligned paired-end reads from a file (typically a BAM file) into a GAlignmentPairs object.
  • GAlignmentsobjects for handling aligned single-end reads.
  • makeGAlignmentPairsfor pairing the elements of aGAlignmentsobject into a GAlignmentPairs object.
  • junctions-methodsfor extracting and summarizing junctions from a GAlignmentPairs object.
  • coverage-methodsfor computing the coverage of a GAlignmentPairs object.
  • findOverlaps-methodsfor finding range overlaps between a GAlignmentPairs object and another range-based object.
  • seqinfoin theGenomeInfoDbpackage for getting/setting/modifying the sequence information stored in an object.
  • TheGRangesandGRangesListclasses defined and documented in theGenomicRangespackage.

Examples

Run this code
library(Rsamtools)  # for the ex1.bam file
ex1_file <- system.file("extdata", "ex1.bam", package="Rsamtools")
galp <- readGAlignmentPairs(ex1_file, use.names=TRUE, strandMode=1)
galp

length(galp)
head(galp)
head(names(galp))

first(galp)
last(galp)
# or
second(galp)

strandMode(galp)
first(galp, real.strand=TRUE)
last(galp, real.strand=TRUE)
strand(galp)

strandMode(galp) <- 2
first(galp, real.strand=TRUE)
last(galp, real.strand=TRUE)
strand(galp)

seqnames(galp)

head(njunc(galp))
table(isProperPair(galp))
seqlevels(galp)

## Rename the reference sequences:
seqlevels(galp) <- sub("seq", "chr", seqlevels(galp))
seqlevels(galp)

galp[[1]]
unlist(galp)

grglist(galp)  # a GRangesList object

strandMode(galp) <- 1
grglist(galp)

stopifnot(identical(unname(elementNROWS(grglist(galp))), njunc(galp) + 2L))

granges(galp)  # a GRanges object

Run the code above in your browser using DataLab