| name | bio-flow-cytometry-gating-analysis |
| description | Manual and automated gating for defining cell populations in flow cytometry. Covers rectangular, polygon, and data-driven gates. Use when identifying cell populations through hierarchical gating strategies. |
| tool_type | r |
| primary_tool | flowWorkspace |
Gating Analysis
Manual Rectangular Gates
library(flowCore)
cd4_gate <- rectangleGate(filterId = 'CD4+',
'CD4' = c(500, Inf),
'CD3' = c(200, Inf))
cd4_result <- filter(fcs, cd4_gate)
summary(cd4_result)
cd4_cells <- Subset(fcs, cd4_gate)
Polygon Gates
vertices <- matrix(c(100, 100,
1000, 100,
1000, 1000,
100, 1000),
ncol = 2, byrow = TRUE)
colnames(vertices) <- c('FSC-A', 'SSC-A')
poly_gate <- polygonGate(filterId = 'Lymphocytes', .gate = vertices)
lymph <- Subset(fcs, poly_gate)
Gating Hierarchy (flowWorkspace)
library(flowWorkspace)
gs <- GatingSet(fs)
gs_pop_add(gs, cd4_gate, parent = 'root')
cd4_cd8_gate <- rectangleGate(filterId = 'CD8+', 'CD8' = c(500, Inf))
gs_pop_add(gs, cd4_cd8_gate, parent = 'CD4+')
gs_get_pop_paths(gs)
recompute(gs)
gs_pop_get_stats(gs)
Automated Gating: flowDensity
library(flowDensity)
cd4_gate <- deGate(fcs, channel = 'CD4', use.upper = TRUE)
cd4_threshold <- cd4_gate@min
cd4_pos <- flowDensity(fcs, channels = 'CD4', position = c(TRUE))
cd4_cells <- getflowFrame(cd4_pos)
Automated Gating: openCyto
library(openCyto)
gating_template <- fread('
alias,pop,parent,dims,gating_method,gating_args
nonDebris,+,root,FSC-A,flowClust,K=2
singlets,+,nonDebris,"FSC-A,FSC-H",singletGate,
lymph,+,singlets,"FSC-A,SSC-A",flowClust,K=3
cd3,+,lymph,CD3,mindensity,
cd4,+,cd3,"CD4,CD8",quadrantGate,
')
gt <- gatingTemplate(gating_template)
gs <- GatingSet(fs)
gating(gt, gs)
Quadrant Gates
quad_gate <- quadGate(filterId = 'CD4_CD8_quad',
'CD4' = 500,
'CD8' = 500)
Boolean Gates
cd4_not_cd8 <- cd4_gate & !cd8_gate
gs_pop_add(gs,
booleanFilter(CD4+CD8- = CD4+ & !CD8+),
parent = 'lymph')
Extract Gated Populations
cd4_data <- gh_pop_get_data(gs[[1]], 'CD4+')
cd4_indices <- gh_pop_get_indices(gs[[1]], 'CD4+')
gs_pop_get_count_fast(gs)
Visualization
library(ggcyto)
autoplot(gs[[1]], 'CD4+')
autoplot(gs[[1]], c('CD4+', 'CD8+'))
autoplot(fcs, 'CD4', 'CD8') +
geom_gate(cd4_gate)
Export Gating Strategy
save_gs(gs, 'gating_set')
library(CytoML)
gatingset_to_flowjo(gs, 'analysis.wsp')
Related Skills
- compensation-transformation - Preprocess before gating
- clustering-phenotyping - Unsupervised alternative
- differential-analysis - Compare gated populations