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

convert an existing gating Hierarchy to the csv gating template #67

Closed mikejiang closed 3 years ago

mikejiang commented 10 years ago

To ease the process of writing csv template to replicate the manual gating schemes, we can generate a csv gating template with the alias,pop,parent and dims parsed from xml, and leaving the gating methods columns blank for user to complete.

mikejiang commented 10 years ago

Here is the current output from templateGen, apparently, some quadGates (e.g. Q1 - Q4) need to be merged.

> df <- templateGen(gh)
> df[,1:4]
                  alias                  pop
1                 Cells                Cells
2          Single Cells         Single Cells
3          Single Cells         Single Cells
4          Granulocytes         Granulocytes
5                  CD45                 CD45
6      Q4: CD19- , IgD-     Q4: CD19- , IgD-
7      Q3: CD19+ , IgD-     Q3: CD19+ , IgD-
8      Q2: CD19+ , IgD+     Q2: CD19+ , IgD+
9      Q1: CD19- , IgD+     Q1: CD19- , IgD+
10              B cells              B cells
11 transitional B cells transitional B cells
12     Q4: CD27- , IgD-     Q4: CD27- , IgD-
13     Q3: CD27+ , IgD-     Q3: CD27+ , IgD-
14     Q2: CD27+ , IgD+     Q2: CD27+ , IgD+
15     Q1: CD27- , IgD+     Q1: CD27- , IgD+
16    CD20, CD27 subset    CD20, CD27 subset
17         Plasmablasts         Plasmablasts
18         Plasma cells         Plasma cells
                                                            parent
1                                                             root
2                                                           /Cells
3                                              /Cells/Single Cells
4                                 /Cells/Single Cells/Single Cells
5                                 /Cells/Single Cells/Single Cells
6                            /Cells/Single Cells/Single Cells/CD45
7                            /Cells/Single Cells/Single Cells/CD45
8                            /Cells/Single Cells/Single Cells/CD45
9                            /Cells/Single Cells/Single Cells/CD45
10                           /Cells/Single Cells/Single Cells/CD45
11                   /Cells/Single Cells/Single Cells/CD45/B cells
12                   /Cells/Single Cells/Single Cells/CD45/B cells
13                   /Cells/Single Cells/Single Cells/CD45/B cells
14                   /Cells/Single Cells/Single Cells/CD45/B cells
15                   /Cells/Single Cells/Single Cells/CD45/B cells
16                   /Cells/Single Cells/Single Cells/CD45/B cells
17 /Cells/Single Cells/Single Cells/CD45/B cells/CD20, CD27 subset
18 /Cells/Single Cells/Single Cells/CD45/B cells/CD20, CD27 subset
                                         dims
1                                 FSC-A,SSC-A
2                                 FSC-H,FSC-A
3                                 SSC-H,SSC-A
4                         Comp-AmCyan-A,SSC-A
5                         Comp-AmCyan-A,SSC-A
6             Comp-PE-Tx-Red-YG-A,Comp-FITC-A
7             Comp-PE-Tx-Red-YG-A,Comp-FITC-A
8             Comp-PE-Tx-Red-YG-A,Comp-FITC-A
9             Comp-PE-Tx-Red-YG-A,Comp-FITC-A
10 Comp-PE-Tx-Red-YG-A,Comp-Alexa Fluor 700-A
11                    Comp-PE-A,Comp-PE-Cy7-A
12                 Comp-APC-Cy7-A,Comp-FITC-A
13                 Comp-APC-Cy7-A,Comp-FITC-A
14                 Comp-APC-Cy7-A,Comp-FITC-A
15                 Comp-APC-Cy7-A,Comp-FITC-A
16               Comp-PE-Cy5-A,Comp-APC-Cy7-A
17                   Comp-APC-A,Comp-PE-Cy7-A
18                   Comp-APC-A,Comp-PE-Cy7-A
mikejiang commented 10 years ago

Users also need to be aware and take care of the prefixed (Comp-) channel name since we normally don't change the original channel name in the workflow of openCyto.

mikejiang commented 9 years ago

As discussed at yesterday's meeting, when translating a manual rectangleGate into appropriate 1d gating method, besides comparing the geometric boundary of the gate to the data range, we will also look at the 1d kernel density to determine whether mindensity or tailgate should be applied.

For now, I am only looking at one sample, once we have a working prototype, it can be extended to use multiple samples as @gfinak suggested.

