Composite track is a way to combine multiple types of features into one track.
A composite track can be constructed by combining a list of different tracks with function merge
.
Label, background and height of the composite track will be derived from the component tracks and
can be further accessed and modified with trackSpec
and trackSpec<-
.
suppressPackageStartupMessages({ library(TnT) library(GenomicFeatures) library(AnnotationHub) }) set.seed(42)
First to construct a block track and a pin track from data.
gr <- GRanges("chr1", IRanges(c(11000, 20000, 60000), width = 2000)) gpos <- GRanges("chr1", IRanges(c(12000, 21000, 61000), width = 1), value = c(1, 2, 3)) btrack <- TnT::BlockTrack(gr, label = "Block Track", tooltip = as.data.frame(gr), color = "lightblue4") ptrack <- TnT::PinTrack(gpos, label = "Pin Track", tooltip = as.data.frame(gpos), background = "beige")
Then use merge
to construct a composite track and showing it.
ctrack <- TnT::merge(btrack, ptrack) TnTBoard(ctrack)
Be aware that the components in a composite track are rendered according to the order
in merge
. For example, the block track will cover the pin track if we switch the order.
TnTBoard(merge(ptrack, btrack)) # the pin track has been covered
Show all three tracks and add axis indicator.
TnTGenome(list(ctrack, ptrack, btrack))
library(TxDb.Hsapiens.UCSC.hg19.knownGene) txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene gtrack <- TnT::GeneTrackFromTxDb(txdb, label = "Gene", color = "burlywood3") ah <- AnnotationHub() ah <- query(ah, "cpgisland") cpg <- ah[[names(ah[ah$genome == "hg19"])]] cpgtrack <- TnT::BlockTrack(cpg, label = "CpG Islands", tooltip = as.data.frame(cpg), color = "lightblue") TnTGenome(merge(cpgtrack, gtrack), view.range = GRanges("chr1", IRanges(84884317, 85205497)))
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.