Skip to content
cccskills
FreePublished on GitHub

bio-flow-cytometry-gating-analysis

Identify cell populations in flow cytometry data using manual boundaries or automated methods. Organize populations into a hierarchy, extract matching cells, summarize counts, visualize boundaries, and save or export the analysis.

OriginalShow the original 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.

See how to install

Good for

  • Extract cells that meet marker conditions
  • Apply the same gating template across samples
  • Inspect population counts and gate plots
  • Export a gating strategy to FlowJo

Files included (3)

  • SKILL.md4.5 KB
  • examples/gating_workflow.R1.2 KB
  • usage-guide.md2.2 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Version Compatibility

Reference examples tested with: flowCore 2.14+

Before using code patterns, verify installed versions match. If versions differ:

  • R: packageVersion('<pkg>') then ?function_name to verify parameters

If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.

Gating Analysis

"Gate my flow cytometry data to identify cell populations" → Define cell populations through manual or automated gating strategies using rectangular, polygon, or data-driven gates in a hierarchical framework.

  • R: flowWorkspace::gs_add_gating_method(), openCyto::gating() for automated gating

Manual Rectangular Gates

library(flowCore)

# Create rectangular gate
cd4_gate <- rectangleGate(filterId = 'CD4+',
                           'CD4' = c(500, Inf),
                           'CD3' = c(200, Inf))

# Apply gate
cd4_result <- filter(fcs, cd4_gate)
summary(cd4_result)

# Get cells in gate
cd4_cells <- Subset(fcs, cd4_gate)

Polygon Gates

# Define polygon vertices
vertices <- matrix(c(100, 100,    # x1, y1
                      1000, 100,   # x2, y2
                      1000, 1000,  # x3, y3
                      100, 1000),  # x4, y4
                    ncol = 2, byrow = TRUE)
colnames(vertices) <- c('FSC-A', 'SSC-A')

# Create polygon gate
poly_gate <- polygonGate(filterId = 'Lymphocytes', .gate = vertices)

# Apply
lymph <- Subset(fcs, poly_gate)

Gating Hierarchy (flowWorkspace)

library(flowWorkspace)

# Create GatingSet from flowSet
gs <- GatingSet(fs)

# Add gates to hierarchy
gs_pop_add(gs, cd4_gate, parent = 'root')

# Add child gate
cd4_cd8_gate <- rectangleGate(filterId = 'CD8+', 'CD8' = c(500, Inf))
gs_pop_add(gs, cd4_cd8_gate, parent = 'CD4+')

# View hierarchy
gs_get_pop_paths(gs)

# Recompute statistics
recompute(gs)

# Get population statistics
gs_pop_get_stats(gs)

Automated Gating: flowDensity

library(flowDensity)

# Data-driven gate based on density
cd4_gate <- deGate(fcs, channel = 'CD4', use.upper = TRUE)

# Get threshold
cd4_threshold <- cd4_gate@min

# Apply
cd4_pos <- flowDensity(fcs, channels = 'CD4', position = c(TRUE))
cd4_cells <- getflowFrame(cd4_pos)

Automated Gating: openCyto

Goal: Apply a reproducible, template-driven gating strategy that automatically identifies cell populations across all samples.

Approach: Define a CSV gating template specifying parent-child hierarchy, channel combinations, and gating algorithms (flowClust, singletGate, mindensity, quadrantGate), then apply the template to a GatingSet for batch processing.

library(openCyto)

# Define gating template
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,
')

# Apply template
gt <- gatingTemplate(gating_template)
gs <- GatingSet(fs)
gating(gt, gs)

Quadrant Gates

# Create quadrant gate
quad_gate <- quadGate(filterId = 'CD4_CD8_quad',
                       'CD4' = 500,
                       'CD8' = 500)

# Results in 4 populations:
# CD4+CD8-, CD4-CD8+, CD4+CD8+, CD4-CD8-

Boolean Gates

