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

Selecting specific cell populations #208

Closed IvanaOsredek closed 3 years ago

IvanaOsredek commented 4 years ago

Hello,

My data set includes cells transfected with a vector carrying GFP and tdTomato, together and respectively. Cells were measured by flow cytometry and the goal is to see if any of the markers overtake the other one in copy number over 2 weeks.

Before switching to another package (probably FlowSpy) I would do reproduce FlowJo gating in OpenCyto and then extract all cell except doublets and dead cells into new fcs file. Could you please advise me what would be the best way of doing this?

I was thinking to use those commands:

alive_gate <- gh_pop_get_data(gs[[2]], "Alive") fr_alive <- as(alive_gate, "flowFrame")

And then save it as a new fcs file.

Thank you:)

Regards

mikejiang commented 4 years ago

You may already have done this, follow openCyto vignette to load the original FCS files into GatingSet and do the compensation and transformation properly. Then use gs_add_gating_method() to incrementally add your gates. Without much information of your data, I am just giving the possible workflow, In your case, first use the builtin singletGate method to remove doublets, e.g.

gs_add_gating_method(gs, "singlet", parent = "root", dims = "FSC-A,FSC-H", gating_method = "singletGate")

then, possible define 1d gate on the live/dead marker to remove dead cells

gs_add_gating_method(gs, "Alive", pop = "-",  parent = "singlet", dims = "live/dead", gating_method = "mindensity")

Once the gating is done, you can grab the entire dataset (similar to your code) and write them to fcs files

fs <- gs_pop_get_data(gs, "Alive")
write.flowSet(fs, path)

Note that We are currently still working on writing to FCS for development branch (https://github.com/RGLab/flowWorkspace/issues/308). But if you are using release version, you are good to go.

IvanaOsredek commented 4 years ago

Hello,

Thank you very much for your help! So you're suggesting that the best way would be to do automated gating? I will proceed with that.

My gates are as follows: root/J76/Single cells/Alive cells and from there I gate for GFP-/tdTomato +, GFP+/tdTomato-, GFP+/tdTomato+ and GFP-/tdTomato-.
In the trajectory, I was thinking to use double-positive cells as the root and others as leaves. So when I extract "Alive" cells gate, are automatically all other gates from the gate "Alive" extracted as well? Or I extract only the Alive gate and those for GFP and tdTomato get lost?

Kind regards

mikejiang commented 4 years ago

reproduce FlowJo gating in OpenCyto

By that, I thought you were talking about autogating since openCyto package is specifically for that purpose.

you're suggesting that the best way would be to do automated gating?

No, you don't have to. If you already did the gating in FlowJo and want to simply import it into R, You can use CytoML , namely flowjo_to_gatingset function . Please look at its vignette and manual (of both flowWorkspace and CytoML) before proceeding. Once you parsed flowJo workspace (i.e. wsp file) into a GatingSet , you can extract the gated populations and re-save them into FCS as described above.