Gviz single side margin for plotTracks
1
0
Entering edit mode
alex.gos90 ▴ 10
@alexgos90-13597
Last seen 4 months ago
Germany

Hi Gviz developers, 

 

I found the option to increase the margin around the plot area very helpful to include longer than usual titles, but when I tried in par(mar(c(bottom, left, top, right))-like manner to specify side specific margins it did not work as expected. 
Somehow the margin was defined by the maximum of the specified vector, so I am wondering wether this behaviour is intended or a bug.   

Anyways, thank you for providing the awesome Gviz package for plotting genomics data, it is really extensible and looks very nice with minimal tweaking. 

Edit: 
Small reproducible example:

## Create some tracks to plot
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="annotation track foo",
                            stacking="squish")

ax <- GenomeAxisTrack()

dt <- DataTrack(start=seq(min(st), max(ed), len=10), width=18000,
                data=matrix(runif(40), nrow=4), genome="hg19", chromosome=7,
                type="histogram", name="data track bar")


## Now plot the tracks
plotTracks(list(ax, annTrack, dt),frame=TRUE)

## Plot with higher margin (single value)
plotTracks(list(ax, annTrack, dt),margin = 50,frame=TRUE)

## Plot with higher margin (per site value) --> only first two are respected
plotTracks(list(ax, annTrack, dt),margin = c(50,100,200,400),frame=TRUE)

## Plot with higher margin (c(horizontal,vertical) value) --> same as before
plotTracks(list(ax, annTrack, dt),margin = c(50,100),frame=TRUE)

 

Best,

Alex

gviz grid layout • 1.9k views
ADD COMMENT
0
Entering edit mode

Dear Alex,

Can you provide a reproducible example? The Gviz is using grid graphics so par cannot work.

Best

Robert

ADD REPLY
0
Entering edit mode

Thanks Robert for pointing this out. 

Now I actually played around a bit more (before was taking too long) and figured out you can basically only extend margin in horizontal (equally left/right) and vertical (equally top/bottom) direction. 
This sounds definitely better than my first assumption with the max value bug, but was not really documented (at least I did not find any hints).   

And still it is different from the behaviour that I would usually expect form a margin parameter.

Best,
Alex

ADD REPLY
0
Entering edit mode

Hi Alex,

I can update the code to take all four values c(bottom, left, top, right) into account but it will not be compatible with current specification of the margin c(width, height). Therefore I can only push this change into devel version of Gviz (Bioc 3.9).

Best Robert

ADD REPLY
0
Entering edit mode

Hi Robert,

this would be really nice! I do not know how much sense it makes, but maybe you could allow both versions to be used. So providing either two or four values, these could be interpreted differentially. 

 

Best Alex 

ADD REPLY
2
Entering edit mode
Robert Ivanek ▴ 750
@robert-ivanek-5892
Last seen 13 months ago
Switzerland

I updated the code in both versions (release, devel) that it can take four different values for margin definition (similar to par). If you provide only two, it will use them as before. It will be available in next versions.

ADD COMMENT

Login before adding your answer.

Traffic: 452 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6