Question: Gviz: How to control `grid` parameter and how to add horizontal lines with different colors to DataTrack?
gravatar for Ezgi Karaesmen
3.1 years ago by
Ezgi Karaesmen30 wrote:


I'm using gviz to plot some GWAS data and my DataTrack is showing the association p-values of SNPs  for a certain genomic region, which is a pretty basic dot plot. I would like to show certain significance levels on my plot, and add several horizontal lines with different colors (or at least different colors than my dots...). I tried abline parameter in the DataTrack function but didn't really help. Is there another way to add horizontal lines?

Also I want to add some horizontal grid lines to my DataTrack which is relatively easy to do by setting grid=T, v=0, h=10 , where the integer controls the number of lines, but how can I control the coordinates of these lines?


gviz • 904 views
ADD COMMENTlink modified 3.1 years ago by li lilingdu450 • written 3.1 years ago by Ezgi Karaesmen30
Answer: Gviz: How to control `grid` parameter and how to add horizontal lines with diffe
gravatar for li lilingdu
3.1 years ago by
li lilingdu450
li lilingdu450 wrote:

Solution I considered is to add grid grills firstly and then modify their positions , following is the code, but another problem occur:


########using the example data contained in Gviz 
dTrack <- DataTrack(dat, name = "uniform")

###############make some modification of the horizon grid lines

However, the horizon lines (the 5 and -5 horizon line)was not correctly placed. Is this due to the viewport where the points and grill lines were really plotted was not pushed ? And how can I push the viewport correctly? It looks like I can't get this information from the grid grill grob (in fact segmentsGrob):

any advice? thanks!

ADD COMMENTlink written 3.1 years ago by li lilingdu450

Just for add of horizon lines:

ADD REPLYlink written 3.1 years ago by li lilingdu450

But it will be greater to list/get the viewports and even the correspondence of grobs and viewports in the plot, so more detailed and flexible control of the plot can be achieved. 

For task such as would be possible to do using grid low-level functions.

ADD REPLYlink written 3.1 years ago by li lilingdu450

Gviz does not expose that much of the grid underlining, and frankly I don't think that this would be particularly useful. There are several nested viewports that make up a typical Gviz plot, and just the thought of an API to expose that make me shiver...

You can get full control over the main graph viewport using a combination of OverlayTrack and CustomTrack objects:

st <- c(2000000, 2070000, 2100000, 2160000)

ed <- c(2050000, 2130000, 2150000, 2170000)

str <- c("-", "+", "-", "-")

gr <- c("Group1","Group2","Group1", "Group3")

annTrack <- AnnotationTrack(start=st, end=ed, strand=str, chromosome=7, genome="hg19", feature="test", group=gr, id=paste("annTrack item", 1:4), name="generic annotation", stacking="squish")


ct <- CustomTrack(plottingFunction=function(GdObject, prepare){ if(!prepare) panel.grid(); return(GdObject)})

plotTracks(OverlayTrack(trackList=list(annTrack, ct)))




ADD REPLYlink written 3.1 years ago by florian.hahne@novartis.com1.6k
Please log in to add an answer.


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