ggcyto and ggplot themes behavior unexpected
0
0
Entering edit mode
Robert Baer ▴ 70
@robert-baer-4660
Last seen 22 months ago
United States

This is a duplicate of issue #85 that I made to github 24 days ago. In retrospect, I'm not sure of the proper place to post it. The issue is missing legends and improper fill behavior.

For reference, to an apparently a similar problem, see your .md file for ggcyto where it is claimed fills will appear but they do not. See figures 5th & 6th figure at the link below: [(https://github.com/RGLab/ggcyto/blob/master/vignettes/ggcyto.flowSet.md)]

In creating ggcyto() figure, certain forms of faceting produces plots that are expected to have a legend but do not produce one. Further, when using geom_gate() on a 1D figure, The fill on the figure disappears.

Experimentation (well the experimentation failed and serendipity actually was key :-) shows that the problem(s) can be worked around by adding a theme(complete = TRUE) if that helps you to figure out the root problem.

This report/question may be related to issue #84 on ggcyto as well as issue #85.

Here is a reproducible example that demonstates both the fill and legend problems and also demonstrates the workaround:


# Legend and fill issues with ggcyto
library(openCyto)
library(ggcyto)
# A reproductible test gating set
data(GvHD)
fs <- GvHD[subset(pData(GvHD), Patient %in%5:7 & Visit %in% c(5:6))[["name"]]]

# transform
tf <- transformList(colnames(fs[[1]])[3:6], asinh, transformationId="asinh")
fs_trans<-transform(fs,tf)
gs <- GatingSet(fs_trans)

# Add a gate
chnl <- "FL1-H"
minden <- openCyto:::.mindensity(fs[[1]], channels = chnl)

ggplot(gs, subset = "root", aes(x = `FL1-H`, fill = name)) + geom_density(alpha = 0.2)

# Note that the expected legend is missing
p <- ggcyto(gs, aes(x = `FL1-H`), subset = "root") + 
  geom_density(aes(fill = Visit), alpha = 0.1) +
  facet_wrap(NULL)
p 

# Add a gate and the fill disappears too
p+ geom_gate(minden)

# The workaround is to add a complete theme
# The fill and missing legend return
p + theme(complete = TRUE)
p+ theme_gray()

sessionInfo()

sessionInfo() R version 4.1.3 (2022-03-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22598)

Matrix products: default

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

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

other attached packages: [1] ggcyto_1.22.0 flowWorkspace_4.6.0 ncdfFlow_2.40.0 BH_1.78.0-0
[5] RcppArmadillo_0.11.0.0.0 flowCore_2.6.0 ggplot2_3.3.5 openCyto_2.6.0

loaded via a namespace (and not attached): [1] bitops_1.0-7 matrixStats_0.61.0 RColorBrewer_1.1-3 httr_1.4.2 Rgraphviz_2.38.0
[6] tools_4.1.3 utf8_1.2.2 R6_2.5.1 KernSmooth_2.23-20 DBI_1.1.2
[11] BiocGenerics_0.40.0 colorspace_2.0-3 withr_2.5.0 gridExtra_2.3 tidyselect_1.1.2
[16] mnormt_2.0.2 curl_4.3.2 compiler_4.1.3 graph_1.72.0 cli_3.2.0
[21] Biobase_2.54.0 flowClust_3.32.0 xml2_1.3.3 labeling_0.4.2 flowStats_4.6.0
[26] scales_1.1.1 DEoptimR_1.0-10 hexbin_1.28.2 mvtnorm_1.1-3 robustbase_0.93-9
[31] RBGL_1.70.0 digest_0.6.29 rainbow_3.6 R.utils_2.11.0 rrcov_1.6-2
[36] base64enc_0.1-3 jpeg_0.1-9 pkgconfig_2.0.3 rlang_1.0.2 farver_2.1.0
[41] generics_0.1.2 mclust_5.4.9 gtools_3.9.2 dplyr_1.0.8 R.oo_1.24.0
[46] RCurl_1.98-1.6 magrittr_2.0.3 RProtoBufLib_2.6.0 Matrix_1.4-0 Rcpp_1.0.8.3
[51] munsell_0.5.0 S4Vectors_0.32.4 fansi_1.0.3 lifecycle_1.0.1 R.methodsS3_1.8.1
[56] MASS_7.3-55 zlibbioc_1.40.0 plyr_1.8.7 grid_4.1.3 parallel_4.1.3
[61] crayon_1.5.1 lattice_0.20-45 splines_4.1.3 tmvnsim_1.0-2 pillar_1.7.0
[66] fda_5.5.1 corpcor_1.6.10 stats4_4.1.3 XML_3.99-0.9 glue_1.6.2
[71] latticeExtra_0.6-29 data.table_1.14.2 RcppParallel_5.1.5 deSolve_1.30 png_0.1-7
[76] vctrs_0.4.0 gtable_0.3.0 aws.s3_0.3.21 purrr_0.3.4 clue_0.3-60
[81] assertthat_0.2.1 ks_1.13.4 fds_1.8 pracma_2.3.8 IDPmisc_1.1.20
[86] pcaPP_1.9-74 tibble_3.1.6 cytolib_2.6.2 aws.signature_0.6.0 flowViz_1.58.0
[91] ellipse_0.4.2 cluster_2.1.2 ellipsis_0.3.2 hdrcde_3.4

ggcyto • 506 views
ADD COMMENT

Login before adding your answer.

Traffic: 723 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

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

Powered by the version 2.3.6