7
$\begingroup$

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.

$\endgroup$

1 Answer 1

8
$\begingroup$

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'))
$\endgroup$
3
  • 1
    $\begingroup$ Thanks, seems to work, can't believe I missed that! What colours are accepted as arguments for fill? $\endgroup$ Nov 15, 2017 at 10:08
  • $\begingroup$ Probably all colors, here a list of color names. $\endgroup$
    – benn
    Nov 15, 2017 at 10:11
  • $\begingroup$ @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. $\endgroup$
    – terdon
    Nov 15, 2017 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.