geom_alignment {ggbio}R Documentation

Alignment geoms for GRanges object

Description

Show interval data as alignment.

Usage


## S4 method for signature 'GRanges'
geom_alignment(data, ..., xlab, ylab, main, facets = NULL, stat =
                 c("stepping", "identity"), range.geom = c("rect",
                 "arrowrect"), gap.geom = c("chevron", "arrow",
                 "segment"), rect.height = NULL, group.selfish = TRUE)

## S4 method for signature 'TranscriptDb'
geom_alignment(data, ..., which, xlim, truncate.gaps = FALSE,
                 truncate.fun = NULL, ratio = 0.0025, xlab, ylab, main,
                 facets = NULL, geom = "alignment",
                 stat = c("identity", "reduce"),
                 range.geom = "rect", gap.geom = "arrow",
                 utr.geom = "rect", names.expr = "tx_name(gene_id)")

Arguments

data

A GRanges or data.frame or TranscriptDb object.

...

Extra parameters such as aes() passed.

xlab

Label for x

ylab

Label for y

main

Title for plot.

facets

Faceting formula to use.

stat

For GRanges: Character vector specifying statistics to use. "stepping" with randomly assigned stepping levels as y varialbe. "identity" allow users to specify y value in aes.

For TranscriptDb: defualt "identity" give full gene model and "reduce" for reduced model.

gap.geom

Geom for 'gap' computed from the data you passed based on the group information.

rect.height

Half height of the arrow body.

group.selfish

Passed to addStepping, control whether to show each group as unique level or not. If set to FALSE, if two groups are not overlapped with each other, they will probably be layout in the same level to save space.

which

GRanges object to subset the TranscriptDb object.

xlim

Limits for x, to subset the TranscriptDb object.

truncate.gaps

logical value indicate to truncate gaps or not.

truncate.fun

shrinkage function. Please see shrinkagefun in package biovizBase.

ratio

used in maxGap.

geom

geometric object. only support "gene" now.

range.geom

geom for main intevals or exons.

utr.geom

geom for utr region.

names.expr

Expression for showing y label.

Value

A 'Layer'.

Author(s)

Tengfei Yin

Examples

set.seed(1)
N <- 100
require(GenomicRanges)
## ======================================================================
##  simmulated GRanges
## ======================================================================
gr <- GRanges(seqnames = 
              sample(c("chr1", "chr2", "chr3"),
                     size = N, replace = TRUE),
              IRanges(
                      start = sample(1:300, size = N, replace = TRUE),
                      width = sample(70:75, size = N,replace = TRUE)),
              strand = sample(c("+", "-", "*"), size = N, 
                replace = TRUE),
              value = rnorm(N, 10, 3), score = rnorm(N, 100, 30),
              sample = sample(c("Normal", "Tumor"), 
                size = N, replace = TRUE),
              pair = sample(letters, size = N, 
                replace = TRUE))
## ======================================================================
##  default
## ======================================================================
ggplot(gr) + geom_alignment()

plot of chunk unnamed-chunk-1

## or
ggplot() + geom_alignment(gr)

plot of chunk unnamed-chunk-1

## ======================================================================
##  facetting and aesthetics
## ======================================================================
ggplot(gr) + geom_alignment(facets = sample ~ seqnames, aes(color = strand, fill = strand))
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
## Scale for 'fill' is already present. Adding another scale for 'fill',
## which will replace the existing scale.

plot of chunk unnamed-chunk-1

## ======================================================================
##  stat:stepping
## ======================================================================
ggplot(gr) + geom_alignment(stat = "stepping", aes(group = pair))

plot of chunk unnamed-chunk-1

## ======================================================================
##  group.selfish controls when 
## ======================================================================
ggplot(gr) + geom_alignment(stat = "stepping", aes(group = pair), group.selfish = FALSE)

plot of chunk unnamed-chunk-1

## =======================================
##  main/gap geom
## =======================================
ggplot(gr) + geom_alignment(range.geom = "arrowrect", gap.geom = "chevron")

plot of chunk unnamed-chunk-1

## =======================================
##  For TranscriptDb
## =======================================
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
data(genesymbol, package = "biovizBase")
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
## made a track comparing full/reduce stat.
p1 <- ggplot(txdb) + geom_alignment(which = genesymbol["RBM17"])
## Aggregating TranscriptDb...
## Parsing exons...
## Parsing cds...
## Parsing transcripts...
## Aggregating...
## Done
## Constructing graphics...
p2 <- ggplot(txdb) + geom_alignment(which = genesymbol["RBM17"], stat = "reduce")
## Aggregating TranscriptDb...
## Parsing exons...
## Parsing cds...
## Parsing transcripts...
## Aggregating...
## Done
## Constructing graphics...
tracks(full = p1, reduce = p2, heights = c(3, 1))

plot of chunk unnamed-chunk-1

tracks(full = p1, reduce = p2, heights = c(3, 1)) + theme_tracks_sunset()

plot of chunk unnamed-chunk-1

tracks(full = p1, reduce = p2, heights = c(3, 1)) +
     theme_tracks_sunset(axis.line.color = NA)

plot of chunk unnamed-chunk-1

## change y labels
ggplot(txdb) + geom_alignment(which = genesymbol["RBM17"], names.expr = "tx_id:::gene_id")
## Aggregating TranscriptDb...
## Parsing exons...
## Parsing cds...
## Parsing transcripts...
## Aggregating...
## Done
## Constructing graphics...

plot of chunk unnamed-chunk-1


[Package ggbio version 1.5.20 ]