knitr::opts_chunk$set(echo = TRUE)
CytoRSuite provides a variety of useful gating functions to interactively draw gates around populations for the analysis of flow cytometry data. Here we will demonstrate the use of these functions to return flowCore
gate objects for downstream analyses. Below we outline the gating functions currently supported by CytoRSuite as well as their required inputs:
gate_polygon_draw
- constructs polygonGate(s) based on selection of a minimum of 3 points. Polygon gates are sealed by right clicking and selecting "stop".gate_rectangle_draw
- constructs rectangleGate(s) based on selection of 2 diagonal points defining the limits of the gate.gate_boundary_draw
- constructs a lower open-ended rectangleGate based on selection of 1 point indicating the upper bound of the population. Boundary gates are supported in both 1 and 2 dimensions.gate_threshold_draw
- constructs an upper open-ended rectangleGate based on selection of 1 point indicating the lower bound of the population. Threshold gates are supported in both 1 and 2 dimensions.gate_interval_draw
- constructs rectangleGate(s) based on selection of 2 points indicating the lower and upper bounds of the population. Interval gates are supported in both 1 and 2 dimensions.gate_ellipse_draw
- constructs ellipsoidGate(s) based on selection of 4 points indicating the lower and upper bounds of the population in 2 dimensions. gate_quadrant_draw
- constructs 4 open-ended rectangleGates based on selection of 1 point indicating the center of the crosshair between 4 populations. gate_web_draw
- constructs any number of polygonGates based on selection of a center point and surrounding separating points. See below for demonstration.gate_draw
is a wrapper for all of these gating functions which takes on an argument type
to indicate that type of gate to draw and construct.All gating functions have the same format with minor variations as detailed below:
gate_draw(fr, channels, alias = NULL, display = 1, plot = TRUE, label = TRUE, ...)
flowFrame
to be gated. For objects of classes flowSet
and GatingSet
refer to the more versatile gate_draw
function.flowFrame
, all events will be plotted.To demonstrate the use of CytoRSuite's gating functions we will use the "Activation" flowSet shipped with CytoRSuiteData. This flowSet contains 4 samples from an in vitro activation assay where activated dendritic cells pulsed with ovalbumin were used to stimulate OT-I (CD8+) and OT-II (CD4+) transgenic T cells. For more information about this flowSet
see ?Activation.
# Load in required packages library(CytoRSuite) library(CytoRSuiteData) # Load in Activation dataset fs <- Activation # Extract spillover matrix from flowFrame description slot - see ?computeSpillover ?editSpillover spill <- fs[[1]]@description$SPILL # Apply compensation to samples & save to object fs fs <- compensate(fs, spill) # Apply logicle transformation to all fluorescent channels trans <- estimateLogicle(fs[[1]], colnames(spill)) fs <- transform(fs, trans) # We will use the pooled samples for gating - for large datasets use display to limit events for plotting fr <- as(fs, "flowFrame")
gate_polygon_draw
# Gate cells based on FSC-A & SSC-A - close gate by right click & "stop" - save gate to gts gts <- gate_polygon_draw(fr, alias = "Cells", channels = c("FSC-A","SSC-A"))
knitr::include_graphics('Gating-functions/drawPolygon.gif')
# gts is a filters list containing the constructed gates that can be easily applied to samples Cells <- Subset(fr, gts[[1]])
gate_rectangle_draw
# Gate single cells by selecting 2 diagonal points of rectangle - add gate to gts gts <- gate_rectangle_draw(Cells, alias = "Single Cells", channels = c("SSC-W","SSC-H"))
knitr::include_graphics('Gating-functions/drawRectangle.gif')
# gts is a filters list containing the constructed gates that can be easily applied to samples Singlets <- Subset(Cells, gts[[1]])
gate_boundary_draw
# Gate live cells as Hoechst- Alexa Fluor 405-A - gate not applied to demonstrate 2-D boundary gates gate_boundary_draw(Singlets, alias = "Cells", channels = "Alexa Fluor 405-A")
knitr::include_graphics('Gating-functions/drawBoundary1D.gif')
# Gate live cells using 2-D boundary gate gts <- gate_boundary_draw(Singlets, alias = "Live Cells", channels = c("Alexa Fluor 405-A","Alexa Fluor 430-A"))
knitr::include_graphics('Gating-functions/drawBoundary2D.gif')
# gts is a filters list containing the constructed gates that can be easily applied to samples Live <- Subset(Singlets, gts[[1]])
gate_threshold_draw
# Gate T cells as Va2-PE+ - gate not applied to demonstrate 2-D threshold gates gate_threshold_draw(Live, alias = "T Cells", channels = "PE-A")
knitr::include_graphics('Gating-functions/drawThreshold1D.gif')
# Gate T cells as Va2-PE+ using 2-D threshold gate gts <- gate_threshold_draw(Live, alias = "T Cells", channels = c("APC-Cy7-A","PE-A"))
knitr::include_graphics('Gating-functions/drawThreshold2D.gif')
# gts is a filters list containing the constructed gates that can be easily applied to samples Va2 <- Subset(Live, gts[[1]])
gate_interval_draw
# Gate Dendritic cells CD11c+ APC cy7 using 1D interval gate - gate not applied to demonstrate 2D interval gates gate_interval_draw(Live, alias = "Dendritic Cells", channels = "APC-Cy7-A")
knitr::include_graphics('Gating-functions/drawInterval1D.gif')
# Gate dendritic cells CD11c+ APC Cy7 using 2D interval gate gts <- gate_interval_draw(Live, alias = "Dendritic Cells", channels = c("Qdot 605-A", "APC-Cy7-A"), axis = "y")
knitr::include_graphics('Gating-functions/drawInterval2D.gif')
# gts is a filters list containing the constructed gates that can be easily applied to samples DC <- Subset(Live, gts[[1]])
gate_ellipse_draw
# Gate CD8+ T cells using ellipsoid gate - gate not applied to demonstrate quadrant and web gates gate_ellipse_draw(Va2, alias = "CD8 T Cells", channels = c("Alexa Fluor 700-A","Alexa Fluor 488-A"))
knitr::include_graphics('Gating-functions/drawEllipse.gif')
gate_quadrant_draw
# Gate CD4 & CD8 T cells using quadrant gates - gates not applied to demonstrate web gates # Quadrant gates are named from bottom left anticlockwise to top left gate_quadrant_draw(Va2, alias = c("CD4- CD8-","CD4+ CD8-","CD4+ CD8+","CD4+ CD8+"), channels = c("Alexa Fluor 700-A","Alexa Fluor 488-A"))
knitr::include_graphics('Gating-functions/drawQuadrants.gif')
gate_web_draw
# Gate CD4 & CD8 T cells using web gates - gates not applied to demonstrate web gates # Gates are named from bottom left anticlockwise to top left gts <- gate_web_draw(Va2, alias = c("DN","CD4 T Cells","CD8 T Cells"), channels = c("Alexa Fluor 700-A","Alexa Fluor 488-A"))
knitr::include_graphics('Gating-functions/drawWeb.gif')
# gts is a filters list containing the constructed gates that can be easily applied to samples CD4 <- Subset(Va2, gts[[2]]) CD8 <- Subset(Va2, gts[[3]])
# Gate CD4 & CD8 T cells using multiple rectangle gates - gates not applied # Number of gates is determined based on how many populations are specified in "alias" gate_rectangle_draw(Va2, alias = c("CD4 T Cells","CD8 T Cells"), channels = c("Alexa Fluor 700-A", "Alexa Fluor 488-A"))
knitr::include_graphics('Gating-functions/MultiGates.gif')
# Gate CD4 & CD8 T cells using mixed gates - gates not applied # Gating functions can be mixed by setting plot = FALSE for subsequent gates & keep plotting window open gate_rectangle_draw(Va2, alias = "CD4 T Cells", channels = c("Alexa Fluor 700-A","Alexa Fluor 488-A")) gate_ellipse_draw(Va2, alias = "CD8 T Cells", channels = c("Alexa Fluor 700-A","Alexa Fluor 488-A"), plot = FALSE)
knitr::include_graphics('Gating-functions/MixedGates.gif')
For more information on these gating functions refer to the documentation for these functions in the Reference. To learn more about how to edit and remove gates refer to Gate Manipulation vignette.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.