FAQ  •  Register  •  Login

Auto-gating Gaussian and/or cells?

Forum rules
Please be as geeky as possible. Reference, reference, reference.
Also, please note that this is a mixed bag of math-gurus and mathematically challenged, so choose your words wisely :-)
<<

jimbomahoney

Master

Posts: 73

Joined: Wed Feb 27, 2019 11:21 am

Post Tue Dec 03, 2019 12:11 pm

Auto-gating Gaussian and/or cells?

Hi all,

Is there any appetite for a script that auto-gates CyTOF data using the Gaussian parameters and/or beads?

Because I like doing this sort of thing, I wrote one anyway...

UPDATE - now exists as an R package - https://github.com/JimboMahoney/cytofclean

It outputs plots to show the gates used and the %events remaining and then writes new FCS files containing only the events of interest.

Each row is a gate (Event -> Centre -> Offset -> Residual -> Cells) and each column is a file.

Image

Of course, as with any automated task, there is a risk of it going wrong, but at least with this script, it shows you how it's gated the events and also outputs NEW files, rather than overwriting the originals.

And of course, this is WAY faster than doing it manually...
Last edited by jimbomahoney on Wed Dec 04, 2019 8:17 pm, edited 1 time in total.
<<

jimbomahoney

Master

Posts: 73

Joined: Wed Feb 27, 2019 11:21 am

Post Tue Dec 03, 2019 3:47 pm

Re: Auto-gating Gaussian and/or cells?

OK, pretty pleased with how this is working across a variety of "nice" and "dirty" datasets.

The following 800 MB FCS file, with 1 million events took 13 seconds to auto-gate:

Image
<<

jimbomahoney

Master

Posts: 73

Joined: Wed Feb 27, 2019 11:21 am

Post Tue Dec 03, 2019 6:13 pm

Re: Auto-gating Gaussian and/or cells?

I just realised another advantage with this method is that the size of the resulting fcs files are ~25% of the originals due to the coincident removal of the "super-secret" Fluidigm data.

This means uploading to Cytobank for further gating etc. will be faster and take up less space!

:D
<<

jimbomahoney

Master

Posts: 73

Joined: Wed Feb 27, 2019 11:21 am

Post Wed Dec 04, 2019 8:16 pm

Re: Auto-gating Gaussian and/or cells?

Released as an R package:

https://github.com/JimboMahoney/cytofclean

Feedback welcome!
<<

dtelad11

Master

Posts: 107

Joined: Mon Oct 31, 2016 6:26 pm

Post Thu Dec 05, 2019 3:49 pm

Re: Auto-gating Gaussian and/or cells?

Thanks for sharing! Could you please elaborate on the algorithm you use the find the peaks?

Also, it might be beneficial to cite these under the "Gaussian parameters" section:

https://link.springer.com/protocol/10.1 ... 9-9454-0_2
https://onlinelibrary.wiley.com/doi/abs ... to.b.21858
<<

jimbomahoney

Master

Posts: 73

Joined: Wed Feb 27, 2019 11:21 am

Post Thu Dec 05, 2019 6:32 pm

Re: Auto-gating Gaussian and/or cells?

Hi El-ad,

If I tell you my super-secret methods, you and others will implement them in your commercial platforms! :D

(joking of course!)

Well, I'm not a maths genius and I'm also new to coding, so my method is very much a trial-and-error-until-it-works-on-a-bunch-of-good-and-bad-datasets kinda method...

In general, I find the largest peak in the histogram (the point at which the derivative is zero). Due to the "spikes" in the histogram, I apply a smoothing function. I guess this could be considered the mode?

I also look at the median and SD of the histogram.

I then set the min and max of the "gates" to be a multiple of the SD around the mode.

I use the difference between the median and mode to give an idea of the "skew" of the data and shift the min/max accordingly. I've had to tweak each setting (Event, Centre, Offset, Residual) individually, so each has a slightly different "weighting". Like I said - lots of trial-and-error.

