RGLab / openCyto

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

clustering region between two peak area in flow cytometry data #101

Closed kdh4win4 closed 6 years ago

kdh4win4 commented 8 years ago

I would like to sort middle area between two peak area(bright and dark). In below manual gating plot; CD56 bright and CD16 dim region. (8%) How can I sort that using template(csv) file? I could not find any good way to sort this region yet. Rplot03.pdf

gfinak commented 8 years ago

I'd suggest to come up with a data driven strategy using the basic components of 1d or 2d mixture models (flowClust) and/or density based gating and even ( if necessary) , fixed thresholds to define the region of interest computationally, then wrap that strategy in a custom gating routine that you plug in to openCyto, so you have a custom gate, that's data driven, and returns the gate for a given sample. Best,

Greg On Dec 22, 2015 3:41 PM, "kdh4win4" notifications@github.com wrote:

I would like to sort middle area between two peak area(bright and dark) In below manual gating plot; CD56 bright and CD16 dim region (8%) How can I sort that using template(csv) file? I could not find any good way to sort this region yet Rplot03pdf https://githubcom/RGLab/openCyto/files/70171/Rplot03pdf

— Reply to this email directly or view it on GitHub https://github.com/RGLab/openCyto/issues/101.

kdh4win4 commented 8 years ago

Do you mean that I need to use manual gating strategy a bit ? I have tried to use that strategy, however, I couldn't. Could you give me a hint how to "wrap the strategy in a custom gating routine that I previously plugged in to openCyto" Mr. Finak ?

gfinak commented 8 years ago

Please have a look at the documentation for writing plugin gating routines for openCyto. There are examples online from the BioConductor seminars last year as well as on openCyto.org and on guthub.com/gfinak . In a nutshell, you'll write a function that receives a flowFrame, it would then extract the two markers you're interested in, you'd gate it in 1d or 2d to identify peaks, valleys, or clusters of cells and orient yourself relative to those features, and use their locations to define the boundaries of your region of interest, and return a gate object for that sample. That function gets registered with openCyto using the registerPlugins API, so it can be used in the template.

Greg Finak On Dec 22, 2015 4:28 PM, "kdh4win4" notifications@github.com wrote:

Do you mean that I need to use manual gating strategy a bit ? I have tried to use that strategy, however, I couldn't. Could you give me a hint how to "wrap the strategy in a custom gating routine that I previously plugged in to openCyto" Mr. Finak ?

— Reply to this email directly or view it on GitHub https://github.com/RGLab/openCyto/issues/101#issuecomment-166734300.

gfinak commented 8 years ago

Thanks, this is helpful to make it more concrete. I'll have a look when I get a few minutes and see if I can come up with some suggestions.

Greg Finak On Dec 22, 2015 5:05 PM, "kdh4win4" notifications@github.com wrote:

I have read it and tried it during last two weeks. The goal is to catch the CD56 bright and CD16 dim

Some results I got so far are below. the template is; alias.docx https://github.com/RGLab/openCyto/files/70260/alias.docx

the previous manual gating is ; Rplot04_1.pdf https://github.com/RGLab/openCyto/files/70261/Rplot04_1.pdf

the autogating result with the template is; Rplot04_auto_1.pdf https://github.com/RGLab/openCyto/files/70263/Rplot04_auto_1.pdf

Any comment on my template is truly welcomed !. Thank you for your time. Mr. Finak

— Reply to this email directly or view it on GitHub https://github.com/RGLab/openCyto/issues/101#issuecomment-166742625.

kdh4win4 commented 8 years ago

Thank you. Mr. Finak

kdh4win4 commented 8 years ago

Can I have any suggestion ?

gfinak commented 8 years ago

You could write a custom gating plugin that gates the CD16 and CD56 dimensions, and then condition on different subsets to identify precisely where to cut in order to draw that gate around the 8% population. For example after identifying CD56+ and CD56- using mindensity, you would further process the data within the gating routine to apply a tailgate to the right side of the CD56+ population, that should get you the left boundary, then you could process the CD56- subset and apply a tailgate to the left side of CD56- cells to get the right boundary. For the upper and lower boundaries, you could look at the CD56+/CD16+ cells and find the mode, then take the mode+/- 2 or 3 sds of the population to get the upper and lower boundary. Then construct a gate from those four sets of coordinates.

This would be a pretty special-purpose and specific gating routine, but depending on how your data looks (if there isn't massive variability from sample to sample, for examples populations disappearing) then it might be sufficient.

SamGG commented 8 years ago

Thanks Greg for this nice tip. I am wondering if the right and left boundaries should apply to CD16 instead of CD56.

kdh4win4 commented 8 years ago

Thank you so much, Mr. Greg Finak

Sincerely, Dohoon Kim

      1. 오후 4:43 Greg Finak notifications@github.com 작성:

You could write a custom gating plugin that gates the CD16 and CD56 dimensions, and then condition on different subsets to identify precisely where to cut in order to draw that gate around the 8% population. For example after identifying CD56+ and CD56- using mindensity, you would further process the data within the gating routine to apply a tailgate to the right side of the CD56+ population, that should get you the left boundary, then you could process the CD56- subset and apply a tailgate to the left side of CD56- cells to get the right boundary. For the upper and lower boundaries, you could look at the CD56+/CD16+ cells and find the mode, then take the mode+/- 2 or 3 sds of the population to get the upper and lower boundary. Then construct a gate from those four sets of coordinates.

This would be a pretty special-purpose and specific gating routine, but depending on how your data looks (if there isn't massive variability from sample to sample, for examples populations disappearing) then it might be sufficient.

— Reply to this email directly or view it on GitHub.

SamGG commented 8 years ago

Greg and Mike helped me solving a related question #102

kdh4win4 commented 8 years ago

How do I set +/- 2 or 3 sd ? I am afraid to say that I cound not find that in opencyto vignette.

gfinak commented 8 years ago

Can you clarify your question?

kdh4win4 commented 8 years ago

Rplot07_github.pdf Hi, Dr. Finak In the 5th figure, CD3-(parent), the 8% area is in "CD56positive & CD16dim" region . The target region is located in between CD16+ and CD16- area. After getting CD56+ region by mindensity method(I have done this), however, how to tailgating for CD16dim region is not that much clear to me.

gfinak commented 8 years ago

As I said before you will have to write a custom gating routine for this. You cannot do this through the openCyto template directly without writing a gating plugin. There is no gating routine in openCyto that lets you say "threshold 2 SDs below the peak". You need to write this code.

kdh4win4 commented 8 years ago

where can I get that information ?

gfinak commented 8 years ago

A very basic example is here: https://rstudio-pubs-static.s3.amazonaws.com/65921_14da9c6acdfd4966b43f8e02e8d67b94.html

You need to write a wrapper around your custom routine. The wrapper has to match the expected function signature (see the example in the link above). The output would be a gate. The routine would munge and process the data as needed to identify all the relevant cutpoints. In the example above, it's just using simple tailgate applied to a control sample that then gets used to gate non-control samples. For your use case, you replace the tailgate in the wrapper with your own routine.

Edit: you probably don't need to worry about any custom preprocessing.

kdh4win4 commented 8 years ago

Dear Greg I will do that right now. I appreciate it.