Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scale_y_flowCore_fasinh does not work with hexagonal binning #51

Closed
jacobpwagner opened this issue Sep 9, 2019 · 5 comments
Closed
Assignees
Labels

Comments

@jacobpwagner
Copy link
Member

jacobpwagner commented Sep 9, 2019

I first discovered this while working on #50, and so I will use an simplified version of the example there. First, starting with a simple plot

library(ggcyto)
data("GvHD")
fs2 <- GvHD[subset(pData(GvHD), Patient %in% 5:7 & Visit %in% c(5:6))[["name"]]]
autoplot(fs2, "Time", "FL3-H")

With the current trunk branch, this looks like this:
trunk_plot_pre

With the Bioconductor 3.8 branch, it looks like this:
demo_plot_pre

Some differences in color scaling, but mostly the same plot.

Now, adding the arcsinh transform to the y axis using scale_y_flowCore_fasinh:

autoplot(fs2, "Time", "FL3-H") + scale_y_flowCore_fasinh(b = 1/5)

The result of this from Bioc 3.8 versions of the packages is this:
demo_plot

As expected, the transformation is performed and then the hexagonal partitioning is performed on the transformed scale. However, with the current trunk branch, we get this:
trunk_plot

It appears that something is going wrong in binning on y after the axis was rescaled. I have been doing some hunting for a commit on our end (in ggcyto, flowWorkspace, flowCore) that could have changed this behavior, but have not had any success. I have also not had any success after reverting ggplot2 before potentially relevant commits to see if it's anything on their end.

I'll keep trying to track it down and post on any progress here.

@jacobpwagner jacobpwagner changed the title scale_y_flowCore_fasinh does not work with hexagonal binning scale_y_flowCore_fasinh does not work with hexagonal binning Sep 9, 2019
@jacobpwagner
Copy link
Member Author

sessionInfo() for the Bioc 3.8 Docker container (where the plot is successful):

R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux buster/sid

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggcyto_1.10.2             flowWorkspace_3.30.2     
[3] ncdfFlow_2.28.1           BH_1.69.0-1              
[5] RcppArmadillo_0.9.700.2.0 flowCore_1.48.1          
[7] ggplot2_3.2.1            

loaded via a namespace (and not attached):
 [1] pcaPP_1.9-73        Rcpp_1.0.2          plyr_1.8.4         
 [4] RColorBrewer_1.1-2  pillar_1.4.2        compiler_3.5.2     
 [7] DEoptimR_1.0-8      BiocManager_1.30.4  zlibbioc_1.28.0    
[10] tools_3.5.2         tibble_2.1.3        gtable_0.3.0       
[13] lattice_0.20-38     pkgconfig_2.0.2     rlang_0.4.0        
[16] graph_1.60.0        Rgraphviz_2.26.0    parallel_3.5.2     
[19] mvtnorm_1.0-11      hexbin_1.27.3       gridExtra_2.3      
[22] stringr_1.4.0       withr_2.1.2         dplyr_0.8.3        
[25] cluster_2.1.0       IDPmisc_1.1.19      stats4_3.5.2       
[28] grid_3.5.2          tidyselect_0.2.5    data.table_1.12.2  
[31] glue_1.3.1          robustbase_0.93-5   Biobase_2.42.0     
[34] R6_2.4.0            rrcov_1.4-7         XML_3.98-1.20      
[37] latticeExtra_0.6-28 purrr_0.3.2         corpcor_1.6.9      
[40] magrittr_1.5        scales_1.0.0        matrixStats_0.54.0 
[43] BiocGenerics_0.28.0 MASS_7.3-51.4       assertthat_0.2.1   
[46] colorspace_1.4-1    labeling_0.3        KernSmooth_2.23-15 
[49] stringi_1.4.3       flowViz_1.46.1      lazyeval_0.2.2     
[52] munsell_0.5.0       crayon_1.3.4  

@jacobpwagner jacobpwagner self-assigned this Sep 9, 2019
@jacobpwagner
Copy link
Member Author

jacobpwagner commented Sep 9, 2019

The problem is not confined to scale_y_flowCore_fasinh, as a similar issue occurs with scale_y_flowjo_biexp.

autoplot(fs2, "Time", "FL3-H") + scale_y_flowjo_biexp()

plot_zoom_png

But curiously, it does not for scale_y_flowJo_biexp

autoplot(fs2, "Time", "FL3-H") + scale_y_flowJo_biexp()

plot_zoom_png

which is odd, as scale_y_flowJo_biexp is now just a deprecation redirect to scale_y_flowjo_biexp. It may be an issue of handling ... or default args.

@jacobpwagner
Copy link
Member Author

Nevermind. It looks like this is an issue for any scaling of the y axis, including scaling functions from `ggplot2.

autoplot(fs2, "Time", "FL3-H") + ggplot2::scale_y_log10()

plot_zoom_png

That works fine in Bioc 3.8, though.

@jacobpwagner
Copy link
Member Author

Looks like 2974b47 is the breaking commit, which makes sense based on the commit message. Working on the fix.

@jacobpwagner
Copy link
Member Author

After 0a2ed8a, it looks good:
plot_zoom_png

The explicit calculation of binwidths added by 0e576c2 and 16ca1c2 just weren't accounting for the transformed axes. The reference images for the tests need to be updated, but I verified that it is no more than they needed to before this commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant