vignettes/advanced/ggplot.flowSet.1d.Rmd
ggplot.flowSet.1d.Rmd
ggcyto
makes ggplot2
to be able to work with Cytometry
data, namely flowSet/ncdfFlowSet
or flowFrame
S4 objects.
library(ggcyto)
data(GvHD)
fs <- GvHD[subset(pData(GvHD), Patient %in%5:7 & Visit %in% c(5:6))[["name"]]]
fr <- fs[[1]]
# logicle scale with default parameters setting (e.g. t = 262144)
p <- p + geom_histogram(colour = "white")
p + scale_x_logicle()
# customized breaks
myBreaks <- c(0, 10, 1e2, 1e3)
p + scale_x_logicle(t = 1e4, w = 0, breaks = myBreaks)
# save the scales
# myScales <- scale_x_flowJo_biexp(maxValue = 1e4, widthBasis = 0)
# density (default y is density)
p <- ggplot(fr, aes(x = `FL1-H`))
p + geom_density() + scale_x_log10()
# histogram + density line
ggplot(fr, aes(x = `FL1-H`, y = ..density..)) + geom_histogram(colour = "white") + geom_density(color = "red") + scale_x_log10()
# plot multiple samples
p <- ggplot(fs, aes(x = `FL1-H`)) + geom_area(stat = "density")+ scale_x_log10()
# facetting by sample names
p + facet_wrap(~name)
# fill with different colors
ggplot(fs, aes(x = `FL1-H`, fill = name)) + facet_wrap(~name) + geom_density(alpha = 0.2)+ scale_x_log10()
# or plot in the same panel
ggplot(fs, aes(x = `FL1-H`, fill = name)) + geom_density(alpha = 0.2) + scale_x_log10()