DillonHammill / CytoExploreR

Interactive Cytometry Data Analysis
61 stars 13 forks source link

Error: Single cells not found! Spill Editor #46

Closed rwbaer closed 4 years ago

rwbaer commented 4 years ago

Briefly describe what you hope to achieve: Sorry to be so noisy ...

I am having trouble understanding the "persistence" requirements of many of the cyto_xxx commands. For example, knowing what .csv files SHOULD exist and what .csv files SHOULD NOT exist. In the code snippet below from the overview tutorial, I have already created a Compensation-gatingTemplate.csv file with single cells in it, and yet the cyto_spillover_edit function claims "Single Cells Not found" (see editor screenshot below). It seems improbable that I should manually delete and recreate the gating template in order to use the editor. But what should I be doing to tell the editor to edit the spill object? The individual help files are not giving me the big picture I need yet. Is there an overview of such things that I should be studying?

As a second example of my confusion, cyto_plot_compensation() always brings up an unpopulated channel selector despite my having already mapped the channels once. Do I need to be adding/saving this information so that it can be reused or edited in later contexts?

Outline the steps taken to attempt to reach this goal (paste code below):

Listening on http://127.0.0.1:3157 Warning: Error in get_cytoset_from_node: Single Cells not found! 180: Warning: Error in get_cytoset_from_node: Single Cells not found! 180: Warning: Error in get_cytoset_from_node: Single Cells not found! 180: Warning: Error in get_cytoset_from_node: Single Cells not found! 180: Warning in doTryCatch(return(expr), name, parentenv, handler) : display list redraw incomplete Warning in doTryCatch(return(expr), name, parentenv, handler) : display list redraw incomplete



**Include any associated screenshots or images here:**
![gateEdit](https://user-images.githubusercontent.com/3155051/82251644-2efd4500-9913-11ea-8edf-64e542d19d06.png)
DillonHammill commented 4 years ago

@rwbaer, R is case sensitive so make sure that you are supplying the correct name for the population (i.e. Single Cells versus single cells). You can check the names of the nodes using cyto_nodes(gs).

For various reasons, the channel selections are only retained after running cyto_spillover_compute(), which should always be run before cyto_spillover_edit() or cyto_plot_compensation().

rwbaer commented 4 years ago

Probably not case-sensitivity issue which I am clear on. I'm was just careless while typing my post :( The problem is probably repeating your code in an unfortunate order that is messing things up. I have been trying to understand what each line is doing. BTS, your vignettes are VERY well written and easy to copy and paste. It is my learning that is struggling.

Here is my Compensation-gatingTemplate.csv, and the file does have Single Cells row.


alias | pop | parent | dims | gating_method | gating_args | collapseDataForGating | groupBy | preprocessing_method | preprocessing_args
-- | -- | -- | -- | -- | -- | -- | -- | -- | --
Cells | + | root | FSC-A,SSC-A | cyto_gate_draw | gate = list('Combined Events' = new('filters', .Data =   list(new('polygonGate',     boundaries   = structure(c(67827.4037042295, 38716.8408286659,     70110.5851062344, 103216.715435307,   66115.0176527257, 36489.2915168948,       10626.9773035178, -8461.8736634986, 22942.3650241735,   35873.522130862    ), .Dim = c(5L, 2L),   .Dimnames = list(NULL, c('FSC-A', 'SSC-A'      ))), parameters = new('parameters', .Data =   list(new('unitytransform',           .Data = function ()           NULL, parameters = 'FSC-A', transformationId =   'defaultUnityTransform'),           new('unitytransform', .Data = function ()         NULL, parameters = 'SSC-A',   transformationId = 'defaultUnityTransform'))),     filterId = 'Cells')))),   openCyto.minEvents = -1 | TRUE | NA | pp_cyto_gate_draw | NA
Single Cells | + | Cells | FSC-A,FSC-H | cyto_gate_draw | gate = list('Combined Events' = new('filters', .Data =   list(new('polygonGate',     boundaries   = structure(c(38716.8408286659, 110066.259641322,     99791.9433322992, 17597.4128601198,   41000.0222306709, 20479.2874800423,       89445.4587157144, 103608.154594468, 32794.6752006981,   20479.2874800423    ), .Dim = c(5L,   2L), .Dimnames = list(NULL, c('FSC-A', 'FSC-H'    ))), parameters = new('parameters', .Data   = list(new('unitytransform',           .Data = function ()           NULL, parameters = 'FSC-A', transformationId =   'defaultUnityTransform'),           new('unitytransform', .Data = function ()         NULL, parameters = 'FSC-H',   transformationId = 'defaultUnityTransform'))),     filterId = 'Single Cells')))),   openCyto.minEvents = -1 | TRUE | NA | pp_cyto_gate_draw | NA

So Single Cells seems to be in the file, but not recognized for use, and I can't add it to the gating set using cyto_gate_draw() Finally, cyto_nodes(gs) confirms that it is not in the gating set. I know something is missing from my understanding, like how to add it to the gating set and how the gs relates to the .csv file in terms of who is used for what. How did Single Cells get in the .csv but not in the gs

# Visualise uncompensated data
> cyto_plot_compensation(gs,
+                        parent = "Single Cells")
Select a fluorescent channel for each of the samples:
Error in get_cytoset_from_node(obj@pointer, y) : Single Cells not found!
> # Gate Single Cells
> cyto_gate_draw(gs,
+                parent = "Cells",
+                alias = "Single Cells",
+                channels = c("FSC-A", "FSC-H"))
Single Cells already exists in Compensation-gatingTemplate.csv.
Error in FUN(X[[i]], ...) : 
  Supply another gatingTemplate or edit gate(s) using cyto_gate_edit.
> cyto_nodes(gs)
[1] "root"
> 
DillonHammill commented 4 years ago

The gatingTemplate is created as a by-product of cyto_gate_draw() to keep a record of the gating scheme. cyto_gate_draw() will automatically update the GatingSet with the gates as they are constructed. If you already have the gatingTemplate, there is no need to re-draw the gates using cyto_gate_draw(), instead you can just apply the gatingTemplate to the GatingSet directly:

gs <- cyto_gatingTemplate_apply(gs, "Compensation-gatingTemplate.csv")

If a gatingTemplate already exists and cyto_gate_draw() is called, it will check to see the gate has already been defined in the gatingTemplate and throw an error if it already exists. This was added intentionally to prevent users from accidentally overriding gates that they had previously drawn.

rwbaer commented 4 years ago

This helps immensely. Thanks. You might consider extracting your nice explanation and making it a part of a "design considerations" or "workflows" document for new users like me, once you accumulate more questions like this. I'll go read about cyto_gatingTemplate_apply() and look at the function list again to get a better feel for what might be available.