Gviz: Setting Up Colour / Fill for AnnotationTrack (strand-dependent colour)
1
0
Entering edit mode
JezDD • 0
@jezdd-19085
Last seen 3.9 years ago

Hi,
'm new to bioinformatics, so please excuse if this is a silly question.
I need help to generate some plots using Gviz for some genome sequencing data from a parasite.

I have managed to generate the plots, but I'm struggling to set up the annotation track to show different colours for CDSs depending on the "+" or "-" strand orientation.

For this, I have tried the following:

#Set fill as a function of CDS orientation
cor <- strand(aTrack)
cor[cor=="+"]<-"blue"
cor[cor=="-"]<-"red"
#Plot
plotTracks(list(gTrack,dTrack,aTrack), from=1, to=853233, fill.histogram="red", fill=cor, shape="arrow", type="hist")

And this is what I get:

I'm importing a GFF file containing only the CDSs from a original GFF file. I have also tried with the original file and the results are similar.
Please, also note that, in the AnnotationTrack, not all CDSs are represented as arrows, even though I am setting the shape as arrow.
Worst, I get mixed colouring, with no colouring of "+" and "-" strands with blue and red, respectively.
I have no idea how I can fix this!!

Thanks in advance for any help!
:-)

1
Entering edit mode
Robert Ivanek ▴ 730
@robert-ivanek-5892
Last seen 7 months ago
Switzerland

Hi,

You can colour the individual items in the AnnotationTrack by setting the feature to "plus" and "minus" strand. Then in plotTracks function provide two additional arguments which set colours to "plus" and "minus" features:

library(Gviz)

data(collapseTrack)
strand(ctrack) <- rep(c("+","-","+","-"), c(7,2,1,2))
feature(ctrack) <- ifelse(strand(ctrack)=="+", "plus", "minus")

plotTracks(ctrack, plus="darkred", minus="darkgreen")

Hope that helps.

Robert

0
Entering edit mode

It worked perfectly!
Thank you so much, Robert!
Cheers