Question: Gviz: Setting Up Colour / Fill for AnnotationTrack (strand-dependent colour)
0
gravatar for JezDD
10 months ago by
JezDD0
JezDD0 wrote:

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!
:-)

 

 

ADD COMMENTlink modified 10 months ago by Robert Ivanek650 • written 10 months ago by JezDD0
Answer: Gviz: Setting Up Colour / Fill for AnnotationTrack (strand-dependent colour)
1
gravatar for Robert Ivanek
10 months ago by
Robert Ivanek650
Switzerland
Robert Ivanek650 wrote:

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

ADD COMMENTlink written 10 months ago by Robert Ivanek650

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

 

ADD REPLYlink written 10 months ago by JezDD0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 344 users visited in the last hour