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


Thank you for the clarification.
Is it possible to keep the feature data and at the same time color certain exons in custom colors?
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.
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?