The support.bioconductor.org editor has been updated to markdown! Please see more info at: Tutorial: Updated Support Site Editor

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

Hi,

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?

Thanks!

gviz • 749 views
ADD COMMENTlink modified 2.4 years ago by li lilingdu450 • written 2.4 years ago by Ezgi Karaesmen30
Answer: Gviz: How to control `grid` parameter and how to add horizontal lines with diffe
2
gravatar for li lilingdu
2.4 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:

library(Gviz)

########using the example data contained in Gviz 
data(twoGroups)
dat<-resize(twoGroups,width=1)
dat<-dat[,'control']
dTrack <- DataTrack(dat, name = "uniform")
plotTracks(dTrack,grid=T,col.grid='gray',v=0,h=5)

###############make some modification of the horizon grid lines
grid.edit('.grid.h.panel..',y0=unit(c(-5,0,5),'native'),y1=unit(c(-5,0,5),'native'),gp=gpar(col=c('red','green','blue')))

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

grid.get('.grid.h.panel..')$vp
any advice? thanks!

ADD COMMENTlink written 2.4 years ago by li lilingdu450
1

Just for add of horizon lines:

plotTracks(dTrack,baseline=c(-5,0,5),col.baseline=c('red','green','blue'))
ADD REPLYlink written 2.4 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 http://stackoverflow.com/questions/25494125/plotting-arbitrary-lines-at-gviz-plottracks would be possible to do using grid low-level functions.

ADD REPLYlink written 2.4 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")

library(lattice)

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

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

 

 

 

ADD REPLYlink written 2.4 years ago by florian.hahne@novartis.com1.6k
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: 165 users visited in the last hour