7

I'm learning the Gviz bioconductor package, I generate a plot as follows:

library(Gviz)
track <- AnnotationTrack(start=c(1,5,7), end=c(2,6,10), strand=c('*','*','*'), stacking="dense", showFeatureId=TRUE, id=c('red','blue', 'red'))
pdf(file=paste("test","pdf", sep="."))
plotTracks(track)
dev.off()

test.pdf looks like this: enter image description here

However, what I want is for the boxes to be coloured rather than labelled with the colour word, how to do this?

Note that my real example is much more complex than this.

terdon
  • 10,071
  • 5
  • 22
  • 48
Chris_Rands
  • 3,948
  • 12
  • 31

1 Answers1

8

Did you try the fill argument?

Something like this:

track <- AnnotationTrack(start=c(1,5,7), end=c(2,6,10), strand=c('*','*','*'), stacking="dense", showFeatureId=TRUE, id=c('red','blue', 'red'), fill=c('red','blue', 'red'))
benn
  • 3,571
  • 9
  • 28
  • 1
    Thanks, seems to work, can't believe I missed that! What colours are accepted as arguments for fill? – Chris_Rands Nov 15 '17 at 10:08
  • Probably all colors, here a list of color names. – benn Nov 15 '17 at 10:11
  • @Chris_Rands see ?plotTracks for the options accepted by plotTracks which will then refer you to ?settings for the various things you can tweak (long, long documentation). Finally, availableDisplayPars(track) will show you what you can set for track. – terdon Nov 15 '17 at 10:59