Closed browshanravan closed 4 years ago
The builtin flowClust.2d
in openCyto package is designed for returning only one gate/population as you've already noticed.
To return multiple gates from one gating function, you will need to wrap the flowClust into your plugin function. Here is one example https://rpubs.com/wjiang2/194332 that demonstrates this Be aware that it is just proof-of-concept code written years ago, (e.g. tmix2DGate has been moved to https://github.com/RGLab/cytoUtils/blob/master/R/tmix2DGate.R) try get the principle and tweak into your own needs.
Everything works! great! thank you! I was hoping to ask two short questions which are unrelated. Should I open a new issue?
Having used your custom scripts linked above, I have successfully identified my 2 populations of interest, as shown below.
I have achieved this by running the below script.
thisData<- gs_pop_get_data(gs, "parent_pop")
DD_gate<- fsApply(thisData, function(fr) tmix2DGate(fr, channels = c("chnl1", "chnl2"), K=2, quantile=0.95))
gs_pop_add(gs, DD_gate, parent = "parent_pop", name = c("gate1","gate2"))
autoplot(gs, c("gate1","gate2"))
recompute(gs)
However, I have recently realised when I select one of the gates for plotting using autoplot(gs, "gate1")
, the gates seem to be assigned randomly throughout my data, as shown below.
Given the arrangement of my clusters, I though of using the target = c(0,0)
argument in order to constrain one of the gates, say gate1
, on the x and y axis to consistently recognise the population/cluster closest to the origin but I was not been successful. Do you have any suggestions as to what I can do?
Hi, @browshanravan sorry your issue seems to have been missed. I'd like to dig into this, can you share a little bit of the data with code to reproduce this? Thanks
I don't think target
parameter works for tmix2DGate
, you will need to switch back to flowClust.2d
to gate one population at a time.
For now, I will close it with https://rpubs.com/wjiang2/176974, which illustrates the usage of target
with flowClust.2d
.
Feel free to reopen it if you feel the issue is not fully resolved.
My understanding is that
openCyto:::.flowClust.2d
function recognises K user defined clusters (as visualised by the argumentplot=TRUE
) however it only gates on the one with the most cell count if thetarget
argument is not defined.Is there a way to gate on more than 1 population, say 2, and have them added to the gate path as
myGateName_Gate1
andmyGateName_Gate2
?