AlignedReadTrack-class {Gviz} | R Documentation

## AlignedReadTrack class and methods (NOTE: THIS IS STILL IN DEVELOPMENT AND SUBJECT TO CHANGE)

### Description

A class to represent short sequences that have been aligned to a reference genome as they are typically generated in a next generation sequencing experiment.

### Usage

    AlignedReadTrack(range=NULL, start=NULL, end=NULL, width=NULL, chromosome, strand, genome,
    stacking="squish", name="AlignedReadTrack", coverageOnly=FALSE, ...)

### Arguments

`range` | An object of class `GRanges`, or a `data.frame` which will be coerced into one in which case it needs to contain at least the three columns: `start`, `end`: the start and end coordinates for the track items. `strand`: the strand information for the track items. It may be provided in the form `+` for the Watson strand, `-` for the Crick strand or `*` for either one of the two. Alternatively, the `range` argument may be missing, in which case the relevant information has to be provided as individual function arguments (see below).
`start, end, width` | Integer vectors, giving the start and the end end coordinates for the individual track items, or their width. Two of the three need to be specified, and have to be of equal length or of length one, in which case this value will be recycled. Otherwise, the usual R recycling rules for vectors do not apply.
`strand` | Character vector, the strand information for the individual track items. Needs to be of equal length as the `start, end` or `width` vectors, or of length 1. Please note that grouped items need to be on the same strand, and erroneous entries will result in casting of an error.
`chromosome` | The chromosome on which the track's genomic ranges are defined. A valid UCSC chromosome identifier. Please note that at this stage only syntactic checking takes place, i.e., the argument value needs to be a single integer, numeric character or a character of the form `chrx`, where x may be any possible string. The user has to make sure that the respective chromosome is indeed defined for the the track's genome.
`genome` | The genome on which the track's ranges are defined. Usually this is a valid UCSC genome identifier, however this is not being formally checked at this point.
`stacking` | The stacking type for overlapping items of the track. One in `c(hide, dense, squish, pack,full)`. Currently, only hide (don't show the track items, squish (make best use of the available space) and dense (no stacking at all) are implemented.
`name` | Character scalar of the track's name used in the title panel when plotting.
`coverageOnly` | Instead of storing individual reads, just compute the coverage and store the resulting coverage vector.
`...` | Additional items which will all be interpreted as further display parameters.

### Value

The return value of the constructor function is a new object of class `AlignedReadTrack`.

### Objects from the Class

Objects can be created using the constructor function `AlignedReadTrack`.

### Slots

`coverage`:

  Object of class `"list"`, a list of coverage vectors for the plus strand, the minus strand and for both strands combined.

`coverageOnly`:

  Object of class `"logical"`, flag to determine whether the object stores read locations or the coverage vectors only.

`stacking`:

  Object of class `"character"`, inherited from class `StackedTrack`

`stacks`:

  Object of class `"environment"`, inherited from class `StackedTrack`

`range`:

  Object of class `GRanges`, inherited from class `RangeTrack`

`chromosome`:

  Object of class `"character"`, inherited from class `RangeTrack`

`genome`:

  Object of class `"character"`, inherited from class `RangeTrack`

`dp`:

  Object of class `DisplayPars`, inherited from class `GdObject`

`name`:

  Object of class `"character"`, inherited from class `GdObject`

`imageMap`:

  Object of class `ImageMap`, inherited from class `GdObject`

### Extends

Class `"StackedTrack"`, directly.

Class `"RangeTrack"`, by class "StackedTrack", distance2.

Class `"GdObject"`, by class "StackedTrack", distance3.

### Methods

In the following code chunks, `obj` is considered to be an object of class `AlignedReadTrack`.

Exported in the name space:

[

  `signature(x="AlignedReadTrack")`: subset the items in the `AlignedReadTrack`. This is essentially similar to subsetting of the `GRanges` object in the `range` slot. For most applications, the `subset` method may be more appropriate. The operation is only supported for objects that still contain all the read locations, i.e., `coverageOnly=FALSE`.

  Additional Arguments:

    `i`: subsetting indices

  Examples:

    `obj[1:5]`

subset

  `signature(x="AlignedReadTrack")`: subset a `AlignedReadTrack` by coordinates and sort if necessary.

  Usage:

  `subset(x, from, to, sort=FALSE, stacks=FALSE)`

  Additional Arguments:

    `from`, `to`: the coordinates range to subset to.

    `sort`: sort the object after subsetting. Usually not necessary.

    `stacks`: recompute the stacking after subsetting which can be expensive and is not always necessary.

  Examples:

    `subset(obj, from=10, to=20)`

    `subset(obj, from=10, to=20, sort=TRUE, stacks=FALSE)`

split

  `signature(x="AlignedReadTrack")`: split an `AlignedReadTrack` object by an appropriate factor vector (or another vector that can be coerced into one). The output of this operation is a list of `AlignedReadTrack` objects.

  Additional Arguments:

    `f`: the splitting factor.

    `...`: all further arguments are ignored.

  Usage:

  `split(x, f, ...)`

  Examples:

    `split(obj, c("a", "a", "b", "c", "a"))`

coverage

  `signature(x="AlignedReadTrack")`: return the coverage vector for one of the strands, or the combined vector.

  Usage:

  `coverage(x, strand="*")`

  Additional Arguments:

    `strand`: the selector for the strand, `+` for the Watson strand, `-` for the Crick strand or `*` for both strands.

  Examples:

    `coveraget(obj)`

    `coverage(obj, strand="-")`

Internal methods:

setCoverage

  `signature(GdObject="AlignedReadTrack")`: recompute the coverage on the plus and minus strand as well as for the combined strands and update the respective slot.

  Usage:

  `setCoverage(GdObject)`

  Examples:

    `setCoverage(obj)`

drawAxis

  `signature(GdObject="AlignedReadTrack")`: add a y-axis to the title panel of a track.

  Usage:

  `drawAxis(GdObject, from, to, subset=FALSE, ...)`

  Additional Arguments:

    `from`, `to`: compute axis range from the data within a certain coordinates range only.

    `subset`: subset the object prior to calculating the axis ranges. Can be expensive and is not always needed.

    `...`: all further arguments are ignored.

  Examples:

    `Gviz:::drawAxis(obj)`

drawGD

  `signature(gdObject="AlignedReadTrack")`: plot the object to a graphics device. The return value of this method is the input object, potentially updated during the plotting operation. Internally, there are two modes in which the method can be called. Either in 'prepare' mode, in which case no plotting is done but the object is preprocessed based on the available space, or in 'plotting' mode, in which case the actual graphical output is created. Since subsetting of the object can be potentially costly, this can be switched off in case subsetting has already been performed before or is not necessary.

  Usage:

  `drawGD(GdObject, minBase, maxBase, prepare=FALSE, subset=TRUE, ...)`

  Additional Arguments:

    `minBase`, `maxBase`: the coordinate range to plot.

    `prepare`: run method in preparation or in production mode.

    `subset`: subset the object to the visible region or skip the potentially expensive subsetting operation.

    `...`: all further arguments are ignored.

  Examples:

    `Gviz:::drawGD(obj)`

    `Gviz:::drawGD(obj, minBase=1, maxBase=100)`

    `Gviz:::drawGD(obj, prepare=TRUE, subset=FALSE)`

drawGrid

  `signature(GdObject="AlignedReadTrack")`: superpose a grid on top of a track.

  Usage:

  `drawGrid(GdObject, from, to)`

  Additional Arguments:

    `from`, `to`: draw grid within a certain coordinates range. This needs to be supplied for the plotting function to know the current genomic coordinates.

  Examples:

    `Gviz:::drawGrid(obj, from=10, to=100)`

initialize

  `signature(.Object="AligendReadTrack")`: initialize the object.

show

  `signature(object="AlignedReadTrack")`: show a human-readable summary of the object.

Inherited methods:

stacking

  `signature(GdObject="AlignedReadTrack")`: return the current stacking type.

  Usage:

  `stacking(GdObject)`

  Examples:

    `stacking(obj)`

stacking<-

  `signature(GdObject="AlignedReadTrack", value="character")`: set the object's stacking type to one in `c(hide, dense, squish, pack,full)`.

  Usage:

  `stacking<-(GdObject, value)`

  Additional Arguments:

    `value`: replacement value.

  Examples:

    `stacking(obj) <- "squish"`

setStacks

  `signature(GdObject="AlignedReadTrack")`: recompute the stacks based on the available space and on the object's track items and stacking settings.

  Usage:

  `setStacks(GdObject, from, to)`

  Additional Arguments:

    `from`, `to`: compute stacking within a certain coordinates range. This needs to be supplied for the plotting function to know the current genomic coordinates.

  Examples:

    `Gviz:::setStacks(obj)`

stacks

  `signature(GdObject="AlignedReadTrack")`: return the stack indices for each track item.

  Usage:

  `stacks(GdObject)`

  Examples:

    `Gviz:::stacks(obj)`

chromosome

  `signature(GdObject="AlignedReadTrack")`: return the chromosome for which the track is defined.

  Usage:

  `chromosome(GdObject)`

  Examples:

    `chromosome(obj)`

chromosome<-

  `signature(GdObject="AlignedReadTrack")`: replace the value of the track's chromosome. This has to be a valid UCSC chromosome identifier or an integer or character scalar that can be reasonably coerced into one.

  Usage:

  `chromosome<-(GdObject, value)`

  Additional Arguments:

    `value`: replacement value.

  Examples:

    `chromosome(obj) <- "chr12"`

start, end, width

  `signature(x="AlignedReadTrack")`: the start or end coordinates of the track items, or their width in genomic coordinates.

  Usage:

  `start(x)`

  `end(x)`

  `width(x)`

  Examples:

    `start(obj)`

    `end(obj)`

    `width(obj)`

start<-, end<-, width<-

  `signature(x="AlignedReadTrack")`: replace the start or end coordinates of the track items, or their width.

  Usage:

  `start<-(x, value)`

  `end<-(x, value)`

  `width<-(x, value)`

  Additional Arguments:

    `value`: replacement value.

  Examples:

    `start(obj) <- 1:10`

    `end(obj) <- 20:30`

    `width(obj) <- 1`

position

  `signature(GdObject="AlignedReadTrack")`: the arithmetic mean of the track item's coordionates, i.e., `(end(obj)-start(obj))/2`.

  Usage:

  `position(GdObject)`

  Examples:

    `position(obj)`

feature

  `signature(GdObject="AlignedReadTrack")`: return the grouping information for track items. For certain sub-classes, groups may be indicated by different color schemes when plotting. See `grouping` or `AnnotationTrack` and `GeneRegionTrack` for details.

  Usage:

  `feature(GdObject)`

  Examples:

    `feature(obj)`

feature<-

  `signature(gdObject="AlignedReadTrack", value="character")`: set the grouping information for track items. This has to be a factor vector (or another type of vector that can be coerced into one) of the same length as the number of items in the `AlignedReadTrack`. See `grouping` or `AnnotationTrack` and `GeneRegionTrack` for details.

  Usage:

  `feature<-(GdObject, value)`

  Additional Arguments:

    `value`: replacement value.

  Examples:

    `feature(obj) <- c("a", "a", "b", "c", "a")`

genome

  `signature(x="AlignedReadTrack")`: return the track's genome.

  Usage:

  `genome(x)`

  Examples:

    `genome(obj)`

genome<-

  `signature(x="AlignedReadTrack")`: set the track's genome. Usually this has to be a valid UCSC identifier, however this is not formally enforced here.

  Usage:

  `genome<-(x, value)`

  Additional Arguments:

    `value`: replacement value.

  Examples:

    `genome(obj) <- "mm9"`

length

  `signature(x="AlignedReadTrack")`: return the number of items in the track.

  Usage:

  `length(x)`

  Examples:

    `length(obj)`

range

  `signature(x="AlignedReadTrack")`: return the genomic coordinates for the track as an object of class `IRanges`.

  Usage:

  `range(x)`

  Examples:

    `range(obj)`

ranges

  `signature(x="AlignedReadTrack")`: return the genomic coordinates for the track along with all additional annotation information as an object of class `GRanges`.

  Usage:

  `ranges(x)`

  Examples:

    `ranges(obj)`

strand

  `signature(x="AlignedReadTrack")`: return a vector of strand specifiers for all track items, in the form '+' for the Watson strand, '-' for the Crick strand or '*' for either of the two.

  Usage:

  `strand(x)`

  Examples:

    `strand(obj)`

strand<-

  `signature(x="AlignedReadTrack")`: replace the strand information for the track items. The replacement value needs to be an appropriate scalar or vector of strand values.

  Usage:

  `strand<-(x, value)`

  Additional Arguments:

    `value`: replacement value.

  Examples:

    `strand(obj) <- "+"`

values

  `signature(x="AlignedReadTrack")`: return all additional annotation information except for the genomic coordinates for the track items as a data.frame.

  Usage:

  `values(x)`

  Examples:

    `values(obj)`

coerce

  `signature(from="AlignedReadTrack", to="data.frame")`: coerce the `GRanges` object in the `range` slot into a regular data.frame.

  Examples:

    `as(obj, "data.frame")`

displayPars

  `signature(x="AlignedReadTrack", name="character")`: list the value of the display parameter `name`. See `settings` for details on display parameters and customization.

  Usage:

  `displayPars(x, name)`

  Examples:

    `displayPars(obj, "col")`

displayPars

  `signature(x="AlignedReadTrack", name="missing")`: list the value of all available display parameters. See `settings` for details on display parameters and customization.

  Examples:

    `displayPars(obj)`

getPar

  `signature(x="AlignedReadTrack", name="character")`: alias for the `displayPars` method. See `settings` for details on display parameters and customization.

  Usage:

  `getPar(x, name)`

  Examples:

    `getPar(obj, "col")`

getPar

  `signature(x="AlignedReadTrack", name="missing")`: alias for the `displayPars` method. See `settings` for details on display parameters and customization.

  Examples:

    `getPar(obj)`

displayPars<-

  `signature(x="AlignedReadTrack", value="list")`: set display parameters using the values of the named list in `value`. See `settings` for details on display parameters and customization.

  Usage:

  `displayPars<-(x, value)`

  Examples:

    `displayPars(obj) <- list(col="red", lwd=2)`

setPar

  `signature(x="AlignedReadTrack", value="character")`: set the single display parameter `name` to `value`. Note that display parameters in the `AlignedReadTrack` class are pass-by-reference, so no re-assignmnet to the symbol `obj` is necessary. See `settings` for details on display parameters and customization.

  Usage:

  `setPar(x, name, value)`

  Additional Arguments:

    `name`: the name of the display parameter to set.

  Examples:

    `setPar(obj, "col", "red")`

setPar

  `signature(x="AlignedReadTrack", value="list")`: set display parameters by the values of the named list in `value`. Note that display parameters in the `AlignedReadTrack` class are pass-by-reference, so no re-assignmnet to the symbol `obj` is necessary. See `settings` for details on display parameters and customization.

  Examples:

    `setPar(obj, list(col="red", lwd=2))`

group

  `signature(GdObject="AlignedReadTrack")`: return grouping information for the individual items in the track. Unless overwritten in one of the sub-classes, this usualy returns `NULL`.

  Usage:

  `group(GdObject)`

  Examples:

    `group(obj)`

names

  `signature(x="AlignedReadTrack")`: return the value of the `name` slot.

  Usage:

  `names(x)`

  Examples:

    `names(obj)`

names<-

  `signature(x="AlignedReadTrack", value="character")`: set the value of the `name` slot.

  Usage:

  `names<-(x, value)`

  Examples:

    `names(obj) <- "foo"`

coords

  `signature(ImageMap="AlignedReadTrack")`: return the coordinates from the internal image map.

  Usage:

  `coords(ImageMap)`

  Examples:

    `coords(obj)`

tags

  `signature(x="AlignedReadTrack")`: return the tags from the internal image map.

  Usage:

  `tags(x)`

  Examples:

    `tags(obj)`

### Display Parameters

The following display parameters are set for objects of class `AlignedReadTrack` upon instantiation, unless one or more of them have already been set by one of the optional sub-class initializers, which always get precedence over these global defaults. See `settings` for details on setting graphical parameters for tracks.

  `collapse=FALSE`: collapse overlapping ranges and aggregate the underlying data.

  `detail="coverage"`: the amount of detail to plot the data. Either `coverage` to show the coverage only, or `reads` to show individual reads. For large data sets the latter can be very inefficient. Please note that `reads` is only available when the object has been created with option `coverageOnly=FALSE`.

  `fill="#0080ff"`: the fill color for the coverage indicator.

  `size=NULL`: the relative size of the track. Defaults to size selection based on the underlying data. Can be overridden in the `plotTracks` function.

  `type="histogram"`: the plot type, one or several in `c("p","l", "b", "a", "s", "g", "r", "S", "smooth", "histogram", "mountain", "polygon", "h", "boxplot", "gradient", "heatmap", "horizon")`. See the 'Details' section in `DataTrack` for more information on the individual plotting types.

Additional display parameters are being inherited from the respective parent classes. Note that not all of them may have an effect on the plotting of `AlignedReadTrack` objects.

  `StackedTrack`:

    `reverseStacking=FALSE`: Logical flag. Reverse the y-ordering of stacked items. I.e., features that are plotted on the bottom-most stacks will be moved to the top-most stack and vice versa.

    `stackHeight=0.75`: Numeric between 0 and 1. Controls the vertical size and spacing between stacked elements. The number defines the proportion of the total available space for the stack that is used to draw the glyphs. E.g., a value of 0.5 means that half of the available vertical drawing space (for each stacking line) is used for the glyphs, and thus one quarter of the available space each is used for spacing above and below the glyph. Defaults to 0.75.

  `GdObject`:

    `alpha=1`: Numeric scalar. The transparency for all track items.

    `alpha.title=NULL`: Numeric scalar. The transparency for the title panel.

    `background.legend="transparent"`: Integer or character scalar. The background color for the legend.

    `background.panel="transparent"`: Integer or character scalar. The background color of the content panel.

    `background.title="lightgray"`: Integer or character scalar. The background color for the title panel.

    `cex=1`: Numeric scalar. The overall font expansion factor for all text and glyphs, unless a more specific definition exists.

    `cex.axis=NULL`: Numeric scalar. The expansion factor for the axis annotation. Defaults to `NULL`, in which case it is automatically determined based on the available space.

    `cex.title=NULL`: Numeric scalar. The expansion factor for the title panel. This effects the fontsize of both the title and the axis, if any. Defaults to `NULL`, which means that the text size is automatically adjusted to the available space.

    `col="#0080FF"`: Integer or character scalar. Default line color setting for all plotting elements, unless there is a more specific control defined elsewhere.

    `col.axis="white"`: Integer or character scalar. The font and line color for the y axis, if any.

    `col.border.title="white"`: Integer or character scalar. The border color for the title panels.

    `col.frame="lightgray"`: Integer or character scalar. The line color used for the panel frame, if `frame==TRUE`

    `col.grid="#808080"`: Integer or character scalar. Default line color for grid lines, both when `type=="g"` in `DataTrack`s and when display parameter `grid==TRUE`.

    `col.line=NULL`: Integer or character scalar. Default colors for plot lines. Usually the same as the global `col` parameter.

    `col.symbol=NULL`: Integer or character scalar. Default colors for plot symbols. Usually the same as the global `col` parameter.

    `col.title="white"` `(Aliases: fontcolor.title)`: Integer or character scalar. The border color for the title panels

    `fontcolor="black"`: Integer or character scalar. The font color for all text, unless a more specific definition exists.

    `fontface=1`: Integer or character scalar. The font face for all text, unless a more specific definition exists.

    `fontface.title=2`: Integer or character scalar. The font face for the title panels.

    `fontfamily="sans"`: Integer or character scalar. The font family for all text, unless a more specific definition exists.

    `fontfamily.title="sans"`: Integer or character scalar. The font family for the title panels.

    `fontsize=12`: Numeric scalar. The font size for all text, unless a more specific definition exists.

    `frame=FALSE`: Boolean. Draw a frame around the track when plotting.

    `grid=FALSE`: Boolean, switching on/off the plotting of a grid.

    `h=-1`: Integer scalar. Parameter controlling the number of horizontal grid lines, see `panel.grid` for details.

    `lineheight=1`: Numeric scalar. The font line height for all text, unless a more specific definition exists.

    `lty="solid"`: Numeric scalar. Default line type setting for all plotting elements, unless there is a more specific control defined elsewhere.

    `lty.grid="solid"`: Integer or character scalar. Default line type for grid lines, both when `type=="g"` in `DataTrack`s and when display parameter `grid==TRUE`.

    `lwd=1`: Numeric scalar. Default line width setting for all plotting elements, unless there is a more specific control defined elsewhere.

    `lwd.border.title=1`: Integer scalar. The border width for the title panels.

    `lwd.grid=1`: Numeric scalar. Default line width for grid lines, both when `type=="g"` in `DataTrack`s and when display parameter `grid==TRUE`.

    `lwd.title=1`: Integer scalar. The border width for the title panels

    `min.distance=1`: Numeric scalar. The minimum pixel distance before collapsing range items, only if `collapse==TRUE`. See `collapsing` for details.

    `min.height=3`: Numeric scalar. The minimum range height in pixels to display. All ranges are expanded to this size in order to avoid rendering issues. See `collapsing` for details.

    `min.width=1`: Numeric scalar. The minimum range width in pixels to display. All ranges are expanded to this size in order to avoid rendering issues. See `collapsing` for details.

    `reverseStrand=FALSE`: Logical scalar. Set up the plotting coordinates in 3' -> 5' direction if `TRUE`. This will effectively mirror the plot on the vertical axis.

    `rotation=0`: The rotation angle for all text unless a more specific definiton exists.

    `rotation.title=90` `(Aliases: rotation.title)`: The rotation angle for the text in the title panel. Even though this can be adjusted, the automatic resizing of the title panel will currently not work, so use at own risk.

    `showAxis=TRUE`: Boolean controlling whether to plot a y axis (only applies to track types where axes are implemented).

    `showTitle=TRUE`: Boolean controlling whether to plot a title panel. Although this can be set individually for each track, in multi-track plots as created by `plotTracks` there will still be an empty placeholder in case any of the other tracks include a title. The same holds true for axes. Note that the the title panel background color could be set to transparent in order to completely hide it.

    `v=-1`: Integer scalar. Parameter controlling the number of vertical grid lines, see `panel.grid` for details.

### Author(s)

Florian Hahne

### See Also

`AnnotationTrack`

`DataTrack`

`DisplayPars`

`GRanges`

`GdObject`

`GeneRegionTrack`

`IRanges`

`ImageMap`

`RangeTrack`

`StackedTrack`

`collapsing`

`grouping`

`panel.grid`

`plotTracks`

`settings`

### Examples

    ## Construct from individual arguments
    arTrack <- AlignedReadTrack(start=runif(1000, 100, 200), width=24,
    genome="mm9", chromosome=7, strand=sample(c("+", "-"), 1000, TRUE))

    ## Plotting
    plotTracks(arTrack)

    ## Track names
    names(arTrack)
    names(arTrack) <- "foo"
    plotTracks(arTrack)

    ## Subsetting and splitting
    subTrack <- subset(arTrack, from=110, to=130)
    length(subTrack)
    subTrack[1:2]
    split(arTrack, strand(arTrack))

    ## Accessors
    start(arTrack)
    end(arTrack)
    width(arTrack)
    position(arTrack)
    width(subTrack) <- 30

    strand(arTrack)
    strand(subTrack) <- "-"

    chromosome(arTrack)
    chromosome(subTrack) <- "chrX"

    genome(arTrack)
    genome(subTrack) <- "mm9"

    range(arTrack)
    ranges(arTrack)

    coverage(arTrack)

    ## Annotation
    values(arTrack)

    ## Stacking
    stacking(arTrack)
    stacking(arTrack) <- "dense"

    ## coercion
    as(arTrack, "data.frame")

[Package Gviz version 1.28.3 Index]