This page describes how to construct a GeneTrack/FeatureTrack from TxDb or GRanges.
suppressPackageStartupMessages({ library(TnT) library(GenomicFeatures) library(TxDb.Hsapiens.UCSC.hg19.knownGene) library(EnsDb.Hsapiens.v75) })
A GeneTrack can be easily constructed from a TxDb.
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene gtrack <- TnT::GeneTrackFromTxDb(txdb) gtrack
To show the track, put the track into a TnTBoard
or TnTGenome
, optionally specifing the
view range with a GRanges object.
TnTGenome(gtrack, view.range = GRanges("chr13", IRanges(32889617, 32973809)) * 0.7)
FeatureTrack is an alias of GeneTrack, in the sense that this display method can be applied to general overlapping genomic features.
Function FeatureTrack
can construct a GeneTrack/FeatureTrack from a GRanges object, and
gives you more control of the display (i.e. color, feature labels, tooltip).
For example, we first extract the genes as a GRanges object from a EnsDb.
gene <- genes(EnsDb.Hsapiens.v75) head(gene)
Then we construct the GeneTrack using this GRanges object with FeatureTrack
, specifing
our custom feature labels, feature colors and tooltips. Finally show the track with TnTGenome
.
ensGeneTrack <- TnT::FeatureTrack(gene, tooltip = as.data.frame(gene), names = paste(gene$symbol, " (", gene$gene_biotype, ")", sep = ""), color = TnT::mapcol(gene$gene_biotype, palette.fun = grDevices::rainbow)) TnTGenome(ensGeneTrack, view.range = gene[gene$symbol == "BRCA2"][1] * .7)
TODO
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.