Learn R Programming

ggcyto : Visualize Cytometry data with ggplot

Overloaded fortify S3 method makes Cytometry data to be fully compatible with ggplot.

library(ggcyto)
dataDir <- system.file("extdata",package="flowWorkspaceData")
gs <- load_gs(list.files(dataDir, pattern = "gs_manual",full = TRUE))
fs <- getData(gs, "CD3+")

Quick plot with autoplot

#1d
autoplot(fs, "CD4")

#2d
autoplot(fs, "CD4", "CD8", bins = 64)

autoplot(gs, c("CD4", "CD8"), bins = 64)

More flexibility with ggcyto wrapper

ggcyto + flowSet

# support fuzzy-matching of aes to the data
# with flowJo-type of default color fills
# facet on `name` by default
ggcyto(fs,aes(x = CD4, y = CD8)) + geom_hex(bins = 64) + xlim(0, 3600)

ggcyto + GatingSet

ggcyto(gs,aes(x = CCR7, y = CD45RA), subset = "CD4") + geom_hex(bins = 64) + geom_gate("CD4/CCR7+ 45RA+") + geom_stats(fill = "yellow", size = 4)

Use ggplot directly to have more controls.

# 1d
p <- ggplot(fs, aes(x = `<B710-A>`)) + facet_wrap(~name) 
#histogram plot
p + geom_histogram(colour = "white")

#density plot
p + geom_density(fill = "black")

# 2d hexbin
ggplot(fs, aes(x = `<B710-A>`, y = `<R780-A>`)) + facet_wrap(~name) + geom_hex(bins = 64)

More examples of using ggplot directly on flowSet:

Copy Link

Version

Version

1.0.5

License

Artistic-2.0

Issues

Pull Requests

Stars

Forks

Maintainer

MJiang

Last Published

February 15th, 2017

Functions in ggcyto (1.0.5)

ggcyto-class

Create a new ggcyto plot
is.ggcyto_flowSet

Reports whether x is a ggcyto_flowSet object
getFlowFrame

extract flowFrame data structure from the given R object
compute_stats

compute the statistics of the cell population defined by gates
labs_cyto

Change axis labels and legend titles
print.ggcyto

Draw ggcyto on current graphics device.
scale_x_flowJo_fasinh

flowJo inverse hyperbolic sine scale
scale_x_flowJo_biexp

flowJo biexponential scale
ggcyto_par_default

Return The default ggcyto settings
marginalFilter

Generate a marginal gate.
print.ggcyto_GatingLayout

print method for ggcyto_gate_layout class It calls arrangeGrob to arrange a list of ggplot objects stored as ggcyto_gate_layout object
fortify.filterList

Convert a filterList to a data.table useful for ggplot
ggcyto.GatingSet

Create a new ggcyto plot from a GatingSet
geom_stats

Popluation statistics layer
geom_gate

add a flowCore gate layer
axis_x_inverse_trans

Display axis labels in raw scales
fortify.polygonGate

Convert a polygonGate to a data.table useful for ggplot
fortify.rectangleGate

Convert a rectangleGate to a data.table useful for ggplot
fortify.ellipsoidGate

Convert a ellipsoidGate to a data.table useful for ggplot
as.ggplot

It fortifies the data, fills some default settings and returns a regular ggplot object.
geom_hvline

Vertical or horizontal line.
is.ggcyto

Reports whether x is a ggcyto object
+.ggcyto_flowSet

overloaded '+' method for ggcyto
stat_position

compute the positions of the population statistics based on the geometic gate centroid
ggcyto_par_set

Set some default parameters for ggcyto
+.ggcyto_GatingSet

overloaded '+' method for ggcyto.gs
autoplot.flowSet

Plot fluorescence intensity in one or two dimension.
fortify.flowFrame

Convert a flowFrame/flowSet/GatingSet to a ggplot-compatible data.table
ggcyto.flowSet

Create a new ggcyto plot from a flowSet
is.ggcyto_par

Reports whether x is a ggcyto_par object
fortify_fs

Fortify a model into flowSet object
+.ggcyto_GatingLayout

overloaded '+' method for ggcyto_gate_layout
scale_x_logicle

flowJo inverse hyperbolic sine scale