gviz: stacking option for plotTracks function
1
0
Entering edit mode
shuoguo ▴ 10
@shuoguo-10625
Last seen 5.3 years ago

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 • 726 views
0
Entering edit mode
@florianhahnenovartiscom-3784
Last seen 3.2 years ago
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