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

filter out a gating set and convert it in a Flowset #255

Open feanaros opened 3 weeks ago

feanaros commented 3 weeks ago

Hello I want to filter my flowSet object keeping only CD45+ Live cells. I have a gating set derived from a flowset of 16 samples.

 gs
A GatingSet with 16 samples
fcs_pro
A flowSet with 16 experiments.
column names(76): Time Event_length ... Pb208Di Bi209Di

I applied this kind of filtering but I think it filters too much:

fcs_pro <- read.flowSet(files, transformation = T, truncate_max_range = F)
gs= GatingSet(fcs_pro)
gs_add_gating_method(gs, "Alive", pop = "+",  parent = "root", dims = "Rh103Di", gating_method = "mindensity")
gs_add_gating_method(gs, "cd45", pop = "+",  parent = "root", dims = "Y89Di", gating_method = "mindensity" )
fs <- gs_pop_get_data(gs, c("cd45"))
write.flowSet(fs, path)

I want to do a gating based on this parameters but I don't know how to apply it on all the elements of the GatingSet obtaining a subset of cells and convert it in a FlowSet:

gs= GatingSet(fcs_pro)
fr <- gh_pop_get_data(gs, "root", returnType = "flowFrame", inverse.transform = F)
chnl <- c("Rh103Di","Y89Di")
g <- openCyto:::.boundary(fr, channels = chnl, min = c(0, 0), max=c(20,400))
p <- autoplot(fr, x = chnl[1], y = chnl[2])
p + geom_gate(g)

thank you!

mikejiang commented 1 day ago

wrap your custom gating function into a plugin gating method and register it so that it can be used by opencyto::gs_add_gating_method look at example usage of registerPlugins here https://rpubs.com/wjiang2/188182 https://www.bioconductor.org/help/course-materials/2014/BioC2014/OpenCytoPracticalComponent.html