DillonHammill / CytoExploreR

Interactive Cytometry Data Analysis
61 stars 13 forks source link

Unassigned quad gate members of a parent population #116

Closed rwbaer closed 3 years ago

rwbaer commented 3 years ago

Briefly describe what you hope to achieve: I'm attempting to draw a set of quad gates on "single cells" and then plot them with cyto_plot() using a grouping variable. The resulting cyto_plots contain some dark blue points that seem to be "Single Cells" that were not assigned to any of the gates. These are evident in gates 1 and 3 of the set. What went wrong?

Outline the steps taken to attempt to reach this goal (paste code below): Here is the code for creating the gates

# Apply compensation to samples, based on the spill matrix calculated with our 
#   calibration beads
gsSamp <- cyto_compensate(gsSamp,
                      spillover = "Spillover-Matrix.csv")

## Transform fluorescent channels - default is a logicle transformations 
#         but this default did not work well here. Can't use line below.
#    gsSamp = cyto_transform(gsSamp)  ## can't use on this dataset

# Suggests to increase m. (trial and error, m = 6 thru 9 seem to work here)
logicleTransSamp <- cyto_transformer_logicle(gsSamp, m = 9)                              

# Apply our custom logicle transform for better viewing of our data
# never do this line more than once.  Start over if in doubt.
gsSamp = cyto_transform(gsSamp, trans = logicleTransSamp)

# Gate (non-debris) Cells
cyto_gate_draw(gsSamp,
               parent = "root",
               alias = "Non-Debris",
               channels = c("FSC-AREA", "SSC-AREA"))

# Gate Single Cells
cyto_gate_draw(gsSamp,
               parent = "Non-Debris",
               alias = "Single Cells",
               channels = c("FSC-AREA", "FSC-HEIGHT"))

# Select control sample using "Control" variable
gs_control <- cyto_select(gsSamp, Control =  TRUE)
# Extract data from control for overlay
cs_control <- cyto_extract(gs_control, "Single Cells")

# Draw Phagocytosis quadrant gate (single click, >greenest, >bluest controls)
# Labeled clockwise from upper left
# Quadrant gate
cyto_gate_draw(gsSamp,
               parent = "Single Cells",
               alias = c("Empty Macrophages","Phagocytic Macrophages",
                         "Free Bait LM45", "Unstained Cells"),
               channels = c("FL1-AREA","FL2-AREA"),
               type = "quadrant")

Here is the resulting gating plot flowGates flowGraphs

Here is the code for doing the plots

cyto_plot(gsSamp, 
          parent = "Single Cells",
          channels = c("FL2-AREA", "FL1-AREA"),
          popup = FALSE,
          overlay = c("Empty Macrophages","Phagocytic Macrophages",
                      "Free Bait LM45", "Unstained Cells"),
          group_by = "BaitType",
#          legend = c(FALSE, FALSE, TRUE),
          trans = logicleTransSamp)

Here are the resulting graphs.  Why the dark blue dots that seem part of single cells that got assigned to none of the 4 portions of the quad gate?
![flowGraphs](https://user-images.githubusercontent.com/3155051/116010036-50b28200-a5e2-11eb-8609-385a81d87fb2.png)
DillonHammill commented 3 years ago

@rwbaer, the events are within the gate. The reason you see the Single Cells is due to the sampling within cyto_plot(). If you set display = 1 you will see that this is the case.

FYI this has been fixed in the coming version of CytoExploreR.

rwbaer commented 3 years ago

A relief that it is not about a gating error I was making. Nice work-around to just set display to 1 if I need to. You keep helping me learn how deep this package really is. Thanks.