For the Beads, I simply set a hard cut-off at 10^2 - anything above is considered a bead and removed.

On all the datasets I have available, this all seems to work well, but it would need more real-world data / testing to know for sure. Hence my "disclaimer" of this initial release being a beta...

It's almost certainly not as "good" at manually gating, but it's (probably) good enough and a LOT faster.

EDIT - Thanks for the links. I'll take a look at them when I'm back at work, as I don't have full access from home.
<<

dtelad11

Master

Posts: 107

Joined: Mon Oct 31, 2016 6:26 pm

Post Sat Dec 07, 2019 12:47 am

Re: Auto-gating Gaussian and/or cells?

jimbomahoney wrote:If I tell you my super-secret methods, you and others will implement them in your commercial platforms! :D

(joking of course!)

Actually, you reminded me of a real concern: Your code doesn't have any license attached to it. I doubt this will matter for the average grad student, but some organizations (such as core facilities or companies) will avoid using it due to legal issues. You might want to look into available licenses and pick one that make sense.

jimbomahoney wrote:In general, I find the largest peak in the histogram (the point at which the derivative is zero). Due to the "spikes" in the histogram, I apply a smoothing function. I guess this could be considered the mode?

If you're smoothing a histogram then I suspect that you actually want a density. Check out the R density function, it might better reflect what you're trying to achieve.

jimbomahoney wrote:I use the difference between the median and mode to give an idea of the "skew" of the data and shift the min/max accordingly. I've had to tweak each setting (Event, Centre, Offset, Residual) individually, so each has a slightly different "weighting". Like I said - lots of trial-and-error.

That makes sense. I wonder whether there's some common reasoning/equation that you could use in lieu of your manual tweaking, now that you have a better idea of how the data behaves.

jimbomahoney wrote:For the Beads, I simply set a hard cut-off at 10^2 - anything above is considered a bead and removed.

Is that only on Ce140Di, or other bead channels as well?

What if the file does not have Ce140Di?
<<

jimbomahoney

Master

Posts: 73

Joined: Wed Feb 27, 2019 11:21 am

Post Sat Dec 07, 2019 10:00 am

Re: Auto-gating Gaussian and/or cells?

Hi El-ad,

Thanks - I don't know much about licence options, so I did a quick search and the suggestion was to simply use the MIT, so I've attached that to the GitHub repository.

Re: Density - thanks - I think I've used that function for some of my plots, and it's probably used in these ones too. I'll give it a go in terms of processing.

Re: Beads - Only 140. I thought the Ce140 was always present? Does anyone every run without EQ beads? Certainly for CyTOF normalisation, the 140, 151, 153, 165 and 175 are required. I believe the Finck method is less fussy.
<<

jimbomahoney

Master

Posts: 73

Joined: Wed Feb 27, 2019 11:21 am

Post Sat Dec 07, 2019 11:04 am

Re: Auto-gating Gaussian and/or cells?

OK, that's changed the package to use density instead of the (messy!) histogram smoothing / stats functions I was using before.

Thanks so much for that advice - it works a LOT better!
<<

dtelad11

Master

Posts: 107

Joined: Mon Oct 31, 2016 6:26 pm

Post Sat Dec 07, 2019 2:47 pm

Re: Auto-gating Gaussian and/or cells?

Glad to hear density helped! And thanks for the license.

jimbomahoney wrote:Re: Beads - Only 140. I thought the Ce140 was always present? Does anyone every run without EQ beads? Certainly for CyTOF normalisation, the 140, 151, 153, 165 and 175 are required. I believe the Finck method is less fussy.


You would think, but I've seen all sorts of weird stuff over the years. Including cases where the operator forgot to acquire Ce140, or that Ce140 was removed via pre-processing (along with a bunch of other channels) to "make the file smaller".
Next

Return to CyTOF data analysis

Who is online

Users browsing this forum: No registered users and 1 guest

cron