Complex filters in flowCore and ggcyto
1
0
Entering edit mode
jaera • 0
@jaera-12317
Last seen 4.5 years ago

I have noticed that gates defined using transformations (via the %on% operator) and boolean operations (!, &, |, %&%) are not supported by flowCore's GatingSet and by ggcyto. E.g.

library(flowCore)
library(ggcyto)

fcsSet <- read.flowSet(path=system.file("extdata", "compdata", "data", package="flowCore"))

myTransform <- transform("FSC-H" = log, "SSC-H" = log)
mat <- matrix(c(500, 400, 400, 600, 650, 650,
                500, 600, 750, 750, 600, 500), nrow = 6)
colnames(mat) <- c("FSC-H", "SSC-H")
myGate <- polygonGate(log(mat)) %on% myTransform

# Subset is happy:
nrow(Subset(fcsSet[[1]], myGate))
# [1] 10

gateSet <- GatingSet(fcsSet)
add(gateSet, myGate)
# replicating filter 'defaultPolygonGate on transformed values of FSC-H,SSC-H' across samples!
# Error in (function (classes, fdef, mtable)  :
#  unable to find an inherited method for function ‘filterObject’ for signature ‘"transformFilter"’

# not run:
# recompute(gateSet)
# autoplot(gateSet, "defaultPolygonGate")

recompute(gateSet)
autoplot(fcsSet[[1]], "FSC-H", "SSC-H") + geom_gate(myGate)
# Error: ggcyto doesn't know how to deal with gate of class transformFilter

 

Am I missing something here or is there an alternative workflow? (In the example above, one could perhaps transform the parameters first and then do the gating, but this approach wouldn't help if different transformations are used by different gates or in cases of combinatorial gates).

flowCore ggcyto • 1.9k views
ADD COMMENT
0
Entering edit mode
Jiang, Mike ★ 1.3k
@jiang-mike-4886
Last seen 3.2 years ago
(Private Address)

You are right, "transformFilter" is not supported here. We suppose different flow parameters/channels can have different transformations but for each flow parameter the transformation is the fixed in the context of your particular analysis. I don't see the compelling reason to transform the same parameter (e.g. FSC-H in this example) differently in your different gates.

ADD COMMENT
0
Entering edit mode

May be, transformFilter was the wrong choice in my example, because it might indeed be a rare case to have the need to apply different transforms on the same parameter for different gates, but I see no workaround for unionFilter, intersectFilter, subsetFilter or complementFilter.

ADD REPLY
0
Entering edit mode

A practical case for transformFilter: gates were first defined in logicle-axes in, say, FACSDiva, but now we want to have them in log.

ADD REPLY
0
Entering edit mode

These filters can be represented as "booleanFilter" (equivalent to flowJo's Boolean Gate). Why would you want to change logicle to log scale?

ADD REPLY

Login before adding your answer.

Traffic: 729 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6