/ggflow

Makes plotting flow cytometry data easy and pretty. This package reads flowFrame objects and plots them in beautiful scatter plots using ggplot2. You can also select/gate cells/events on a plot to remove/select relevant cells and you can display a visible, rectangular gate with percentage of selected cells highlighted.

Primary LanguageR

ggflow

ggflow is a plotting package for flow cytometry built on ggplot2 and flowCore. ggflow allows to easily plot flowFrame objects from FCS files into beautiful 2D scatter plots. Now with 6 pre-defined color sets!

plot of chunk color-chunk-1

To install please install the devtools package and type

library(devtools)
install_github("nbafrank/ggflow")

this package requires the ggplot2 and flowCore packages.

library(ggplot2)
library(flowCore)
library(ggflow)

To test it, you can use flowCore's example data by typing

data(GvHD)

In this data, you can use ggflow to plot FL4-H against FL1-H in log10 scale with an onverlaying density contour plot by simply typing:

ggflow_plot(GvHD[[1]],x_value="FL4-H",y_value="FL1-H")

plot of chunk unnamed-chunk-1

You can also create and plot a rectangular gate which will be displayed on the plot and provide a % count of the selected cells/events.

rectGate <- rectangleGate("FL1-H"=c(300, 6500),"FL4-H"=c(1.5,30))
gg_rectgater_display(ggflow_plot(GvHD[[1]],x_value="FL4-H",y_value="FL1-H"),rectGate)

plot of chunk unnamed-chunk-2

Additionally the rectangular gate object can also be used to select cells/events to be displayed. This is useful for instance if you are interested in gating a parameter and then plot others. This can be done with all gate objects from flowCore.

rectGate_cut <- rectangleGate("FSC-H"=c(60, 300),"SSC-H"=c(100,1000))
gg_rectgater_display(ggflow_plot(GvHD[[1]],x_value="FSC-H",y_value="SSC-H"),rectGate_cut)

ggcut <- gg_gate_cutter(ggflow_plot(GvHD[[1]],x_value="FL4-H",y_value="FL1-H"),rectGate_cut)

gg_rectgater_display(ggcut,rectGate)

plot of chunk unnamed-chunk-3