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!
Just for add of horizon lines:
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.
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)))