RGLab / openCyto

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

Better documentation for preprocessing methods #220

Closed wjs20 closed 3 years ago

wjs20 commented 3 years ago

Hi openCyto team!

Really enjoying the package. I'm a bit confused about how to fill in the pre-processing column in my gating template csv for a tailgate. In your vignette you add the standardize_flowset argument, but I cannot find any explanation in the vignette or documentation about what it is used for or how it works. It would be helpful if you could provide some explanations of how this and other preprocessing methods work somewhere in your documentation.

Thankyou

mikejiang commented 3 years ago

let's use standardize_flowset as the example, and heere is the formal of the preprocessing function,

.standardize_flowset <- function(fs, gs, gm, channels, groupBy, isCollapse, ...)

The return value of preprocessing can be anything, it is passed on to the gating function as pp_res argument, e.g.

.gate_tail <- function(fr, pp_res = NULL, channels, ...) 

as shown, gating function receives the data from fr argument , which is a flowFrame (or cytoframe) and it typically represents the parent data from a single sample. unless both groupBy and collapseDataForGating columns are set, e.g. collapseDataForGating = TRUE and groupBy = 'patient ID', then the parent data from a sub-group of samples(from the same patent ID) is collapsed(or merged) into a cytoframe and passed to the gating function.

Again, optional pp_res argument can take the preprcoessing result to guide the gating process.

Coming back to standardize_flowset this specific function, it basically takes the parent data from all samples or a sub-group of samples, and standardizes/rescale the given channel of each sample using the mode of the kernel density estimate and the Huber estimator of the standard deviation. And the standardized data is returned and will be passed as pp_res to gating function, which will be using pp_res instead of fr argument for the actual gating

Here is one example of using preprocessing mechanism to achieve the negative control based gating https://rpubs.com/wjiang2/473129