Cytometry
data with ggplot
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
flowSet/ncdfFlowSet/flowFrame
ggcyto
ggcyto
constructor along with overloaded +
operator encapsulate lots of details that might be tedious and
intimidating for many users.
It simplies the plotting by: * add a default scale_fill_gradientn for
you * fuzzy-matching in aes
by either detector or
fluorochromes names * determine the parent
popoulation
automatically * exact and plot the gate object by simply referring to
the child
population name
autoplot
Inheriting the spirit from ggplot’s Quick plot
, it
further simply the plotting job by hiding more details from users and
taking more assumptions for the plot.
flowSet
, it determines geom
type automatically by the number of dim
suppliedGatingSet
, it further skip the need of
dim
by guessing it from the children
gateIt is done by different scales
layers speically designed
for cytometry
geom_gate
layerIt hides the complex details pf plotting different geometric shapes
fr <- fs[[1]]
p <- autoplot(fr,"CD4", "CD8") + ggcyto_par_set(limits = "instrument")
#1d gate vertical
gate_1d_v <- openCyto::gate_mindensity(fr, "<B710-A>")
p + geom_gate(gate_1d_v)
#2d rectangle gate
gate_rect <- rectangleGate("<B710-A>" = c(gate_1d_v@min, 4e3), "<R780-A>" = c(gate_1d_h@min, 4e3))
p + geom_gate(gate_rect)
## [1] "ellipsoidGate"
## attr(,"package")
## [1] "flowCore"
geom_stats
axis_inverse_trans
It can display the log
scaled data in the original
value
It currently only works with GatingSet
.
Optionally you can set limits by instrument
or
data
range
You can choose between marker
and channel
names (or both
by default)
ggcyto_par_set
It aggregates the different settings in one layer
#put all the customized settings in one layer
mySettings <- ggcyto_par_set(limits = "instrument"
, facet = facet_wrap("name")
, hex_fill = scale_fill_gradientn(colours = rev(RColorBrewer::brewer.pal(11, "Spectral")))
, lab = labs_cyto("marker")
)
# and use it repeatly in the plots later (similar to the `theme` concept)
p + mySettings
Currently we only support 4
settings, but will add more
in future.
as.ggplot
It allows user to convert ggcyto
objects to pure
ggplot
objects for further the manipulating jobs that can
not be done within ggcyto
framework.
## [1] "ggcyto_GatingSet"
## attr(,"package")
## [1] "ggcyto"
## [1] "gg" "ggplot"
Layout many gate plots on the same page
When plooting a GatingHierarchy
, multiple cell
populations with their asssociated gates can be plotted in different
panels of the same plot.
## [1] "singlets" "CD3+" "CD4" "CD4/38- DR+" "CD4/38+ DR+"
## [6] "CD4/38+ DR-" "CD4/38- DR-" "CD8"
## [1] "ggcyto_GatingLayout"
## attr(,"package")
## [1] "ggcyto"
As you see, this generates a special ggcyto_GatingLayout
object which is a container storing multiple ggcyto
objects. You can do more about the plot layout with the helper function
ggcyto_arrange
. For example, to arrange it as one-row
gtable object
## [1] "gtable" "gTree" "grob" "gDesc"
or even combine it with other ggcyto_GatingLayout
objects(or any gtable
objects) and print it on the sampe
page