The virtual parent class for all track types in the Gviz package which contain potentially overlapping annotation items that have to be stacked when plotted.
# S4 method for StackedTrack
initialize(.Object, stacking, ...)
# S4 method for StackedTrack
stacking(GdObject)
# S4 method for StackedTrack,character
stacking(GdObject) <- value
# S4 method for StackedTrack
stacks(GdObject)
# S4 method for StackedTrack
setStacks(GdObject, ...)
# S4 method for StackedTrack
consolidateTrack(GdObject, ...)
# S4 method for StackedTrack,ANY,ANY,ANY
[(x, i, j, ..., drop = TRUE)
# S4 method for StackedTrack
subset(x, from = NULL, to = NULL, sort = FALSE, stacks = FALSE, ...)
# S4 method for StackedTrack
drawGD(GdObject, ...)
.Object
stacking
Additional arguments.
Object of GdObject-class
.
Value to be set.
A valid track object class name, or the object itself, in which case the class is derived directly from it.
Numeric scalar, index to subset.
Numeric scalar, index to subset. Ignored.
logical
, indicating if levels that do not occur should be dropped (if f
is a factor).
Numeric scalar, giving the range of genomic coordinates to
limit the tracks in. Note that to
cannot be larger than from.
logical
.
logical
. Set if stacking should be preserved.
A virtual Class: No objects may be created from it.
initialize(StackedTrack)
: Initialize.
stacking(StackedTrack)
: return the current stacking type.
stacking(GdObject = StackedTrack) <- value
: set the object's stacking type to one in
c(hide, dense, squish, pack,full)
.
stacks(StackedTrack)
: return the stack indices for each track item.
setStacks(StackedTrack)
: recompute the stacks based on the available
space and on the object's track items and stacking settings.
consolidateTrack(StackedTrack)
: Consolidate.
a display parameter)
x[i
: subset the items in the StackedTrack
object.
This is essentially similar to subsetting of the GRanges
object in the
range slot. For most applications, the subset method may be more appropriate.
subset(StackedTrack)
: subset a StackedTrack
by coordinates and sort if necessary.
drawGD(StackedTrack)
: 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 stacking information is updated based on the
available space, or in 'plotting' mode, in which case the actual graphical
output is created. Note that the method for this particular subclass is
usually called through inheritance and not particularly useful on its own.
dp
Object of DisplayPars-class
, the display settings controlling the
look and feel of a track. See settings for details on setting graphical
parameters for tracks.
name
Object of class character
, a human-readable name for the track
that will be used in the track's annotation panel if necessary.
imageMap
Object of ImageMap-class
, containing optional information
for an HTML image map. This will be created by the drawGD
methods when the
track is plotted to a device and is usually not set by the user.
range
Object of class GRanges
, the genomic ranges of the track items
as well as additional annotation information in its elementMetaData
slot.
Please not that the slot is actually implemented as a class union between
GRanges
and IRanges to increase efficiency, for instance for DataTrack
objects. This usually does not concern the user.
chromosome
Object of class character
, the chromosome on which the
track is defined. There can only be a single chromosome for one track. For
certain subclasses, the space of allowed chromosome names is limited (e.g.,
only those chromosomes that exist for a particular genome). Throughout the
package, chromosome name have to be entered either as a single integer scalar
or as a character scalar of the form chrXYZ, where XYZ may be an arbitrary
character string.
genome
Object of class character
, the genome for which the track is
defined. For most sub-classes this has to be valid UCSC genome identifier,
however this may not always be formally checked upon object instantiation.
stacking
Object of class character
, the stacking type of overlapping
items on the final plot. One in c(hide, dense, squish, pack,full)
.
Currently, only hide
(do not show the track items at all), squish
(make
best use of the available space) and dense
(no stacking at all) are
implemented.
stacks
Object of class numeric
, holding the stack indices for each
track item. This slot is usually populated by calling the setStacks
method
upon plotting, since the correct stacking is a function of the available
plotting space.
## This is a reference class therefore we show below
## an example from AnnotationTrack
## An empty object
AnnotationTrack()
#> AnnotationTrack 'AnnotationTrack'
#> | genome: NA
#> | active chromosome: chrNA
#> | annotation features: 0
## Construct from individual arguments
st <- c(2000000, 2070000, 2100000, 2160000)
ed <- c(2050000, 2130000, 2150000, 2170000)
str <- c("-", "+", "-", "-")
gr <- c("Group1", "Group2", "Group1", "Group3")
annTrack <- AnnotationTrack(
start = st, end = ed, strand = str, chromosome = 7,
genome = "hg19", feature = "test", group = gr,
id = paste("annTrack item", 1:4),
name = "generic annotation", stacking = "squish"
)
# \dontshow{
## For some annoying reason the postscript device does not know about
## the sans font
if (!interactive()) {
font <- ps.options()$family
displayPars(annTrack) <- list(fontfamily = font, fontfamily.title = font)
}
# }
## Plotting
plotTracks(annTrack)
## Stacking
stacking(annTrack)
#> [1] "squish"
stacking(annTrack) <- "dense"
plotTracks(annTrack)