Skip to content

jonesnoaht/flowQuick

Repository files navigation

flowQuick

Quick and reproducible flow cytometry analysis in R.

flowQuick provides convenience wrappers around the Bioconductor flow cytometry stack (flowCore, flowWorkspace, flowAI and ggcyto) so that a typical analysis — quality control, compensation, scatter/singlet gating, fluorescence-minus-one (FMO) gating and plotting — takes a handful of calls instead of pages of boilerplate.

A small example data set (cs, a cytoset borrowed from a real experiment) is bundled so you can try every function without any FCS files of your own.

Installation

# install.packages("remotes")
remotes::install_github("jonesnoaht/flowQuick")

flowQuick depends on several Bioconductor packages. If they are not already installed:

# install.packages("BiocManager")
BiocManager::install(c("flowCore", "flowWorkspace", "flowAI", "ggcyto",
                       "flowStats", "CytoML", "cytolib"))

Quick start

library(flowQuick)

# 1. Read raw FCS files into a flowSet
fs <- generate_flowset("path/to/fcs/files")

# 2. Quality-control the data (runs flowAI, caches the result on disk)
cs <- get_fcs_resultsQC(QC_folder = "resultsQC/", raw_folder = "rawData/")

# 3. Build a GatingSet with tube names attached
gs <- make_gs(cs)

# 4. Add cell + singlet gates in one call (safe to re-run)
gates <- quick_gate(gs)

# 5. Draw gates automatically from your FMO controls
make_gates_from_fmos(gs, parent = "SSC-singlet", search_term = "FMO")

# 6. Hand the gates off to FlowJo (and read them back later)
gs_to_flowjo(gs, "my_analysis.wsp")
gs2 <- flowjo_to_gs("my_analysis.wsp")

Automatic FMO gating

make_gates_from_fmos() finds the FMO control tubes (by search_term), works out which marker each is the FMO for, and draws a one-dimensional threshold gate for that marker across every sample. By default the negative/positive cutoff is a robust upper fence, median + k * mad, which is less sensitive to the spread of the FMO population than a raw percentile. Pass method = "quantile" to use a high quantile instead:

# Robust default (median + 5 * MAD)
make_gates_from_fmos(gs, parent = "SSC-singlet")

# Looser robust gate
make_gates_from_fmos(gs, parent = "SSC-singlet", k = 3)

# Quantile-based cutoff at the 99.9th percentile
make_gates_from_fmos(gs, parent = "SSC-singlet",
                     method = "quantile", probability = 0.999)

Function reference

Function What it does
generate_flowset() Read every .fcs file in a folder into a flowSet.
get_fcs_resultsQC() Load cached QC results, or run flowAI QC if none exist.
compensate_data() Build a spillover matrix from single-stained controls.
make_gs() Turn a cytoset into a GatingSet with tube names in pData.
quick_gate() Add cell, FSC-singlet and SSC-singlet gates (idempotent).
set_scatter_gate() Add an arbitrary polygon gate from raw coordinates.
test_plot() Preview a polygon gate before committing to it.
make_gates_from_fmos() Automatically derive positive/negative gates from FMO controls.
update_gate() Replace an existing gate's filter in place.
gs_to_flowjo() Export a GatingSet to a FlowJo workspace (.wsp).
flowjo_to_gs() Read a FlowJo .wsp workspace back into a GatingSet.

clean_data() is retained for backwards compatibility but is deprecated in favour of get_fcs_resultsQC().

For a full, end-to-end walk-through (QC → compensation → gating → publication figures) see the example vignette.

License

MIT © flowQuick authors. See LICENSE.md.

About

A package to make the analysis of flow data easier.

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages