DillonHammill / CytoExploreR

Interactive Cytometry Data Analysis
60 stars 13 forks source link

cyto_convert to collapse gating set #141

Closed rwbaer closed 2 years ago

rwbaer commented 2 years ago

Briefly describe what you hope to achieve: I am attempting to automatically draw a quad gate based on all the samples in my gating set and add a node to the nodes I already created in CytoExploreR manually.

I had intended to use gate_quad_sequential() from the openCyto package and then gs_pop_add from the flowworkspace package.

Since gate_quad_sequential() requires a flow frame I tried to use cyto_convert from CytoExploreR to collapse the gating set into a single flow frame, but I seem to end up with an empty flow frame. Clearly, I'm doing something wrong. I was expecting the result to based on root node.

Any suggestions on how to approach such a task? What am I misunderstanding about cyto_convert?

Code fragment below

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

summary(gsSamp) Length Class Mode 5 GatingSet S4

Produce a quad filter object

qg = gate_quad_sequential(frAll,

  • channels = c("FL4-AREA", "FL2-AREA"),
  • gFunc = mindensity,
  • min = c(5e2, 5e2),
  • max = c(1e6, 1e6)) Error in if (nrow(peaks) < 2) score <- 0 else score <- abs(diff(peaks[, : argument is of length zero In addition: Warning message: In .find_peaks(x, ..., num_peaks = 2) : At least 2 observations must be given in 'x' to find peaks.

    Turn the quad filter object into 4 gating nodes

    use capitalized gate names to stay unique

    gs_pop_add(gsSamp, gq, validityCheck = TRUE,

  • names = c("Apoptotic", "Necrotic-Apoptotic", "Necrotic", "Live")) Error in is(gate, "filter") : object 'gq' not found

Include any associated screenshots or images here:

DillonHammill commented 2 years ago

cyto_convert() was originally designed for internal use only - in fact it has been removed from the new version of CytoExploreR. You should not attempt to gate data at the level of a cytoframe or cytoset, you should instead use cyto_gatingTemplate_edit() to add new openCyto entries to the gatingTemplate or call gs_add_gating_method() and update the gatingTemplate manually afterwards.

Remember, within CytoExploreR, the gatingTemplate serves as a means of keeping track of all the gating changes made to your GatingSet - it is important that any gates applied to your samples are accompanied with an entry in the gatingTemplate.

rwbaer commented 2 years ago

@DillonHammill With your help, I think I am now beginning to understand the philosophy behind integrating opencyto gates with cyto_explorer. This should open up more robust ways to analyze data. Your contributions have been really important. Thanks.