# Combine gates with logic
cd4_not_cd8 <- cd4_gate & !cd8_gate

# Alternative using GatingSet
gs_pop_add(gs,
           booleanFilter(CD4+CD8- = CD4+ & !CD8+),
           parent = 'lymph')

Extract Gated Populations

# Get data for specific population
cd4_data <- gh_pop_get_data(gs[[1]], 'CD4+')

# Get indices
cd4_indices <- gh_pop_get_indices(gs[[1]], 'CD4+')

# Counts
gs_pop_get_count_fast(gs)

Visualization

library(ggcyto)

# Plot with gates
autoplot(gs[[1]], 'CD4+')

# Multiple populations
autoplot(gs[[1]], c('CD4+', 'CD8+'))

# Gate overlay
autoplot(fcs, 'CD4', 'CD8') +
    geom_gate(cd4_gate)

Export Gating Strategy

# Save GatingSet
save_gs(gs, 'gating_set')

# Export to FlowJo workspace
library(CytoML)
gatingset_to_flowjo(gs, 'analysis.wsp')

Related Skills

  • compensation-transformation - Preprocess before gating
  • clustering-phenotyping - Unsupervised alternative
  • differential-analysis - Compare gated populations

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

adaptyv

FreeSummary

Support protein design with cloud laboratory testing for binding, expression, thermal stability, and enzyme activity. Covers sequence optimization, submitting experiments through the Adaptyv API, checking progress, and downloading experimental results.

  • Validate designed proteins with laboratory assays
  • Screen and redesign sequences for better solubility
  • Submit protein testing experiments through an API
FreedomIntelligence/OpenClaw-Medical-Skills3.1KUpdated Jul 21, 2026

Build flexible daily plans that account for ADHD-related difficulties with time estimation and getting started. Narrow priorities to three tasks, add transition buffers, and choose small next actions that match the energy available that day.

  • Choosing three priorities for today
  • Planning a schedule with transition buffers
  • Finding a small first step when starting feels difficult
FreedomIntelligence/OpenClaw-Medical-Skills3.1KUpdated Jul 21, 2026

aeon

FreeSummary

Build Python workflows for data recorded over time, including classification, forecasting, anomaly detection, and pattern search. Using aeon, the skill guides preprocessing, algorithm selection, feature extraction, and evaluation through interfaces compatible with scikit-learn.

  • Classify time series by their patterns
  • Forecast future values from historical data
  • Detect anomalies and change points
FreedomIntelligence/OpenClaw-Medical-Skills3.1KUpdated Jul 21, 2026

agent-browser

FreeSummary

Use a browser to research topics, extract page information, fill forms, and test websites. Guides agents through identifying page controls, interacting with web apps, saving screenshots or PDFs, and reusing saved login sessions.

  • Researching topics and reading web articles
  • Filling and submitting online forms
  • Extracting page text and links
FreedomIntelligence/OpenClaw-Medical-Skills3.1KUpdated Jul 21, 2026

ai-analyzer

FreeSummary

Combine health measurements, exercise, sleep, nutrition, and mental health records to examine trends, unusual changes, and estimated risks. The skill produces personalized suggestions and text or interactive HTML reports using local data without external API calls.

  • Review health records together in a comprehensive report
  • Explore links between sleep, mood, exercise, and weight
  • Summarize estimated disease and nutrition risks
FreedomIntelligence/OpenClaw-Medical-Skills3.1KUpdated Jul 21, 2026

alphafold

FreeSummary

Predict structures for designed protein sequences and protein complexes with AlphaFold2 or ColabFold. Inspect structure files and confidence scores to assess folding and chain interfaces, with guidance for local runs, Modal execution, and common prediction errors.

  • Check predicted folding of a designed protein sequence
  • Predict a binder–target protein complex
  • Review structure and interface confidence scores
FreedomIntelligence/OpenClaw-Medical-Skills3.1KUpdated Jul 21, 2026

See all skills by FreedomIntelligence

Report a problem with this skill