Gviz: Is it possible to retrieve coordinates of a plotted HightlightTrack?
1
0
Entering edit mode
stianlagstad ▴ 90
@stianlagstad-9723
Last seen 4.1 years ago

Is it possible to retrieve the coordinates (in the plot) for a HighlightTrack object? Consider this code:

library(Gviz)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)

transcriptName <- "uc001aaa.3"

# Get exons in transcript:
gr <- GenomicFeatures::exons(
  TxDb.Hsapiens.UCSC.hg19.knownGene,
  vals = list(tx_name = transcriptName),
  columns = list("EXONNAME", "TXNAME", "GENEID"))
gr <- expand(gr)
# Remove extra transcripts I didn't want:
gr <- gr[mcols(gr)$TXNAME == transcriptName]
# Add $transcript mcols for grouping
mcols(gr)$transcript <- mcols(gr)$TXNAME
# Create tracks:
tr <- Gviz::GeneRegionTrack(gr)
htr <- Gviz::HighlightTrack(
  trackList = tr,
  start = 11874,
  end = 12721)
# Plot
res <- Gviz::plotTracks(htr)

# Now what's in res?
res
# $GeneRegionTrack
# GeneRegionTrack 'GeneRegionTrack'
# | genome: hg19
# | active chromosome: chr1
# | annotation features: 3
#
# $titles
# An object of class "ImageMap"
# Slot "coords":
#   x1 y1   x2  y2
# GeneRegionTrack  6  6 39.6 685
#
# Slot "tags":
#   $title
# GeneRegionTrack
# "GeneRegionTrack"

# I'm able to get the coordinates of the transcript:
trCoordinates <- Gviz::coords(res$GeneRegionTrack)
trCoordinates
#               x1     y1       x2      y2
# exon_1  52.26409 90.875 172.0768 600.125
# exon_2 303.09009 90.875 339.7467 600.125
# exon_3 509.45302 90.875 912.6753 600.125

# But I don't see any options for retrieving coordinates for the HighlightTrack
gviz • 1.1k views
ADD COMMENT
1
Entering edit mode
@florianhahnenovartiscom-3784
Last seen 5.6 years ago
Switzerland

Those are currently not being returned in the plotTracks results. Will have to take a look at this in order to include.

ADD COMMENT
0
Entering edit mode

Thank you! It would be helpful, because I'm using highlighttracks to highlight specific regions, and I draw links (bezier curves) between highlighted regions. Right now I have a lot of messy code figuring out where to draw from&to, because I'm working it out based on the GeneRegionTrack.

ADD REPLY

Login before adding your answer.

Traffic: 1118 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6