Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
197 lines (162 sloc) 5.62 KB
---
title: "TnT Examples"
---
<div class="row">
<div class="col-md-5">
```{r, echo=FALSE}
knitr::kable(data.frame(check.names = FALSE,
"~" = c("R", "Bioc", "TnT"),
"Version" = c(
sub(x = sub(x = R.Version()$version.string, "R version ", ""), " ",
paste0(" ", R.Version()$nickname, " ")),
paste(as.character(BiocInstaller::biocVersion()),
sprintf("(bioc-%s)", if (BiocInstaller::isDevel()) "devel" else "release")),
Biobase::package.version("TnT")
)
))
```
</div>
<div class="col-md-7">
</div>
</div>
```{r, include=FALSE}
suppressPackageStartupMessages({
library(TnT)
library(GenomicFeatures)
library(EnsDb.Hsapiens.v75)
})
```
------
## Different Track Types and Their Constructors
There are different track types and constructors in TnT.
The constructors are provided to construct a track from distinct sources which are
generally standard format used in many bioconductor packages (e.g. GRanges that represents
genomic positions and possible annotations; TxDb that represents gene and transcript information).
Track constructors are provided in TnT to construct tracks with different types and from
different sources. The following table shows available track types and their instances.
Links in the table have further description and examples for the track types and constructors.
<table class="table table-bordered">
<thead>
<tr>
<th>Link</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td class="col-md-2">
<strong> [Block Track](tracktype-BlockTrack.html) </strong>
</td>
<td class="col-md-9">
```{r, echo=FALSE}
ir <- IRanges(c(100, 400, 800), width = c(100, 150, 250))
gr <- GRanges("na", ir)
bt <- BlockTrack(gr, color = "salmon2", label = NULL)
TnTBoard(bt, view.range = range(gr) * .7, coord.range = ranges(range(gr)) * .5)
```
</td>
</tr>
<tr>
<td class="col-md-2">
<strong> [Pin Track](tracktype-PinTrack.html) </strong>
</td>
<td class="col-md-9">
```{r, echo=FALSE}
ir <- IRanges(start = c(100, 200, 300, 400), width = 1)
gpos <- GRanges("na", ir)
gpos$value <- 1:4
ptrack <- PinTrack(gpos, color = c("green", "blue", "yellow", "red"), label = NULL)
TnTBoard(ptrack, view.range = GRanges("na", IRanges(0, 500)), coord.range = IRanges(0, 500))
```
</td>
</tr>
<tr>
<td class="col-md-2">
<strong> [Line Track and Area Track](tracktype-LineTrack-AreaTrack.html) </strong>
</td>
<td class="col-md-9">
```{r, echo=FALSE}
pos <- IRanges(seq(0, 500, by = 10), width = 1)
pos <- GRanges("na", pos)
pos$value <- c(1, 0.6, 0.1, 0.7, 0.1, 0, 0.9, 0.4, 0.6, 0.1, 0, 0.8, 0.4, 0.5, 0.3, 0.2, 0.3, 0.8, 0.1, 0.8, 0.1, 0, 1, 0.3, 0, 0.9, 1, 0.6, 0.6, 0.1, 0.9, 0.3, 0.7, 0.2, 0.2, 0.6, 0.1, 0, 1, 0.6, 0.1, 0.5, 0.2, 0.4, 0, 1, 0, 0.4, 0.6, 0.5, 0)
lt <- LineTrack(pos, domain = c(0, 1), label = NULL, color = "steelblue", height = 40)
at <- AreaTrack(pos, domain = c(0, 1), label = NULL, color = "orange", height = 40)
TnTBoard(c(lt, at), view.range = GRanges("na", IRanges(0, 500)), coord.range = IRanges(0, 500),
zoom.allow = IRanges(70, 500))
```
</td>
</tr>
<tr>
<td class="col-md-2">
<strong> [Vline Track](tracktype-VlineTrack.html) </strong>
</td>
<td class="col-md-9">
```{r, echo=FALSE}
set.seed(42)
pos <- IRanges(start = sample(1:1000, 6), width = 1)
colors <- c("red", "yellow", "green", "cyan", "blue", "magenta")
vltrack <- VlineTrack(pos,tooltip = data.frame(Position = start(pos), Color = colors),
color = colors, label = NULL)
TnTBoard(vltrack, view.range = GRanges("UnKnown", IRanges(1, 1000)) , coord.range = c(1, 1000))
```
</td>
</tr>
<tr>
<td class="col-md-2">
<strong> [Gene Track and Feature Track](tracktype-GeneTrack.html) </strong>
</td>
<td class="col-md-9">
```{r, echo=FALSE}
gene <- genes(EnsDb.Hsapiens.v75)
genetrack <- FeatureTrack(gene, tooltip = as.data.frame(gene),
names = paste(gene$symbol, " (", gene$gene_biotype, ")", sep = ""),
height = 100,
color = mapcol(gene$gene_biotype, palette.fun = grDevices::rainbow))
TnTGenome(genetrack, view.range = gene[gene$symbol == "BRCA2"][1] * .8)
```
</td>
</tr>
<tr>
<td class="col-md-2">
<strong> [Tx Track and GroupFeature Track](tracktype-TxTrack.html) </strong>
</td>
<td class="col-md-9">
```{r, echo=FALSE}
suppressMessages({
gr <- biovizBase::crunch(EnsDb.Hsapiens.v75, ~ symbol == "BRCA2")
})
brca2tx <- TxTrackFromGRanges(gr, label = "BRCA2, transcripts", color = "grey2", height = 300)
brca2tx$tooltip <- select(EnsDb.Hsapiens.v75,
keys = brca2tx$tooltip$tx_id, keytype = "TXID", columns = c("GENEID", "SYMBOL", "TXBIOTYPE")
)
brca2tx$color <- mapcol(brca2tx$tooltip$TXBIOTYPE)
brca2tx$display_label <- strandlabel(
paste(brca2tx$tooltip$SYMBOL, brca2tx$tooltip$TXBIOTYPE), strand(trackData(brca2tx))
)
trackSpec(brca2tx, "height") <- 150
TnTGenome(brca2tx, view.range = GRanges("13",IRanges(32879087, 32984329)))
```
</td>
</tr>
<tr>
<td class="col-md-2">
<strong> [Composite Track](track-CompositeTrack.html) </strong>
</td>
<td class="col-md-9">
```{r, echo=FALSE}
gr <- GRanges("chr1", IRanges(c(11000, 20000, 60000), width = 2000))
gpos <- GRanges("chr1", IRanges(c(14000, 23000, 63000), width = 1), value = c(1, 2, 3))
btrack <- BlockTrack(gr, label = "Block Track", tooltip = as.data.frame(gr), color = "lightblue4")
ptrack <- PinTrack(gpos, label = "Pin Track", tooltip = as.data.frame(gpos), background = "beige")
ctrack <- merge(btrack, ptrack)
TnTBoard(ctrack, view.range = GRanges("chr1", IRanges(4500, 69500)), coord.range = c(0, 75000))
```
</td>
</tr>
</tbody>
</table>
<br> </br>
------
## Misc
#### [Feature colors](track-colors.html)
#### [Tooltip display for tracks](track-tooltip-display.html)