anaraserikbek commented 8 years ago

Hello, thanks for the useful information. Is it possible to extract not only the 4 column information, but also the gating_method, groupBy, CollapseDataForGating § preprocessing columns from the existing gating template? Would you not recommend getting other such parameters and instead fill them in manually in the excel sheet? If so, is there any full/comprehensive list of gating methods and preprocessing methods. There are examples, but even the openCyto package vignette § description doesn't contain detailed explanation on different gating methods to decide which one to use in each step. Thank you

mikejiang commented 8 years ago

We can't get those columns from GatingSet because they are simply not stored in GatingSet.

Any gating methods can be used as the plugin of the openCyto as long as it conforms to the conventions. But It is actually a good idea to have a separate vignette to list all gating methods naively supported by openCyto.

anaraserikbek commented 8 years ago

Thank you Mike. Are you suggesting for me to create a vignette to demonstrate the usages of different gating methods? I have created my own gating template, but I've been received an _Error in UseMethod ("alias"): no applicable method for 'alias' applied to an object of class "gtPopulation". _ i have created a gating template similar to the openCyto's "how to create an automated gating". What could this error be caused by ? The real issue is that the same error occurs even when I utilize the ready gates in the openCyto package's extdata/gating_template folder.

mikejiang commented 8 years ago

No. We will be writing such vignette. And the error of alias is also known issue, which has to do with the method masking due to the same S4 generic was defined in other packages. I will try to reproduce and fix it.

anaraserikbek commented 8 years ago

Hi Mike, thanks once more. I'm relatively new to R & FCM data analysis & I'm writing a pipeline for a data set of clinical immunology trial of our lab. I have the following questions (I'm not sure if I need to create a threat for each of these questions separately?) If the questions are too many, or, if it'd be easier to answer them by phone, I am located in Paris (Institut Curie, U932 Flow Cytometry), let me know your availability & I'll call.

Q1: As I understood, the method masking error that I've got before was due to the fact that 'alias' method was present no only in this, but in other packages; and, so with the code you provided, you converted it into a private function of this package? [I've read about S4 classes & masking, but still seem to be confused]. Along with this, since the research personal in our lab will be using this pipeline in the future, would they always need to solve this masking issue in R while analyzing a new new .FCS data set? Is there a way to make it incorporated into openCyto package (when you already download the package. so that they don't have to write code...)?

Q2: What is the purpose of the 4th file "man/alias-gtPopulation-method.Rd" -% Please edit documentation in R/gtPopulation-methods.R ...

Q3: for the automated-gating scheme, the gating_methods vignette will be very useful. When do you think we should be expecting the vignette for this?

Q4: For using a manual-gating-template from FlowJo, it seems that for every .fcs file of the FlowSet, we need to read/open its corresponding Workspace from R as a gating template. Or is there a way to use one Workspace gating template with its parameters to apply for all the FlowSet .fcs files? (does the FlowJo workspace gating-template already contain the information about the .fcs file that it's supposed to be applied to? Since, i've tried to apply a gating template of, for example,"1.fcs" to "2.fcs" & it does not work.)

Q5: which gating method (automated vs. incorporated from flowJo) could be more beneficial in analyzing clinical data (small subset 70-80 patients, 4 times points, 19 markers)? (In automated gating template, how risky is it to use the gating_methods with set parameters in analyzing a big flowSet)

mikejiang commented 8 years ago
  1. alias problem is already fixed.
  2. This file no longer exists after the fix
  3. Probably next week
  4. Not implemented yet If you are talking about this
  5. Try to create a separate issue and elaborate more
anaraserikbek commented 8 years ago

Okay, great. We appreciate your help. How can I sign up to get a notification when the gating_method vignettte will be available? or should i just keep checking on openCyto website? (regarding Q4): yes, I was talking about that process. But does that mean that for each .FCS file of each patient to work with flowJo-template, we need to manually analyze on flowJo and then use that template in R to reproduce the gating on R? Does that mean that the gating_method/information is already incorporated in these flowJo workspace files? Then, would it be possible to extract not only the alias,pop,parent,dims information, but also the gating method and processing parameters?

mikejiang commented 8 years ago

If you watch this issue https://github.com/RGLab/openCyto/issues/107 and then you will be notified once it is closed. I still don't understand your question regarding to Q4 and it sounds irrelevant to this thread. Can you open a new issue and give a concrete example to illustrate what you aim for?