DillonHammill / CytoExploreR

Interactive Cytometry Data Analysis
61 stars 13 forks source link

FEATURE DEMO: Manual Gating Based on Specific Samples #20

Closed DillonHammill closed 4 years ago

DillonHammill commented 4 years ago

In CytoExploreR, samples are pooled prior to plotting to generate a single consensus plot for gating. Users are also able to overlay specific samples through the overlay argument, such as FMO controls to aid in setting gates. CytoExploreR also has support for selecting which samples should be merged prior to plotting, so that users have control over which samples they use for gating. Since this is a new feature that is absent in CytoRSuite, I will put the necessary code here as an example:

# Download Activation fcs files
library(CytoExploreRData)
cyto_save(Activation, save_as = "Samples")

# Load in Activation samples & create gatingTemplate
gs <- cyto_setup("Samples", gatingTemplate = "gatingTemplate.csv")

# Look at experimental details (only has name column as we did not add anything)
cyto_details(gs)

# We can select samples based on these variables - select only Activation_33.fcs for gating
cyto_gate_draw(gs,
                   select = list(name = "Activation_33.fcs"),
                   parent = "root",
                   alias = "Cells",
                   channels = c("FSC-A","SSC-A"))

# You can add variables as necessary using `cyto_details_edit()`
cyto_details_edit(gs)

# We could for example add a `stain` column to indicate an FMO - gate based on FMO only
cyto_gate_draw(gs,
                   select = list(stain = "FMO"),
                   parent = "root",
                   alias = "Cells",
                   channels = c("FSC-A","SSC-A"))

Internally, this works by making a call to cyto_select() which is an extremely useful function to select samples based on experimental parameters. You can use cyto_select() in your analysis to pull out specific samples anytime. This is particularly useful when you want to plot a subset of the data:

# If we add a Treatment variable with Stim-A, Stim-B, Stim-C and Stim-D
cyto_details_edit(gs)

# We can pull out just Stim-A
gs_StimA <- cyto_select(gs, Treatment = "Stim-A")

# Plot just Stim-A samples
cyto_plot(gs_StimA,
             parent = "root",
             channels = c("FSC-A","SSC-A"))

# if we add an OVAConc column
cyto_details_edit(gs)

# We can select samples based on multiple variables
gs_StimA_naive <- cyto_select(gs, Treatment = "Stim-A", OVAConc = 0)

# Or we could select both Stim-A and Stim-B
gs_StimAB <- cyto_select(gs, Treatment = c("Stim-A", "Stim-B"))

CytoExploreR has a number of helper functions to easily accomplish tasks such as these. You can find a full list of available functions in the Reference section of the CytoExploreR website.