AlignedRead-class {ShortRead} | R Documentation

## (Legacy) "AlignedRead" class for aligned short reads

### Description

This class represents and manipulates reads and their genomic alignments. Alignment information includes genomic position, strand, quality, and other data.

### Objects from the Class

Objects of this class can be created from a call to the `AlignedRead` constructor, or more typically by parsing appropriate files (e.g., `readAligned`).

### Slots

`chromosome`

  Object of class `"factor"` the particular sequence within a set of target sequences (e.g. chromosomes in a genome assembly) to which each short read aligns.

`position`

  Object of class `"integer"` the (base-pair) position in the genome to which the read is aligned. AlignedRead objects created by readAligned use 1-based indexing, with alignemnts reported in ‘left-most’ coordinates, as described in the vignette.

`strand`

  Object of class `"factor"` the strand of the alignment.

`alignQuality`

  Object of class `"numeric"` representing an alignment quality score.

`alignData`

  Object of class `"AlignedDataFrame"` additional alignment information.

`quality`

  Object of class `"BStringSet"` representing base-call read quality scores.

`sread`

  Object of class `"DNAStringSet"` DNA sequence of the read.

`id`

  Object of class `"BStringSet"` read identifier.

### Extends

Class `"ShortReadQ"`, directly. Class `"ShortRead"`, by class "ShortReadQ", distance 2. Class `".ShortReadBase"`, by class "ShortReadQ", distance 3.

### Methods

See `accessors` for additional functions to access slot content, and `ShortReadQ`, `ShortRead` for inherited methods. Additional methods include:

[

  `signature(x = "AlignedRead", i = "ANY", j = "missing")`: This method creates a new `AlignedRead` object containing only those reads indexed by `i`. `chromosome` is recoded to contain only those levels in the new subset.

append

  `signature(x = "AlignedRead", values = "AlignedRead")`: append `values` after `x`. `chromosome` and `strand` must be factors with the same levels. See methods for `ShortReadQ`, `AlignedDataFrame` for details of how these components of `x` and `y` are appended.

coerce

  `signature(from = "PairwiseAlignments", to = "AlignedRead")`:

  `signature(from = "AlignedRead", to = "IntegerRangesList")`: `signature(from = "AlignedRead", to = "RangedData")`: `signature(from = "AlignedRead", to = "GRanges")`: `signature(from = "AlignedRead", to = "GAlignments")`: `signature(from = "AlignedRead", to = "GappedReads")`:

  Invoke these methods with, e.g., `as(from, "AlignedRead")` to coerce objects of class `from` to class `"AlignedRead"`.

  Coercion from AlignedRead to IntegerRangesList, RangedData or GRanges assumes that `position(from)` uses a ‘leftmost’ (see `coverage` on this page) coordinate system. Since IntegerRangesList objects cannot store `NA` values, reads with `NA` in the `position`, `width`, `chromosome` or (in the case of GRanges) `strand` vectors are dropped.

chromosome

  `signature(object = "AlignedRead")`: access the chromosome slot of `object`.

position

  `signature(object = "AlignedRead")`: access the position slot of `object`.

strand

  `signature(object = "AlignedRead")`: access the strand slot of `object`.

coverage

  `signature(x = "AlignedRead", shift = 0L, width = NULL, weight = 1L, ..., coords = c("leftmost", "fiveprime"), extend=0L)`:

  Calculate coverage across reads present in `x`.

  `shift` must be either `0L` or a named integer vector with names including all `levels(chromosome(x))`. It specifies how the reads in `x` should be (horizontally) shifted before the coverage is computed.

  `width` must be either `NULL` or a named vector of non-negative integers with names including all `levels(chromosome(x))`. In the latter case, it specifies for each chromosome the end of the chromosome region over which coverage is to be calculated after the reads have been shifted. Note that this region always starts at chromosome position 1. If `width` is `NULL`, it ends at the rightmost chromosome position covered by at least one read.

  `weight` must be `1L` for now (weighting the reads is not supported yet, sorry).

  `coords` specifies the coordinate system used to record position. Both systems number base pairs from left to right on the 5' strand. `leftmost` indicates the eland convention, where `position(x)` is the left-most (minimum) base pair, regardless of strand. `fiveprime` is the MAQ convention, where `position(x)` is the coordinate of the 5' end of the aligned read.

  `extend` indicates the number of base pairs to extend the read. Extension is in the 3' direction, measured from the 3' end of the aligned read.

  The return value of `coverage` is a `SimpleRleList` object.

%in%

  `signature(x = "AlignedRead", table = "IntegerRangesList")`:

  Return a length(x) logical vector indicating whether the chromosome, position, and width of `x` overlap with ranges in `table`. Reads for which `chromosome()`, `position()`, or `width()` return `NA` never overlap with `table`. This function assumes that positions are in ‘leftmost’ coordinates, as defined in `coverage`.

srorder

  `signature(x = "AlignedRead", ..., withSread=TRUE)`:

srrank

  `signature(x = "AlignedRead", ..., withSread=TRUE)`:

srsort

  `signature(x = "AlignedRead", ..., withSread=TRUE)`:

srduplicated

  `signature(x = "AlignedRead", ..., withSread=TRUE)`:

  Order, rank, sort, and find duplicates in `AlignedRead` objects. Reads are sorted by `chromosome`, `strand`, `position`, and then (if `withSread=TRUE`) `sread`; less fine-grained sorting can be accomplished with, e.g., `x[srorder(sread(x))]`. `srduplicated` behaves like `duplicated`, i.e., the first copy of a duplicate is `FALSE` while the remaining copies are `TRUE`.

show

  `signature(object = "AlignedRead")`: provide a compact display of the `AlignedRead` content.

detail

  `signature(x = "AlignedRead")`: display `alignData` in more detail.

### Author(s)

Martin Morgan <mtmorgan@fhcrc.org>

### See Also

`readAligned`

### Examples

    showMethods(class="AlignedRead", where=getNamespace("ShortRead"))
    dirPath <- system.file('extdata', 'maq', package='ShortRead')
    (aln <- readAligned(dirPath, 'out.aln.1.txt', type="MAQMapview"))
    coverage(aln)[[1]]
    cvg <- coverage(aln, shift=c(ChrA=10L))
    ## remove 0 coverage on left ends
    ltrim0 <- function(x) {
        i <- !cumprod(runValue(x) == 0)
        Rle(runValue(x)[i], runLength(x)[i])
    }
    endoapply(cvg, ltrim0)
    ## demonstration of show() and detail() methods
    show(aln)
    detail(aln)

[Package ShortRead version 1.38.0 Index]