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

geom_stats() digits arguement misbehaves #102

Open
rwbaer opened this issue Oct 27, 2024 · 0 comments
Open

geom_stats() digits arguement misbehaves #102

rwbaer opened this issue Oct 27, 2024 · 0 comments

Comments

@rwbaer
Copy link

rwbaer commented Oct 27, 2024

The digits argument misbehaves and is erratic. The default digits is not 3 as suggested in help. The digits behavior can be to produce more digits than specified for some gates and to produce less digits than specified for other gates. The over and under specification seems gate specific and consistent. The gate statistics in this example are both for boolean gates if that makes a difference.

Also:
[When plotting panels for boolean gates, it seems that the location is relative to the panel not the gate even if the location = "gate" is used. Perhaps this is inescapable for boolean gates and can be worked around using panel oriented adjustments.]

This is an example. The gating set is too large, but I can supply it if necessary.

gsSamp = load_gs(path =  "./DigitsLocationBugs")
p1 = ggcyto(gsSamp, subset = "Single Cells", 
            aes(x = `FL3-AREA`, y= `FL1-AREA`),
            limit = "instrument") +
  geom_hex(bins = 1024) +
  geom_density2d(color = "black", bins = 40) +
  labs(title = "Flow Cytometry - WM278 Efferocytosis",
       x = "Macrophage Staining (logicle)",
       y = "Melanoma (bait) Staining (logicle)" ) +
  axis_x_inverse_trans() +
  axis_y_inverse_trans() +
  geom_gate(c("Q1", "Q2", "Q3", "Q4"), colour = "red") +  

  geom_gate("Macrophages", colour = "blue") +
  geom_gate("Bait", colour = "green") +
  ggcyto_par_set(limits = "instrument") +
  facet_wrap( ~ factor(Phenotype), ncol = 2) +
  labs(title = "Predatory Macrophages")

In example 1 we expect 3 decimal digits since the default documented is 3. Instead we get 5 digits and the label is in the left part of the panel despite location = "gate" being specified.

# looks like both location = "gate" and the "digits = 3 default" are failing
# the location seems to be working "per panel" and not "per gate" when using adjust
p2 =  p1 +
  geom_gate(c("PredMac1"), shape = ".", colour = "pink", alpha = 0.4) +
  geom_stats(gate = "PredMac1", type = c("percent"), location = "gate") 
p2   

image

In example 2, we set adjustment that seem panel oriented and attemp to specify 1 digit. The legend is printed as specification +2 digits.

# digits gets called but the number of decimal digits is 3 larger than requested; location still seems wrong
p2 =  p1 +
  geom_gate(c("PredMac1"), shape = ".", colour = "pink", alpha = 0.4) +
  geom_stats(gate = "PredMac1", type = c("percent"), location = "gate", digits = 1L, adjust = c(0.95, 0.9))
p2   

image

In the third example we once again request digits = 1 but this time we get one less digit than requested. The difference is we are using a different gate. There seems no documented rhyme or reason that the behavior should change from one gate to another

# For a different gate decimal digits argument is wrong but is one less not 3 more than requested
p3 =  p1 +
  geom_gate(c("PredMel1"), shape = ".", colour = "pink", alpha = 0.4) +
  geom_stats(gate = "PredMel1", type = c("percent"), location = "gate", digits = 1L, adjust = c(0.95, 0.99)) +
  labs(title = "Predatory Melanoma") 
p3   

image

Session Information

sessionInfo()
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 27729)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8

time zone: America/Chicago
tzcode source: internal

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

other attached packages:
[1] shiny_1.9.1 patchwork_1.3.0 lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1
[6] dplyr_1.1.4 purrr_1.0.2 readr_2.1.5 tidyr_1.3.1 tibble_3.2.1
[11] tidyverse_2.0.0 CytoML_2.16.0 ggcyto_1.32.0 ncdfFlow_2.50.0 BH_1.84.0-0
[16] ggplot2_3.5.1 cytoverse_0.0.0.9000 CytoExploreR_1.1.0 openCyto_2.16.1 flowWorkspace_4.16.0
[21] flowCore_2.16.0 BiocManager_1.30.25

loaded via a namespace (and not attached):
[1] RColorBrewer_1.1-3 rstudioapi_0.17.1 jsonlite_1.8.9 umap_0.2.10.0 magrittr_2.0.3 farver_2.1.2
[7] rmarkdown_2.28 ragg_1.3.3 fs_1.6.4 zlibbioc_1.50.0 vctrs_0.6.5 memoise_2.0.1
[13] askpass_1.2.1 gh_1.4.1 htmltools_0.5.8.1 usethis_3.0.0 curl_5.2.3 sass_0.4.9
[19] bslib_0.8.0 htmlwidgets_1.6.4 desc_1.4.3 plyr_1.8.9 httr2_1.0.5 zoo_1.8-12
[25] cachem_1.1.0 changepoint_2.2.4 mime_0.12 lifecycle_1.0.4 pkgconfig_2.0.3 rsvd_1.0.5
[31] Matrix_1.7-0 R6_2.5.1 fastmap_1.2.0 digest_0.6.37 colorspace_2.1-1 S4Vectors_0.42.1
[37] ps_1.8.0 RSpectra_0.16-2 pkgload_1.4.0 textshaping_0.4.0 labeling_0.4.3 cytolib_2.16.0
[43] fansi_1.0.6 timechange_0.3.0 compiler_4.4.1 remotes_2.5.0 withr_3.0.1 EmbedSOM_2.1.2
[49] flowClust_3.42.0 hexbin_1.28.4 pkgbuild_1.4.4 MASS_7.3-60.2 openssl_2.2.2 rappdirs_0.3.3
[55] sessioninfo_1.2.2 tools_4.4.1 httpuv_1.6.15 flowAI_1.34.0 glue_1.8.0 callr_3.7.6
[61] cytoinstaller_0.1.0 promises_1.3.0 grid_4.4.1 Rtsne_0.17 reshape2_1.4.4 generics_0.1.3
[67] isoband_0.2.7 gtable_0.3.6 tzdb_0.4.0 data.table_1.16.2 hms_1.1.3 utf8_1.2.4
[73] BiocGenerics_0.50.0 pillar_1.9.0 later_1.3.2 robustbase_0.99-4-1 lattice_0.22-6 RProtoBufLib_2.16.0
[79] tidyselect_1.2.1 RBGL_1.80.0 miniUI_0.1.1.1 knitr_1.48 rhandsontable_0.3.8 gitcreds_0.1.2
[85] gridExtra_2.3 svglite_2.1.3 stats4_4.4.1 xfun_0.48 Biobase_2.64.0 devtools_2.4.5
[91] matrixStats_1.4.1 DEoptimR_1.1-3 visNetwork_2.1.2 stringi_1.8.4 yaml_2.3.10 evaluate_1.0.1
[97] Rgraphviz_2.48.0 graph_1.82.0 cli_3.6.3 systemfonts_1.1.0 xtable_1.8-4 reticulate_1.39.0
[103] munsell_0.5.1 processx_3.8.4 jquerylib_0.1.4 Rcpp_1.0.13 png_0.1-8 XML_3.99-0.17
[109] parallel_4.4.1 ellipsis_0.3.2 profvis_0.4.0 urlchecker_1.0.1 scales_1.3.0 crayon_1.5.3
[115] rlang_1.1.4

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

No branches or pull requests

1 participant