In flowCore, a flowSet is associated with an AnnotatedDataFrame that contains ancillary information about the frame. This seems really useful, but it's really only used by the flowViz package---there really isn't anything remotely resembling a useful interactive idiom. Now, we could use subset(), assuming we could ever get the generic working properly, but we already have Subset in flowCore and the opportunity for confusion is high. One idea that has occurred to me is to take advantage of the ellipsis argument in [ and [[ to let us say things like
patient[[CellType="B Cells"]]
to extract the flowFrame identified by the CellType column.
Showing posts with label flowCore. Show all posts
Showing posts with label flowCore. Show all posts
Thursday, June 28, 2007
Friday, May 25, 2007
Interactive Gating with flowCore
One of the biggest hurdles for flowCore adoption is probably the lack of interactive gating. People really like it and it can be useful even to us statistician types that are suspicious of the entire exercise. R and flowCore, unfortunately, aren't particularly good at interactive graphics so this presents something of a problem.
To help with this, here's a quick function for getting a 2D polygon gate with an optional transform:
The fcs parameter is a flowFrame and the x and y arguments should be pretty obvious. The trans argument can be one of three things: NULL, a function, or a transform object. If it is a transform object (created by transform(...)) then it is simply applied. If it's a function, a transform will be created for both parameters and also applied to the subsequent gate.
e.g.
Just a little thing, but pretty useful.
To help with this, here's a quick function for getting a 2D polygon gate with an optional transform:
interactiveGate = function(fcs,x,y,filterId="Picked", trans=NULL,...) {
if(is.function(trans)) {
tnf = structure(list(trans,trans),names=c(x,y))
trans = do.call("transform",tnf)
}
plot(exprs(if(is.null(trans)) fcs else trans %on% fcs)[,c(x,y)],
pch=20,cex=.5,main=filterId,...)
points = locator(type="n")
polygon(points)
points = cbind(points$x,points$y)
colnames(points) = c(x,y)
r = polygonGate(filterId,points)
if(is.null(trans)) r else r %on% trans
}
The fcs parameter is a flowFrame and the x and y arguments should be pretty obvious. The trans argument can be one of three things: NULL, a function, or a transform object. If it is a transform object (created by transform(...)) then it is simply applied. If it's a function, a transform will be created for both parameters and also applied to the subsequent gate.
e.g.
interactiveGate(fcs,"APC-Cy7-A","PacOrange-565-A","Control",function(x) asinh(x/32))
Just a little thing, but pretty useful.
Subscribe to:
Posts (Atom)