ggcyto wrong axis scale?
1
1
Entering edit mode
@andrejstollde-23490
Last seen 2.5 years ago

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!

ggcyto flowWorkspace flow cytometry flowjo • 671 views
2
Entering edit mode
@kevin
Last seen 3 hours ago
Republic of Ireland

I could be incorrect but I think that you need:

ggcyto(gh[2], aes(x = DAPI-A), subset = 'Lymphocytes') +
geom_density(aes(y = ..count..), fill = 'Blue', alpha = 0.2) +
axis_x_inverse_trans()


Let me know if that works.

Kevin

2
Entering edit mode

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.

0
Entering edit mode

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()

0
Entering edit mode

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 for ggplot2::scale_x_continuous (which scale_x_flowjo_biexp calls after building the biexponential transform).

Traffic: 451 users visited in the last hour
FAQ
API
Stats

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