Entering edit mode
stianlagstad
▴
90
@stianlagstad-9723
Last seen 4.8 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
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.