flowViz Plots Gate Outline and grid.newpage()/viewport Issue
1
0
Entering edit mode
Aric Gregson ▴ 30
@aric-gregson-3055
Last seen 10.2 years ago
Hello, I realize that with the version of flowViz I am running (1.7.10) that if I draw a scatterplot with smooth=F and attempt to draw the gate outline the first drawing of the plot will not show the outline, but subsequent attempts will. To generate pdf figures that show the gate outline, I just draw the plot twice prior to submitting it to the pdf device and the gate outline is there in the pdf file. However, I now am placing multiple figures in the same pdf page as below and wonder if there is another method to do this. Example plot: plot344lymph<-xyplot(`FSC.A` ~ `SSC.A`, Data(wf[["CD3+"]])[[6]], xlim=c(0, 8), ylim=c(0, 120000), filter=lymphscatfilter, smooth=F, alpha=0.6, pch=21, cex=0.1, outline=TRUE, names=TRUE, #scales=list(tick.number= 10), main="Lymphocyte Gate\nSinglet Live CD3/CD4+", xlab="Side Scatter Area", ylab="Forward Scatter Area", par.settings=list(gate=list(col="purple", alpha=.4), gate.text=list(col="black", alpha=0.7, cex=0.6))) Code to generate multiple plots on one pdf page: pdf(file="grid344.pdf", width=11, height=8.5) grid.newpage() pushViewport(viewport(layout = grid.layout(2, 3))) pushViewport(viewport(layout.pos.col=1, layout.pos.row=1)) print(plot344singlet, newpage = FALSE) popViewport(1) # pushViewport(viewport(layout.pos.col=1, layout.pos.row=1)) print(plot344singlet, newpage = FALSE) popViewport(1) pushViewport(viewport(layout.pos.col=2, layout.pos.row=1)) print(plot344live, newpage = FALSE) popViewport() # pushViewport(viewport(layout.pos.col=2, layout.pos.row=1)) print(plot344live, newpage = FALSE) popViewport() ...etc. for each plot. Is there a more elegant and less compute intensive way to do this? Thanks in advance. -- Aric Gregson
flowViz flowViz • 1.6k views
ADD COMMENT
0
Entering edit mode
Florian Hahne ▴ 540
@florian-hahne-2471
Last seen 10.2 years ago
Hi Aric, I don't quite follow why you have to draw the plot twice to get the gate outline. This works on my installation: library(flowViz) data(GvHD) tmp <- GvHD[[1]] rg <- rectangleGate("FSC-H"=c(100, 200), "SSC-H"=c(400, 800)) xyplot(`SSC-H`~`FSC-H`, tmp, smooth=FALSE, filter=rg, outline=T) I am also not sure why you want to place individual plots manually. xyplot knows how to deal with flowSets, so the following works fine: xyplot(`SSC-H`~`FSC-H`, GvHD[1:3], smooth=FALSE, filter=rg, outline=T) and if you want to pass in separate filter objects for each frame you can do so by means of a list. Lattice graphics gives pretty much all the freedom to control the placing of the individual frames, and you might consider Deepayan Sarkar's Lattice book as a reference. If you really want to produce lattice objects and manually place them on a graphics device, the split option of the lattice plot method could be helpful. Florian Aric Gregson wrote: > Hello, > > I realize that with the version of flowViz I am running (1.7.10) that > if I draw a scatterplot with smooth=F and attempt to draw the gate > outline the first drawing of the plot will not show the outline, but > subsequent attempts will. To generate pdf figures that show the gate > outline, I just draw the plot twice prior to submitting it to the pdf > device and the gate outline is there in the pdf file. > > However, I now am placing multiple figures in the same pdf page as > below and wonder if there is another method to do this. > > Example plot: > > plot344lymph<-xyplot(`FSC.A` ~ `SSC.A`, Data(wf[["CD3+"]])[[6]], > xlim=c(0, 8), > ylim=c(0, 120000), > filter=lymphscatfilter, > smooth=F, > alpha=0.6, > pch=21, > cex=0.1, > outline=TRUE, > names=TRUE, > #scales=list(tick.number= 10), > main="Lymphocyte Gate\nSinglet Live CD3/CD4+", > xlab="Side Scatter Area", > ylab="Forward Scatter Area", > par.settings=list(gate=list(col="purple", alpha=.4), > gate.text=list(col="black", alpha=0.7, cex=0.6))) > > Code to generate multiple plots on one pdf page: > > pdf(file="grid344.pdf", width=11, height=8.5) > grid.newpage() > pushViewport(viewport(layout = grid.layout(2, 3))) > pushViewport(viewport(layout.pos.col=1, layout.pos.row=1)) > print(plot344singlet, newpage = FALSE) > popViewport(1) > # > pushViewport(viewport(layout.pos.col=1, layout.pos.row=1)) > print(plot344singlet, newpage = FALSE) > popViewport(1) > > pushViewport(viewport(layout.pos.col=2, layout.pos.row=1)) > print(plot344live, newpage = FALSE) > popViewport() > # > pushViewport(viewport(layout.pos.col=2, layout.pos.row=1)) > print(plot344live, newpage = FALSE) > popViewport() > > ...etc. for each plot. > > Is there a more elegant and less compute intensive way to do this? > > Thanks in advance. > > -- Florian Hahne, PhD Computational Biology Program Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M1-B514 PO Box 19024 Seattle, Washington 98109-1024 206-667-3148 fhahne at fhcrc.org
ADD COMMENT
0
Entering edit mode
On Mon, 13 Apr 2009 17:09:55 -0700 Florian Hahne <fhahne at="" fhcrc.org=""> wrote: > I don't quite follow why you have to draw the plot twice to get the > gate outline. This works on my installation: > library(flowViz) > data(GvHD) > tmp <- GvHD[[1]] > rg <- rectangleGate("FSC-H"=c(100, 200), "SSC-H"=c(400, 800)) > xyplot(`SSC-H`~`FSC-H`, tmp, smooth=FALSE, filter=rg, outline=T) Perhaps this has been fixed in 1.7.11? Maybe something else is not working properly on my installation (quite possible). In previous discussions you had mentioned there were some bugs in the drawing of xyplot, so I did not mention this and assumed it was one that you were aware of. It has been extremely reproducible on my machine for many months. > I am also not sure why you want to place individual plots manually. > xyplot knows how to deal with flowSets, so the following works fine: > xyplot(`SSC-H`~`FSC-H`, GvHD[1:3], smooth=FALSE, filter=rg, outline=T) > and if you want to pass in separate filter objects for each frame you > can do so by means of a list. I'm certain there is a better way, but the above is not what I am intending to accomplish. I'd like to plot the same flowFrame from a flowSet, but with different plots. That is, I'd like to show the gating strategy of the flowSet using one flowFrame as an example. I have not figured out how lattice can do that without making individual plots and then laying them all on a page. For example, I have the following plots for flowSet[[6]]: 1. FSC.A vs. FSC.H (filterobject1) 2. APC.H7 vs. Violet UV (filterobject2) 3. APC.H7 vs. AmCyan (filterobject3) 4. SSC.A vs. FSC.A (filterobject4) 5. PacBlue vs. Alexa467 (filterobject5) 6. densityplot of entire flowSet (filterobject6) Deepayan Sarkar's book is truly invaluable, but I find it abstract on some points. This is purely my fault as I am not intimately familiar with lattice, yet. The grid method I used was easiest for me to implement and familiar from the ggplot2 methods. I will have another look at the split method. Thanks for any further suggestions. Aric > sessionInfo() R version 2.8.0 (2008-10-20) i386-pc-solaris2.11 locale: C attached base packages: [1] splines grid tools stats graphics grDevices utils [8] datasets methods base other attached packages: [1] MASS_7.2-44 RColorBrewer_1.0-2 proto_0.3-8 [5] reshape_0.8.2 plyr_0.1.1 xtable_1.5-4 flowViz_1.7.10 [9] lattice_0.17-20 flowCore_1.9.18 rrcov_0.4-07 robustbase_0.4-3 [13] Biobase_2.2.1 loaded via a namespace (and not attached): [1] AnnotationDbi_1.4.1 DBI_0.2-4 KernSmooth_2.22-22 [4] RSQLite_0.7-1 cluster_1.11.11 feature_1.1-14 [7] geneplotter_1.20.0 graph_1.20.0 latticeExtra_0.5-4 [10] stats4_2.8.0
ADD REPLY
0
Entering edit mode
Aric Gregson wrote: > On Mon, 13 Apr 2009 17:09:55 -0700 > Florian Hahne <fhahne at="" fhcrc.org=""> wrote: > > >> I don't quite follow why you have to draw the plot twice to get the >> gate outline. This works on my installation: >> library(flowViz) >> data(GvHD) >> tmp <- GvHD[[1]] >> rg <- rectangleGate("FSC-H"=c(100, 200), "SSC-H"=c(400, 800)) >> xyplot(`SSC-H`~`FSC-H`, tmp, smooth=FALSE, filter=rg, outline=T) >> > > Perhaps this has been fixed in 1.7.11? Maybe something else is not > working properly on my installation (quite possible). In previous > discussions you had mentioned there were some bugs in the drawing of > xyplot, so I did not mention this and assumed it was one that you were > aware of. It has been extremely reproducible on my machine for many > months. > Hopefully! But if you could provide me with a reproducible example using the GvHD data I could make sure. Would be good to fix this before the release if it really is a bug. > >> I am also not sure why you want to place individual plots manually. >> xyplot knows how to deal with flowSets, so the following works fine: >> xyplot(`SSC-H`~`FSC-H`, GvHD[1:3], smooth=FALSE, filter=rg, outline=T) >> and if you want to pass in separate filter objects for each frame you >> can do so by means of a list. >> > > I'm certain there is a better way, but the above is not what I am > intending to accomplish. I'd like to plot the same flowFrame from a > flowSet, but with different plots. That is, I'd like to show the gating > strategy of the flowSet using one flowFrame as an example. I have not > figured out how lattice can do that without making individual plots and > then laying them all on a page. > I see. That is indeed not directly possible with flowViz or lattice unless you produce separate lattice objects for each plot and arrange them with split, or your self-defined viewports, which boils down to pretty much the same thing. I don't see a simple solution to build that into flowViz since we are very flowSet centric. > For example, I have the following plots for flowSet[[6]]: > 1. FSC.A vs. FSC.H (filterobject1) > 2. APC.H7 vs. Violet UV (filterobject2) > 3. APC.H7 vs. AmCyan (filterobject3) > 4. SSC.A vs. FSC.A (filterobject4) > 5. PacBlue vs. Alexa467 (filterobject5) > 6. densityplot of entire flowSet (filterobject6) > > Deepayan Sarkar's book is truly invaluable, but I find it abstract on > some points. This is purely my fault as I am not intimately familiar > with lattice, yet. The grid method I used was easiest for me to > implement and familiar from the ggplot2 methods. I will have another > look at the split method. > > Thanks for any further suggestions. > > Aric > > >> sessionInfo() >> > R version 2.8.0 (2008-10-20) > i386-pc-solaris2.11 > > locale: > C > > attached base packages: > [1] splines grid tools stats graphics grDevices > utils [8] datasets methods base > > other attached packages: > [1] MASS_7.2-44 RColorBrewer_1.0-2 proto_0.3-8 [5] > reshape_0.8.2 plyr_0.1.1 xtable_1.5-4 flowViz_1.7.10 [9] > lattice_0.17-20 flowCore_1.9.18 rrcov_0.4-07 robustbase_0.4-3 > [13] Biobase_2.2.1 > > loaded via a namespace (and not attached): > [1] AnnotationDbi_1.4.1 DBI_0.2-4 KernSmooth_2.22-22 > [4] RSQLite_0.7-1 cluster_1.11.11 feature_1.1-14 > [7] geneplotter_1.20.0 graph_1.20.0 latticeExtra_0.5-4 > [10] stats4_2.8.0 > -- Florian Hahne, PhD Computational Biology Program Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M1-B514 PO Box 19024 Seattle, Washington 98109-1024 206-667-3148 fhahne at fhcrc.org
ADD REPLY

Login before adding your answer.

Traffic: 925 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