Cytometry
data with ggplot
library(ggcyto)
dataDir <- system.file("extdata",package="flowWorkspaceData")
3
types of plot constructorggplot
The overloaded fority
methods empower
ggplot
to work with all the major Cytometry data structures
right away, which allows users to do all kinds of highly customized and
versatile plots.
GatingSet
gs <- load_gs(list.files(dataDir, pattern = "gs_manual",full = TRUE))
attr(gs, "subset") <- "CD3+"
ggplot(gs, aes(x = `<B710-A>`, y = `<R780-A>`)) + geom_hex(bins = 128) + scale_fill_gradientn(colours = gray.colors(9))
flowSet/ncdfFlowSet/flowFrame
fs <- gs_pop_get_data(gs, "CD3+")
ggplot(fs, aes(x = `<B710-A>`)) + geom_density(fill = "blue", alpha= 0.5)
gates
gates <- filterList(gs_pop_get_gate(gs, "CD8"))
ggplot(gs, aes(x = `<B710-A>`, y = `<R780-A>`)) + geom_hex(bins = 128) + geom_polygon(data = gates, fill = NA, col = "purple")
ggcyto
ggcyto
constructor along with overloaded +
operator encapsulate lots of details that might be tedious and
intimidating for many users.
ggcyto(gs, aes(x = CD4, y = CD8)) + geom_hex(bins = 128) + geom_gate("CD8")