Hello,
I am using flowWorkspace to import some flow cytometry data I gated with FlowJo into R:
flowjo_to_gatingset(ws, name= "All Samples", execute = TRUE)
Then I tried to use ggcyto to get a histogram of DAPI channel:
ggcyto(gh[2], aes(x = `DAPI-A`), subset = "Lymphocytes") + geom_density(aes(y = ..count..),fill = "Blue", alpha = 0.2)
As you can see, the values on x-axis are not correct. So next I tried scaling the axis:
ggcyto(gh[2], aes(x = `DAPI-A`), subset = "Lymphocytes") + geom_density(aes(y = ..count..),fill = "Blue", alpha = 0.2) + scale_x_flowjo_biexp(maxValue = 262144, widthBasis = -1000, pos = 4.2, neg = 0)
At this point I was wondering whether somehow the data got messed up during import. so next I tried using autoplot:
autoplot(gh[2], gate = "Lymphocytes", bins = 128)
Using autoplot the values for DAPI channel are depicted correctly. I have done a lot of reading the vignettes for ggcyto and flowWorkspace and googleing but I just can't figure it out. It seems like the transformation of the values for DAPI channel simply isn't correct. I tried manually at first but it gave me the exact same results as you can see in the above histograms. Then I tried using the "execute = TRUE" option with the flowjotogatingset. But it still doesn't work properly as you can see.
Can anyone tell me what I am doing wrong?
Thanks a lot!
Kevin is correct.
axis_x_inverse_trans
will still display the transformed density, but use the pre-transformation values for the axis tick labels, which I believe is what you want.Thanks a lot! That actually did the trick.
I read up on the function at it makes sense. What I still don't understand is when I would use
+ scale_x_flowjo_biexp()
You can use
scale_x_flowjo_biexp
when you want to apply a transformation to the density just for plotting (when the biexponential transformation is not already present), without it being applied to the underlying data. The idea is the same as forggplot2::scale_x_continuous
(whichscale_x_flowjo_biexp
calls after building the biexponential transform).