Overlay Density Plot for FlowSet
1
0
Entering edit mode
Aric Gregson ▴ 30
@aric-gregson-3055
Last seen 10.2 years ago
Apologies if this is obvious or has already been discussed, but I am struggling with how to do this from within flowCore/Viz using R 2.7.0. I have filtered and subseted the data now that I would like to plot an overlay density plot of a full fluorescence tube over a FMO tube and demonstrate the positive gate. I have been able to construct a not so interesting histogram plot as below: plot(CD3.4.fp3Live.subset[[1]], "FL2.W", breaks=256, col=c("black"), main="Overlay Plot FMO for CCR7\nFMO (CCR7-) Blue\nFull Fluorescent Tube (CCR7+) Black") plot(CD3.4.fp3Live.subset[[5]], "FL2.W", breaks=256, col=c ("dodgerblue"), add=T) But there is no indication of the gate and the histograms are difficult to read in this manner. Another option that may work to visualize this, would be to overlay dot plot with xyplot and show the gate somehow. But this is beyond me currently. Thanks for any suggestions, aric
• 2.0k views
ADD COMMENT
0
Entering edit mode
Florian Hahne ▴ 540
@florian-hahne-2471
Last seen 10.2 years ago
Hi Aric, I don't fully understand what you are trying to plot. Is your data one-dimensional, i.e., do you want to compare the densities (or histograms) of a single fluorescence parameter for several tubes? Then the densityplot function should be able to do that: densityplot(name ~ `FL2.W`, CD3.4.fp3Live.subset[c(1,5)]) You say that CD3.4.fp3Live.subset is already a subset of the original data and I am not sure which gate you want to add to this plot. Also you don't say what type of gate you applied. Assuming that g is the gate you used to filter and subset CD3.4.fp3Live, resulting in CD3.4.fp3Live.subset, and that you filtered on the FL2.W parameter, you could add the gate to your plot like this: densityplot(name ~ `FL2.W`, CD3.4.fp3Live[c(1,5)], filter=g) If the gate is not on FL2.W there isn't a reasonable way to add the gate to the one-dimensional density plot. And if CD3.4.fp3Live.subset is the result of your gating it doesn't make much sense, either. It would be in the empty region of the plot. In the 2D situation you can't easily overlay xyplots, but you can plot them in a trellis layout adding the gate as argument "filter" similar to the previous densityplot example. However, you can overlay contour plots: cols <- rainbow(3, alpha=0.1) contour(CD3.4.fp3Live[c(1,5)], col=cols, fill=cols) Let me know if that doesn't address your problem. Also please provide the output of sessionInfo() in future posts, it's much easier to answer questions if we know the R and package versions you are working on. Florian Aric Gregson wrote: > Apologies if this is obvious or has already been discussed, but I am > struggling with how to do this from within flowCore/Viz using R 2.7.0. > > I have filtered and subseted the data now that I would like to plot an > overlay density plot of a full fluorescence tube over a FMO tube and > demonstrate the positive gate. I have been able to construct a not so > interesting histogram plot as below: > > plot(CD3.4.fp3Live.subset[[1]], "FL2.W", breaks=256, col=c("black"), > main="Overlay Plot FMO for CCR7\nFMO (CCR7-) Blue\nFull Fluorescent > Tube (CCR7+) Black") > plot(CD3.4.fp3Live.subset[[5]], "FL2.W", breaks=256, col=c > ("dodgerblue"), add=T) > > But there is no indication of the gate and the histograms are difficult > to read in this manner. > > Another option that may work to visualize this, would be to overlay dot > plot with xyplot and show the gate somehow. But this is beyond me > currently. > > Thanks for any suggestions, > > aric > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > -- Florian Hahne, PhD Computational Biology Program Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M2-B876 PO Box 19024 Seattle, Washington 98109-1024 206-667-3148 fhahne at fhcrc.org
ADD COMMENT
0
Entering edit mode
Florian, Sorry about the poor explanation and thanks very much for your help. I keep rereading everything I can find on flowCore/Viz and continue to figure out more details as I go. On Fri, 03 Oct 2008 13:31:57 -0700 Florian Hahne <fhahne at="" fhcrc.org=""> wrote: > Is your data one-dimensional, i.e., do you want to compare the > densities (or histograms) of a single fluorescence parameter for > several tubes? That is exactly what I want to do. Your densityplot example works just fine, I am not sure why I didn't try that combination before (never tried the 'name' part). I just have to figure out how to annotate it and get the y-axis to have labels. densityplot(name[order(c(5,4))] ~ `FL2.W`, CD3.4.fp3Live.subset[c (5,4)], overlap=10, alpha=0.7, filter= rectCCR7.filter) However, I cannot seem to get the gate to display on this plot. I have tried adding filterResult with no effect. The gate is defined as: = rectCCR7.filter Rectangular gate with dimensions: FL2.W: (480,600) which should give me a one-dimensional gate on FL2.W only. I have made results and subsets of this gate from the CD3.4.fp3Live.subset above, in case they have to be made prior to the gate being plotted. The starting subsets, both before and after the single fluorescence parameter gate is applied, have cells within the FL2.W channel: = CD3.4.fp3Live.subset[[7]]$`FL2.W` flowFrame object '334-p1.000' with 1529 cells and 1 observables: name desc range minRange maxRange $P7 FL2.W FL4-CCR7 1024 0 1023 = CD3.4.fp3Live.subset[[8]]$`FL2.W` flowFrame object '334-p2.000' with 1706 cells and 1 observables: name desc range minRange maxRange $P7 FL2.W FL4-Open 1024 0 1023 = CD3.4.fp3.ccr7.subset[[4]]$`FL2.W` flowFrame object '334-p1.000' with 21 cells and 1 observables: name desc range minRange maxRange $P7 FL2.W FL4-CCR7 1024 0 1023 = CD3.4.fp3.ccr7.subset[[5]]$`FL2.W` flowFrame object '334-p2.000' with 4 cells and 1 observables: name desc range minRange maxRange $P7 FL2.W FL4-Open 1024 0 1023 The flowFrames have different numbers because not all could be filtered through the CCR7 gate (lacked cells). > In the 2D situation you can't easily overlay xyplots, but you can > plot them in a trellis layout adding the gate as argument "filter" > similar to the previous densityplot example. This I was able to do. I like this look, but others do not. Hence, my histogram question. > However, you can overlay contour plots: > > cols <- rainbow(3, alpha=0.1) > contour(CD3.4.fp3Live[c(1,5)], col=cols, fill=cols) I cannot get the contour plots to work for me at all, I have been trying for a while. I am clearly missing something. contour(fset1[c(7,8)], c("FL2.W", "FL1.H"), col=cols, fill=cols) Error in r[i1] - r[-length(r):-(length(r) - lag + 1)] : non-numeric argument to binary operator contour(CD3.4.fp3Live.subset[c(7,8)], "FL2.W", col=cols, fill=cols) Error in contour.default(CD3.4.fp3Live.subset[c(7, 8)], "FL2.W", col = cols, : no proper 'z' matrix specified contour(CD3.4.fp3Live.subset[c(7,8)], col=cols, fill=cols) Error in ceiling(length.out) : Non-numeric argument to mathematical function > Also please provide the output of sessionInfo() in future posts Sorry about that, here it is: = sessionInfo() R version 2.7.0 (2008-04-22) i386-pc-solaris2.11 locale: C attached base packages: [1] tools stats graphics grDevices utils datasets methods [8] base other attached packages: [1] flowViz_1.3.8 latticeExtra_0.3-1 lattice_0.17-6 RColorBrewer_1.0-2 [5] flowCore_1.5.21 Biobase_1.99.10 feature_1.1-13 KernSmooth_2.22-22 [9] rrcov_0.4-05 robustbase_0.2-8 loaded via a namespace (and not attached): [1] AnnotationDbi_1.1.35 DBI_0.2-4 MASS_7.2-41 [4] RSQLite_0.6-8 geneplotter_1.17.8 grid_2.7.0 [7] stats4_2.7.0 tcltk_2.7.0 -- Aric Gregson <a.gregson at="" ucla.edu="">
ADD REPLY
0
Entering edit mode
Florian, On Fri, 03 Oct 2008 13:31:57 -0700 Florian Hahne <fhahne at="" fhcrc.org=""> wrote: > Let me know if that doesn't address your problem. Also please provide > the output of sessionInfo() in future posts, I thought that perhaps the drawing of gates on the densityplot, the lack of contour() working and the fact that none of the gate outlines are ever drawn in xyplot(smooth=F) was due to my environment, so I upgraded. My machine environment is listed below. There was no change in plot results. I then tried on a clean install of R 2.7.2 and the most recent bioconductor packages (as of yesterday) for this version of R on a Mac (sessionInfo not listed) and there was no change in plot behavior. I used the same .RData and .Rhistory files on both machines, before and after the upgrades, if that makes a difference. I must be setting up and adding gates incorrectly or something very odd is going on. I have also noticed that the following example from page 7 of 'filters.pdf' produces different results depending upon which version of the 'filters.pdf' document that I look at. > xyplot(`SSC-H` ~ `FSC-H` | Visit, + data = transform("SSC-H"=asinh,"FSC-H"=asinh) %on% GvHD, + subset = Patient == "6", + filterResults = n2gate.results, + filter = n2gate, + smooth = FALSE, alpha = 0.1) In the filters.pdf dated March 21, 2008 the gated cells are pink and the gate is outlined (exactly what I cannot do), but in the June 3 and September 20 documents gated cells are black and there is not outline of the gate dimensions (which is what I am able to do). The example that is supposed to draw a red outlined gate in xyplot(smooth =F) follows a similar pattern of color/no color. I have no problems getting a black outlined gate to be drawn on the plots with xyplot(smooth=T). Any further suggestions would be greatly appreciated. thanks! > sessionInfo() R version 2.7.0 (2008-04-22) i386-pc-solaris2.11 locale: C attached base packages: [1] tools stats graphics grDevices utils datasets methods [8] base other attached packages: [1] flowViz_1.4.1 latticeExtra_0.5-2 lattice_0.17-15 RColorBrewer_1.0-2 [5] flowCore_1.6.0 Biobase_2.0.1 feature_1.1-13 KernSmooth_2.22-22 [9] rrcov_0.4-07 robustbase_0.4-3 loaded via a namespace (and not attached): [1] AnnotationDbi_1.2.2 DBI_0.2-4 MASS_7.2-44 [4] RSQLite_0.7-0 geneplotter_1.18.0 grid_2.7.0 [7] stats4_2.7.0 aric -- Aric Gregson <a.gregson at="" ucla.edu="">
ADD REPLY
0
Entering edit mode
Hi Aric, sorry for the late reply, I didn't follow the mailing list the past several days. Looks like a bug in flowViz on the Mac. Things are fine on my Linux box, but I get the same strange behavior on my Macbook. There will be many changes and bug fixes with the upcoming release (in about two weeks, I think), and as far as I can tell right now this issue is already fixed in the latest devel version. There will also be significantly updated documentation and vignettes available, the current one is very slim, to put it nicely :) I will check into this in more detail and get back to you tomorrow. Did the contour plot errors go away with the update? And what about the gate on the density plots? I am afraid I still don't get what the CD3.4.fp3Live.subset flowSet is. Is that the result of the subsetting operation using rectCCR7.filter? If that is the case you won't see the gate on the plot. We don't plot lines of gate boundaries on densityplots, but indicate the gate region by color shading. And if your plot the data after subsetting, the whole density region will be in the gate, hence the whole area will be shaded. It would be very helpful if you could send me a coherent piece of code that indicates what you try to do, ideally beginning at data import. It looks like you are only interested in two frames in the set, and sending either the two FCS files or a serialized version of CD3.4.fp3Livet[c(5,4)] to my FHCRC email address (fhahne add fhcrc dot org) would be very helpful. Florian On 06.10.2008, at 11:38, Aric Gregson wrote: > Florian, > > On Fri, 03 Oct 2008 13:31:57 -0700 > Florian Hahne <fhahne at="" fhcrc.org=""> wrote: > >> Let me know if that doesn't address your problem. Also please provide >> the output of sessionInfo() in future posts, > > I thought that perhaps the drawing of gates on the densityplot, the > lack of contour() working and the fact that none of the gate outlines > are ever drawn in xyplot(smooth=F) was due to my environment, so I > upgraded. My machine environment is listed below. There was no change > in plot results. I then tried on a clean install of R 2.7.2 and the > most recent bioconductor packages (as of yesterday) for this version > of R on a Mac (sessionInfo not listed) and there was no change in plot > behavior. > > I used the same .RData and .Rhistory files on both machines, before > and after the upgrades, if that makes a difference. I must be > setting up > and adding gates incorrectly or something very odd is going on. > > I have also noticed that the following example from page 7 of > 'filters.pdf' produces different results depending upon which version > of the 'filters.pdf' document that I look at. > >> xyplot(`SSC-H` ~ `FSC-H` | Visit, > + data = transform("SSC-H"=asinh,"FSC-H"=asinh) %on% GvHD, > + subset = Patient == "6", > + filterResults = n2gate.results, > + filter = n2gate, > + smooth = FALSE, alpha = 0.1) > > In the filters.pdf dated March 21, 2008 the gated cells are pink and > the gate is outlined (exactly what I cannot do), but in the June 3 and > September 20 documents gated cells are black and there is not outline > of the gate dimensions (which is what I am able to do). The example > that > is supposed to draw a red outlined gate in xyplot(smooth =F) follows a > similar pattern of color/no color. I have no problems getting a black > outlined gate to be drawn on the plots with xyplot(smooth=T). > > Any further suggestions would be greatly appreciated. > > thanks! > >> sessionInfo() > R version 2.7.0 (2008-04-22) > i386-pc-solaris2.11 > > locale: > C > > attached base packages: > [1] tools stats graphics grDevices utils datasets > methods > [8] base > > other attached packages: > [1] flowViz_1.4.1 latticeExtra_0.5-2 lattice_0.17-15 > RColorBrewer_1.0-2 [5] flowCore_1.6.0 Biobase_2.0.1 > feature_1.1-13 KernSmooth_2.22-22 [9] rrcov_0.4-07 > robustbase_0.4-3 > > loaded via a namespace (and not attached): > [1] AnnotationDbi_1.2.2 DBI_0.2-4 MASS_7.2-44 > [4] RSQLite_0.7-0 geneplotter_1.18.0 grid_2.7.0 > [7] stats4_2.7.0 > > aric > -- > Aric Gregson <a.gregson at="" ucla.edu="">
ADD REPLY

Login before adding your answer.

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