RGLab / openCyto

A package that provides data analysis pipeline for flow cytometry.
GNU Affero General Public License v3.0
77 stars 29 forks source link

Handling empty sets when gating with templates #177

Closed feltzmc closed 6 years ago

feltzmc commented 6 years ago

Hi @gfinak and @mikejiang,

I am trying to come up with some re-useable gating templates for a client that is working towards immunological cancer treatment cell manufacturing. When prepping cells for a patient they will remove CD3 cell surface markers from the T-cells. However during the flow cytometry analysis portion they would still like to have CD3+ and CD3- gates (which still work fine) and then still have quadgate plots that involve CD3+ gates. Currently if I attempt to use the missing CD3+ data further down in the template I get a variety of errors, the most common being:

Error in .find_peaks(x, num_peaks = num_peaks, adjust = adjust, plot = plot)[, : incorrect number of dimensions

I think that there is probably a template that will work around this issue but so far I have not figured out what this would be. For the quadgating section involving CD3+ data I have tried mindensity, mindensity2, tailgate, and flowClust algorithms with different parameters but haven't found anything that won't error on partially "missing" data.

I have attached my most recent attempt at a template to solve this issue. Please let me know if you have any advice.

Thanks, Matt

Template6.txt

mikejiang commented 6 years ago

If cd3 signal is missing, these conventional gating methods will typically result in empty cd3 data. If you intend to do the dummy gating on cd3 so that it simply passes on the non-empty data to the down stream gating, try to construct a dummy rectangleGate , e.g.

dummy_func <- function(fr, pp_res, channels, ...)
{
  g <- rectangleGate(`<V450-A>` = c(-Inf, Inf))#replace the channel that corresponds to your cd3 marker
  return (g)
}
#register it as the plugin gating method
registerPlugins(dummy_func, "cd3gate")
alias pop parent dims gating_method gating_args
cd3- + singlets CD3 cd3gate  
gfinak commented 6 years ago

@mikejiang can we find a way to handle this within the standard openCyto gating routines?

mikejiang commented 6 years ago

There is an existing dummy gate mechanism automatically kicks in when the data has less events than openCyto.options[["gating"]][["minEvents"]] threshold. But it was for the outlier low-event sample to grow the same leaf branches(othewise will be missing) as others.

For this case, we will have to register and explicitly filled out the dummy gate entry in csv (by user).

feltzmc commented 6 years ago

I apologize for taking so long to come back to this ticket, thank you for the help Mike and Greg. I still haven't quite gotten this to work correctly but I think Mike's answer should be sufficient for most users. If I come up with another solution I will let you know, but for now I will just close the ticket.

Thanks again, Matt