DillonHammill / CytoExploreR

Interactive Cytometry Data Analysis
60 stars 13 forks source link

cyto_gate_remove() struggles with removing quad gate #118

Closed rwbaer closed 3 years ago

rwbaer commented 3 years ago

Describe the bug As implied in the help documentation, I changed draw to remove in cyto_gate_draw() function. An error results because of the multiple gate names associated with this type of gate

To Reproduce Run the following type of code

> # Quadrant gate
> cyto_gate_draw(gsSamp,
+                parent = "Single Cells",
+                alias = c("Empty Macrophages", "Phagocytic Macrophages",
+                          "Uneaten Bait", "Unstained Cells"),
+                channels = c("FL1-AREA", "FL2-AREA"),
+                type = "quadrant")

> cyto_gate_remove(gsSamp,
+                parent = "Single Cells",
+                alias = c("Empty Macrophages","Phagocytic Macrophages",
+                          "Uneaten Bait", "Unstained Cells"),
+                channels = c("FL1-AREA","FL2-AREA"),
+                type = "quadrant")
Removing gate(s) from the GatingSet and Samples-gatingTemplate.csv.
Warning messages:
1: In if (alias[z] == y) { :
  the condition has length > 1 and only the first element will be used
2: In if (alias[z] == y) { :
  the condition has length > 1 and only the first element will be used
3: In if (alias[z] == y) { :
  the condition has length > 1 and only the first element will be used
4: In if (alias[z] == y) { :
  the condition has length > 1 and only the first element will be used

Expected behavior I expect the four associated gates to disappear so that I can redraw them.

Desktop (please complete the following information): Windows 10

Additional context This works with simple, single alias gates, just not quad gates. The documentation does not provide an exception for quad gates.

I should add that when I try to remove the gates "one-by-one" after this error, I get an error telling me that the supplied alias does not exist in the gating set.

Edit 2 AND IF I TRY cyto_gate_draw() again, it seems to work. It seems that the gate removal code is working better than the error message would seem to be telling me!

I now notice that this is a warning message, not an error message. Still, I don't think it should be displayed here, and it improperly implies that the second, third and fourth gate were ignored.

DillonHammill commented 3 years ago

@rwbaer, just tried this on my end and everything works as expected. This is just a warning that doesn't affect the expected behaviour, but nevertheless I will track it down so that it doesn't pop up again.

DillonHammill commented 3 years ago

@rwbaer, this should now be fixed. Please pull down the latest version of CytoExploreR and try again:

devtools::install_github("DillonHammill/CytoExploreR")

I just updated the handling of nodes within cyto_gate_remove() to use cyto_nodes_convert(). I also made cyto_gate_remove() return your GatingSet to match new behaviour of its sister functions cyto_gate_draw() and cyto_gate_edit().

rwbaer commented 3 years ago

Just tried after the update and the warning is gone. Thanks!