Gviz: How to color parts of transcript in BiomartGeneRegionTrack?
4
0
Entering edit mode
stianlagstad ▴ 90
@stianlagstad-9723
Last seen 4.1 years ago

I would like to color parts of a transcript. Using this code:

transcriptID <- "ENST00000421310"
breakpoint <- 132225374
start <- 132223104
end <- 132228670
chromosome <- "chr6"

mart <- biomaRt::useMart(
  biomart = "ENSEMBL_MART_ENSEMBL",
  dataset = "hsapiens_gene_ensembl",
  host = "dec2013.archive.ensembl.org")

# Create transcript track
biomartTrack <- Gviz::BiomartGeneRegionTrack(
  filters = list(
    ensembl_transcript_id = transcriptID),
  biomart = mart)

# Create axis track
axisTrack <- Gviz::GenomeAxisTrack()

# works as expected
Gviz::plotTracks(
  c(biomartTrack, axisTrack),
  chromosome = chromosome)

Gets me this plot:

I want control of the colors of each exon, so I try this:

interestcolor <- list("excluded"="red", "included"="green")
feature(biomartTrack) <- "excluded"
feature(biomartTrack)[start(biomartTrack) >= start &
                       end(biomartTrack) <= breakpoint] <- "included"
displayPars(biomartTrack) <- interestcolor

feature(biomartTrack)
# [1] "included" "included" "excluded"

# no change in color?
Gviz::plotTracks(
  c(biomartTrack, axisTrack),
  chromosome = chromosome)

But this gets me the same result. Am I doing something wrong?

This post is relevant: Change the features and colors in BiomartGeneRegionTrack

gviz • 3.0k views
ADD COMMENT
2
Entering edit mode
@florianhahnenovartiscom-3784
Last seen 5.6 years ago
Switzerland

BiomartTracks will extract all their relevant data directly from calls to Biomart, including the feature type. So assigning thinks via the feature() method does not really do much, since data will be refetched at the next draw. If you want to use this, you will have to coerce your BiomartGeneRegionTrack to a regular GeneRegionTrack first:

 biomartTrack <- as(biomartTrack, "GeneRegionTrack")

However please do note that you will loose the ability to extend the ranges of that track in order to load more annotation data from Biomart. 

ADD COMMENT
0
Entering edit mode

Thank you for the clarification.

ADD REPLY
0
Entering edit mode

Is it possible to keep the feature data and at the same time color certain exons in custom colors?

ADD REPLY
0
Entering edit mode

Not quite sure what you mean. Colors can be assigned to features. If your exon feature is not mapped to any particular color it will fall back to the default. If you are asking whether there is another way to control the color of individual exons independent of the feature value, then no. You can't do that.

ADD REPLY
0
Entering edit mode

Yes, what I want is the ability to draw certain exons in specific colors and at the same time draw UTRs with thinner boxes. The problem is that to draw the UTRs in thin boxes I need to keep the feature information. If I keep the feature information, then I cannot color exons as I like. Do you have any suggestions?

ADD REPLY
1
Entering edit mode
@florianhahnenovartiscom-3784
Last seen 5.6 years ago
Switzerland

From the GeneRegionTrack class documentation:

'GeneRegionTrack' objects also know about coding regions and

     non-coding regions (e.g., UTRs) in a transcript, and will indicate

     those by using different shapes (wide boxes for all coding

     regions, thinner boxes for non-coding regions). This is archived

     by setting the 'feature' values of the object for non-coding

     elements to one of the options that are provided in the

     'thinBoxFeature' display parameters. All other elements are

     considered to be coding elements.

And:

'thinBoxFeature=c("utr", "ncRNA", "utr3", "utr5", "miRNA", "lincRNA")':

          Character vector. A listing of feature types that should be

          drawn with thin boxes. Typically those are non-coding

          elements.

 

So you could set up an additional feature type like "utr3Red", and add that to the thinBoxFeature array. For that you can now also go ahead and provide another color mapping.

Florian

 

ADD COMMENT
0
Entering edit mode

Ah, that's a nice workaround I didn't think of. Thanks!

Can I suggest however the ability to set custom colors regardless of the features in a future version of Gviz? For my purposes I would like to color parts of a transcript in a darker colors, to signify which part of the transcript might be part of a fusion transcript. I can do that with the workaround you suggested, but it would be nice to be able to say something like

mcols(myTrack[specificRegion])$drawColor="#FF0000"
ADD REPLY
0
Entering edit mode
@florianhahnenovartiscom-3784
Last seen 5.6 years ago
Switzerland

You can overwrite the assignment for colors to features in the BiomartGeneRegionTrack objects. Those are regular DisplayParameters. They are all listed in the Display Parameters section of the class' help page.

 

ADD COMMENT
0
Entering edit mode

Hello, While trying to color exons differently using DisplayPars() function, I noticed that boxes that are UTRs and Protein coding are not colored differently but with the same color.

As you can see the thinbox feature makes the UTRs different but they are not different by color. Is there a way to change the color of UTRs even when attached to a protein_coding exon?

ADD REPLY
0
Entering edit mode
@florianhahnenovartiscom-3784
Last seen 5.6 years ago
Switzerland

Since UTRs are parts of exons this behaviour makes sense to me. There is currently no way to color them differently from the coding remainder of the exon, and I don't think there should be one. In many cases the UTR regions are even dynamically computed from the gene models. In the graphical representation within Gviz, composite coding/non-coding exons are plotted using polygons, so even technically different colors would not be possible.

 

ADD COMMENT

Login before adding your answer.

Traffic: 537 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