Question: gviz: stacking option for plotTracks function
0
gravatar for shuoguo
2.6 years ago by
shuoguo10
shuoguo10 wrote:

Hi,

I am using gviz to plot bed format file.

I have a pair of bed files, with equal lines in them and each line is the same name. e.g.

file1.bed

chr4    190954356       190968056       group-1      0       + ... (the rest of the fields omitted here)

chr4    190962609       191009216       group-2      0       + ...

file2.bed

chr14   106359834       106376979       group-1      0       + ...

chr14   106360687       106378941       group-2      0       +...

For each line, I am converting to AnnotationTrack, and use the pushViewport library to put two plots side by side (one for chr4, one for chr14 in this case).

grid.newpage()
pushViewport(viewport(layout = grid.layout(1,2)))

pushViewport(viewport(layout.pos.col = 1, layout.pos.row = 1))
plotTracks(tracksA, chromosome=chromA, add=TRUE, stacking="full", groupAnnotation = "group")
popViewport(1)

pushViewport(viewport(layout.pos.col = 2, layout.pos.row = 1))
plotTracks(tracksB, chromosome=chromB, add=TRUE, stacking="full", groupAnnotation = "group")
popViewport(1)

However, the order of the groups (group-1, group-2, etc) were random based on the space availability (default is to "squish").

If I would like is to keep the order of the groups "as-is" (as they appear in the bed file), is there any way that I can tweak the plot?

Sorry I am new to R and Gviz library, and my questions might have been addressed somewhere else.

Thanks,

Shuoguo

 

gviz plottracks stacking • 491 views
ADD COMMENTlink modified 2.6 years ago by florian.hahne@novartis.com1.6k • written 2.6 years ago by shuoguo10
Answer: gviz: stacking option for plotTracks function
0
gravatar for florian.hahne@novartis.com
2.6 years ago by
Switzerland

Hi Shuoguo,

I am afraid I can't quite follow what you are trying to do. It sounds like your problem has nothing to do with the plotting in viewports, though. Could you please post a reproducible example that shows what you are trying to archive, and what is not working as expected? 

With regards to the ordering of the groups: this should follow the usual R convention of characters vs ordered factors. if your group vectors are indeed ordered factors they should be plotted in the same order for all plots.

Florian

ADD COMMENTlink written 2.6 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: 171 users visited in the last hour