ggflow | R Documentation |
Draw a picture, with default colors reminiscent of FlowJo.
ggflow uses ggplot semantics to render bivariate flow cytometry plots. If called "bare", it draws a picture. If its return value is captured in a variable, further manipulation of the plot is possible. See the examples below.
ggflow( ff, params = c("FSC-A", "SSC-A"), colors = c("flowjo", "viridis", "plasma", "magma"), resolution = c("medium", "very_coarse", "coarse", "fine"), trans_sc = c("linear", "biexp", "asinh", "log"), trans_fl = c("biexp", "asinh", "log", "linear"), a = 0.002, cofactor = 5, indicate_zero = TRUE, xlim = NULL, ylim = NULL )
ff |
The flowFrame to be plotted |
params |
A vector of length 2 indicating the parameters of ff to be plotted |
colors |
A color palette for rendering densities of events. Currently, one of c("flowjo", "viridis", "plasma", "magma"). Can be abbreviated. |
resolution |
One of c("medium", "coarse", "fine"). Can be abbreviated. |
trans_sc |
The transformation that was applied to the scattering parameters of ff. Currently, one of c("linear", "biexp", "asinh", "log"). |
trans_fl |
The transformation that was applied to the fluorescence parameters of ff. Currently, one of c("linear", "biexp", "asinh", "log"). |
a |
Adjustable parameter "a" for the biexp transformation. Default = 0.002. |
cofactor |
Adjustable parameter "cofactor" for asinh transformation. Default = 5. |
indicate_zero |
Boolean, should we indicate the location of 0? |
xlim |
The limits of the plot in the x direction. NULL will apply sensible defaults. |
ylim |
The limits of the plot in the y direction. NULL will apply sensible defaults. |
A ggplot object.
# get some example data filename = system.file("extdata", "example1.fcs", package = "wadeTools") ff = get_sample(filename) # Recall that get_sample by default applies linear transformation to scattering # parameters and biexponential transformation to fluorescence parameters. # Plot ff on default FSC-A, SSC-A dimensions (notice linear axes) ggflow(ff) # another plot of fluorescence parameters. Note the biexponential axes. ggflow(ff, c("CD4PETR", "CD8Q705")) # one fluorescence (biexp) versus one scattering (linear) ggflow(ff, c("SSC-A", "CD3Q605")) # Add a title ggflow(ff, c("CD4PETR", "CD8Q705")) + labs(title = "Title of Plot") # or if you prefer, p = ggflow(ff, c("CD4PETR", "CD8Q705")) p + labs(title = "Another plot with a title") # Check out the other color schemes library("gridExtra") p1 = ggflow(ff, c("CD3Q605", "LIVEDEAD")) + labs(title = "flowjo") + theme(legend.position = 'right') p2 = ggflow(ff, c("CD3Q605", "LIVEDEAD"), colors = "v") + labs(title = "viridis") + theme(legend.position = 'right') p3 = ggflow(ff, c("CD3Q605", "LIVEDEAD"), colors = "m") + labs(title = "magma") + theme(legend.position = 'right') p4 = ggflow(ff, c("CD3Q605", "LIVEDEAD"), colors = "p") + labs(title = "plasma") + theme(legend.position = 'right') p = grid.arrange(p1, p2, p3, p4, nrow = 2, ncol = 2) p # Override plot limits and default resolution ggflow(ff, c("CD45RAQ655","CD11BAPCCY7"), xlim = bx(c(-1e3,1e6)), ylim = bx(c(-1e3,1e6)), res = 'f') # make a plot and add some blob boundaries params = c("SSC-A", "CD3Q605") x_range = 0.5 p1 = ggflow(ff, params) bb1 = blob.boundary(ff, c("SSC-A", "CD3Q605"), x_range = c(x_range, Inf), location = c(1.5, bx(8000)), height = .25) b1 = geom_path(bb1, mapping = aes(x = `SSC-A`, y = CD3Q605, group = 1)) bb2 = blob.boundary(ff, c("SSC-A", "CD3Q605"), x_range = c(x_range, Inf), location = c(3, bx(500)), height = .25) b2 = geom_path(bb2, mapping = aes(x = `SSC-A`, y = CD3Q605, group = 1)) bb3 = blob.boundary(ff, c("SSC-A", "CD3Q605"), x_range = c(x_range, Inf), location = c(0, 0), height = .25) b3 = geom_path(bb3, mapping = aes(x = `SSC-A`, y = CD3Q605, group = 1)) vline = geom_vline(aes(xintercept = x_range), linetype = "dotted") p1 + b1 + b2 + b3 + vline
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.